Log in

View Full Version : Pause flash video using Javascript command



jamesR
05-20-2010, 11:42 PM
Hello,

Not sure if this is the right forum, but if you can help me it would be much appreciated...

Here's the senario. I'm using DynamicDrive's "Content Glider" - http://www.dynamicdrive.com/dynamici...tentglider.htm
to expand a hidden video...

Everything works great until you click to hide to the video(colapse the div tag) it continues to play in the hidden state.

Is there any way to automatically shut it off when its hidden?

If you go to the link above it will show you the code in which how it works.

Thanks,

Brian

djr33
05-21-2010, 01:18 AM
Please post a link to the page on your site that contains the problematic script so we can check it out.

I can't tell from your post even what format the video is in.

Basically yes you can do this; you will add an extra event when you are hiding the layer; it will be the Javascript function to pause the video.

The exact code will depend on the format of the video, and in some cases it may not be possible. If you explain more, we'll see about the specific format and what can be done.



By the way, the link in your post doesn't work.

jamesR
05-21-2010, 02:58 PM
Please post a link to the page on your site that contains the problematic script so we can check it out.

I can't tell from your post even what format the video is in.

Basically yes you can do this; you will add an extra event when you are hiding the layer; it will be the Javascript function to pause the video.

The exact code will depend on the format of the video, and in some cases it may not be possible. If you explain more, we'll see about the specific format and what can be done.



By the way, the link in your post doesn't work.


Thank you so much my friend!!!! You have no idea how this will help me, serioulsy...

Here is my video container and flash embedded code. the the video itself is .mp4 or H.264.





<div id="jackee" style="display:none">
<div style="padding-left:25px"><img src="Images/background/footerbtnBGtop.jpg" width="903" height="47" /></div>
<div class="jackeehVid">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="740" height="482" id="FlashID2" title="jackeeHarryVideo">
<param name="movie" value="flash/video/jackeehvideo.swf" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="6.0.65.0" />
<!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="flash/video/jackeehvideo.swf" width="740" height="482">
<!--<![endif]-->
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="6.0.65.0" />
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
<div>



Here's the link to DD's script that I'm using:
http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm


Again, thank you very much. it's eternally appreciated.

Brian

djr33
05-21-2010, 04:49 PM
Hi, Brian.

Here's the problem: you need to use Javascript to send a command to Flash. That's difficult, to say the least. Everything else is easy enough, but somehow you'll need to connect the two. (It's easy to have flash send a command to Javascript, but since flash isn't, as far as I'm aware, really listening for Javascript commands, the other way is harder).

I'll move this to the Flash section so that someone can (hopefully) tell you how to get flash to listen and pause the video when needed. I also changed the title (please use a descriptive title-- it helps people identify your thread) so hopefully someone will know how to help you in the flash section.


By the way, one other way to do this would be to destroy the flash object so that it doesn't exist on the page any more. That might be easier; but then you'd have to reload it every time you made it appear and it would lose your place if that matters.

jamesR
05-21-2010, 05:00 PM
Hi, Brian.

Here's the problem: you need to use Javascript to send a command to Flash. That's difficult, to say the least. Everything else is easy enough, but somehow you'll need to connect the two. (It's easy to have flash send a command to Javascript, but since flash isn't, as far as I'm aware, really listening for Javascript commands, the other way is harder).

I'll move this to the Flash section so that someone can (hopefully) tell you how to get flash to listen and pause the video when needed. I also changed the title (please use a descriptive title-- it helps people identify your thread) so hopefully someone will know how to help you in the flash section.


By the way, one other way to do this would be to destroy the flash object so that it doesn't exist on the page any more. That might be easier; but then you'd have to reload it every time you made it appear and it would lose your place if that matters.

Ok, thanks. BTW - sorry about the "No title" bit... won't happen agian.


Thanks,
Brian

jamesR
05-21-2010, 06:17 PM
Ok, here's what I've found...
http://www.flash-here.com/tutorials/flash_from_js2.html

The only thing is I need the video to play and stop with the expand and colapse function of the division tag.

the video is set you auto play when the div tag is expanded to just need it to stop when it is hidden.

thanks,

Brian

jamesR
05-21-2010, 06:39 PM
here's what I done thus far...

I added another frame and moved the video to frame 2.
I then named the frames: frame one is "stop" and frame 2 is "play"

I'm thinking if I can get the script to target frame 1 (stop) on the colapse function, that will do it?

Question is, how to do it? Hmmm, i'm stumped please help me!!!

BLiZZaRD
05-21-2010, 09:22 PM
FlashVars

If you embedded using SWFObject it would be even easier. However...

The method is simple, You add AS code inside the Flash to pause or play the movie. Set this variable in the HTML as a FlashVar. When div is collapsed the FlashVar sets the variable to the pause function. When opened it sends a FlashVar to resume.

Unfortunately I don't really have the time right now to build you an example, but if you do a little research you will see how it is done.