How can I change coding around SWF files ?? Editing CLASS file ??

VictorZ

Joined: 2007-09-20
Posts: 18
Posted: Wed, 2009-09-02 03:09

I'm using Carbon theme ... some slight modifications, but nothing extraordinary. Images are no problem, though what I want to display, and DO HAVE a problem with, is panoramic VR images packaged into an flash/SWF file. These are images that you can "pan" fully around using the mouse.

If I create the Flash SWF file that contains the panorama, upload it to Gallery, it displays just like a static image, and works as expected ... that is to say, I can pan around with the mouse, zoom in/out, etc.

What does NOT work is the ability to have the image go "full screen". It requires some javascript code to make it work that I'd like to know how to embed into Gallery.

If I view the HTML code/source created by gallery for the displayed photo page containing the uploaded flash/SWF file, I find the following:

+-+-+-+-+-+-+-+-+-+-+- SNIPPET -+-+-+-+-+-+-+-+-+-+-+-+-+- SNIPPET -+-+-+-+-+-+-+-+-+-+-+-+

<div id="gsImageView" class="gbBlock">
<div id="photo">
<script type="text/javascript">
// <![CDATA[
if (window.ActiveXObject) {
document.write('<object id="animation"');
document.write(' ');
document.write(' width="1000"');
document.write(' height="600"');
document.write(' autoplay="true"');
document.write(' pluginspage="http://www.apple.com/quicktime/download/"');
document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,30,0"');
document.write(' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">');
document.write(' <param name="movie" value="main.php?g2_view=core.DownloadItem&amp;g2_itemId=968&amp;g2_serialNumber=2" />');
document.write(' <param name="quality" value="high" />');
document.write(' <param name="salign" value="TL" />');
document.write(' <param name="wmode" value="opaque" />');
document.write(' <param name="allowNetworking" value="none" />');
document.write(' <param name="AllowScriptAccess" value="never" />');
document.write(' <param name="swLiveConnect" value="false" />');
document.write(' forceFullUrl=true forceSessionId=true}">Download animation</a>');
document.write('</object>');
} else {
document.write('<object id="movie"');
document.write(' ');
document.write(' type="application/x-shockwave-flash"');
document.write(' data="main.php?g2_view=core.DownloadItem&amp;g2_itemId=968&amp;g2_serialNumber=2"');
document.write(' width="1000"');
document.write(' height="600">');
document.write(' <param name="movie" value="main.php?g2_view=core.DownloadItem&amp;g2_itemId=968&amp;g2_serialNumber=2" />');
document.write(' <param name="quality" value="high" />');
document.write(' <param name="salign" value="TL" />');
document.write(' <param name="wmode" value="opaque" />');
document.write(' <param name="allowNetworking" value="none" />');
document.write(' <param name="AllowScriptAccess" value="never" />');
document.write(' <param name="swLiveConnect" value="false" />');
document.write(' forceFullUrl=true forceSessionId=true}">Download animation</a>');
document.write('</object>');
}
//]]>
</script>
</div>

+-+-+-+-+-+-+-+-+-+-+- SNIPPET -+-+-+-+-+-+-+-+-+-+-+-+-+- SNIPPET -+-+-+-+-+-+-+-+-+-+-+-+

It looks like gallery's files - templates, inc's, class, etc. files - provides javascript code wrapping the image/SWF for display.

What I'd like to do is to modify this javascript code in such a way as to get the a different set of coding in order that clicking on the "full screen" icon in the image works. Right now, clicking does nothing at all.

It appears that this code comes from the GalleryAnimationItem.Class file, but I'm not sure ... I'm a tinkerer, not a programmer. I can generally figure things out, find where some of the HTML code is being generated, etc., but this one is just beyond my abilities.

Can anyone be of assistance here? Point me in a direction as to where I need to go?

I don't want to "break" animation functionality as it may be useful presenting videos, etc. (if my understanding is correct). Might it be possible/necessary to create/specify a special handler for these panoramic types of images?

Here's an example of the code that I would need to have implemented rather than that shown above:

+-+-+-+-+-+-+-+-+-+-+- SNIPPET -+-+-+-+-+-+-+-+-+-+-+-+-+- SNIPPET -+-+-+-+-+-+-+-+-+-+-+-+

<script type="text/javascript">
<!--
if ((window.p2q_Version) && (window.p2q_Version>=2.0)) {
// Check to see if the version meets the requirements for playback
var flashvars="";
p2q_EmbedFlash('4133.01_out.swf','100%','95%','allowFullScreen','true','FlashVars',flashvars);

if (!DetectFlashVer(9,0,0)) {
document.write('<p class="warning">This content requires Adobe Flash Player Version 9 or higher. '
+ '<a href="http://www.adobe.com/go/getflash/">Get Flash<\/a><\/p>');
}
} else {
document.writeln('<p class="warning">p2q_embed_object.js is not included or it is too old!
Please copy this file into your html directory.<\/p>');
}
//-->
</script>

The image/filename is place in after p2q_EmbedFlash('SWF_name_here',...

"p2q_embed_object.js" is placed in the directory path. There is also the following embedded in the /HEAD section of the generated HTML photo display page ...

<script type="text/javascript" src="p2q_embed_object.js">
</script>

... but this doesn't seem like it would be a problem to figure out how to add in.

Thanks in advance for your assistance!! If a sample page is desired/required, I'll be happy to set something up for that purpose.

Victor Z

Login or register to post comments
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 3188
Posted: Wed, 2009-09-02 11:08

I've changed mine to use swfObject.
It detects the version for you, and swfObject is already included in the flashvideo module.

case 'HTML':
	    $urlGenerator =& $gallery->getUrlGenerator();
	    $src = $urlGenerator->generateUrl(
		array('view' => 'core.DownloadItem', 'itemId' => $this->getId(),
		      'serialNumber' => $this->getSerialNumber()),
		array('forceFullUrl' => !empty($params['forceFullUrl'])));
	    list ($width, $height) = array($this->getWidth(), $this->getHeight());
	    switch($this->getMimeType()) {
	    case 'application/x-shockwave-flash':
		    $divNum = rand()+$count;
		    $SWFObjectUrl = $urlGenerator->generateUrl(
		        array('href' => 'modules/flashvideo/lib/swfobject.js'),
		        array('forceFullUrl' => true));
		    $expressInstallUrl = $urlGenerator->generateUrl(
		        array('href' => 'modules/flashvideo/lib/expressinstall.swf'),
		        array('forceFullUrl' => true));
		    return sprintf(
		    '<script type="text/javascript" src="%s"></script>
		    <div id="swfContent%s">Javascript required to view this content</div>
		    <script type="text/javascript">
		    // <![CDATA[
		    var so = new SWFObject("%s", "%s", "%s", "%s", "9.0.115.0", "ffffff");
		    so.useExpressInstall("%s");
		    so.addParam("allowScriptAccess","always");
		    so.addParam("wmode","transparent");
		    so.addParam("loop","false");
		    so.addParam("allowFullScreen","true");
		    so.write("swfContent%s");
		    // ]]>
		    </script>',
		    $SWFObjectUrl, $divNum, $src, !empty($params['id']) ? $params['id'] : 'movie',
		         $width, $height, $expressInstallUrl, $divNum);

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

Login or register to post comments
VictorZ

Joined: 2007-09-20
Posts: 18
Posted: Wed, 2009-09-02 16:09

Suprsidr,

Thank you for your response. Is "FlashYourWeb" your site and products? Very nice!

I'm not sure I understand what you mean by "...changed mine to use swfObject." I see where swfObject resides, in the flashvideo folder. I'm not sure where, exactly, I would be able to insert modified javascript coding to make the call I need to allow full screen rendering. I see that there is HTML generation coding to create a script block in what you posted, but I'm not sure where that resides or how it is being called?

Please forgive my stupidity in this matter at the moment!!

The SWF in question is not a "video" in the strict sense ... rather, it's an interactive image. Additionally, autodetection of version isn't the issue, although there may be a requirement for flash of at least a given version level.

Here's an example ... not in gallery ... of the type of object I'm talking about and the most rudimentary HTML and javascripting requirements to get the behavior I'm looking for.

http://www.zaveduk.com/panotemp/4133.02.8k.7s.htm

The last icon on the right (sliding control bar, lower left of object, next to arrows that slide controls in and out) switches the view to full screen. Click and drag to move the view around. The +/- icons (or +/- keys when not in full screen) control zoom in and out. The arrow brackets control panning, like dragging with the mouse, and the circular arrow turns auto scrolling on and off. You've probably seen these before and I'm sure I didn't need to explain how it works, but it's not clear who else might be reading this. Any gallery page would probably have (or provide a link to) some sort of help/instructions for the uninitiated.

In gallery, I can get the SWF to display the initial conditions - the moving image much as a static image would be displayed. The fullscreen button is inoperative, however, because the additional surrounding javascript is absent. I'm pretty sure I can figure out how to get the required 'p2q_embed_object.js' in place, but still need to modify the HTML generated around the SWF.

Again, pardon my ignorance of coding and many thanks in advance for your further help!

Victor

Login or register to post comments
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 3188
Posted: Wed, 2009-09-02 23:33
Quote:
I'm not sure I understand what you mean by "...changed mine to use swfObject

I changed the way gallery displays flash animations(swf)

The code I supplied is to replace gallery2/modules/core/classes/GalleryAnimationItem.class
~ line(s) 197 - 228 in function render
to take advantage of swfObject which BTW will do correctly what you are trying to do.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

Login or register to post comments
VictorZ

Joined: 2007-09-20
Posts: 18
Posted: Thu, 2009-09-03 03:39

-s

Thanks for the clarification ... it's about what I thought but until I snagged a decent text editor for code, I couldn't make heads or tails of the GalleryAnimationItem file; notepad doesn't cut it!

I'll give it a try with swfObject ... changing the call replacing pp2q_embed_object as it'll do the same thing. Simplifies things for sure.

Victor

Login or register to post comments
VictorZ

Joined: 2007-09-20
Posts: 18
Posted: Thu, 2009-09-03 04:56

-s

Hmmm ... replaced code in section as directed, and now when I choose the sub-album which contains the SWF file, all I get is a blank white page. "View Source" on that page is equally blank. Replacing with the original GalleryAnimationItem file and it's back to the way it was. So, something is obviously amiss but what that something is sure isn't obvious to me. :(

Any suggestions as to how I might troubleshoot this?

Thanks in advance...
Victor

Login or register to post comments
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 3188
Posted: Thu, 2009-09-03 10:48
Login or register to post comments
VictorZ

Joined: 2007-09-20
Posts: 18
Posted: Thu, 2009-09-03 14:12

-s

That's got it, thanks! I see my error now, I didn't replace enough text with the clip you provided.

> "The code I supplied is to replace gallery2/modules/core/classes/GalleryAnimationItem.class
> ~ line(s) 197 - 228 in function render

I know you indicated "~" ... an approximate range ... so I replaced down from the "case" statement (at line 197) to just after the next "</script>" statement at line 248 as the clip contained an additional couple of lines beyond that point. Line 228 clearly wasn't far enough as that would have left an unbalanced "<script>" statement.

I thought I was being clever! But not knowing/understanding the code next bit of code, and being too literal in following the directions, I didn't realize that I needed to replace all the way down to line 264, just before the next "case" statement and inclusive of the two paragraphs of code containing the IE and Mozilla Object items. Looking at it now, I think I see why that should have made more sense. Easy and obvious once it is pointed out ... doh! I clearly need to study up on PHP coding if I want to do more than simple cosmetic customization.

In any case, thank you very much for your assistance! Problem solved and desired behavior successfully added!

Victor

Login or register to post comments