Skip to main content
Participant
October 29, 2012
Question

Youtube clip sound continues playing while changing frames

  • October 29, 2012
  • 2 replies
  • 1726 views

Hi there,

At the moment I have been creating a website using flash/AS3. I currently have a Youtube clip put in, which plays fine when run. The website itself has around 5 different sections on different frames. The problem I have is that when I change frame (go to a different section(or page)), the sound from the Youtube clip continues to play, however if I go back to the Youtube clip, it has stopped playing. The sound can't be stopped in any way unless I close the website.

If I push play on the Youtube clip again, then I have the sound of the clip overlapping the previous sound from the first time I pushed play. Is there any way I can stop the clip or turn off the sound when I switch frames/sections?

I am using CS6.

Thank you very much!

Joe

This topic has been closed for replies.

2 replies

Inspiring
January 26, 2013

You want to stop the audio from playing and also downloading more video/audio if it is still downloading when you go to a new keyframe where the video display/component or mp3 player is removed from the stage because it's keyframe ended or do not exist anymore but you still hear the audio.

Add an event listener to your video playback component that calls a function when the flash player tries to remove the video plaer from the stage that stops the netstream or at least stops/pauses the video playback.

[link removed]

//sample NetConnection and NetStream classes when the video player is removed from the stage tell the NetStream to stop playing or downloading the content with .close();

var connection:NetConnection = new NetConnection();

connection.connect(null);

var stream:NetStream = new NetStream(connection);

addEventListener(Event.REMOVED_FROM_STAGE, videoRemovedFromStage);

function videoRemovedFromStage(e:Event){

   stream.close();

}

Ned Murphy
Legend
October 29, 2012

How do you load the video/player?  If you use an FLVPlayback component do you also use its stop() method before leaving the frame?

buckey407Author
Participant
October 29, 2012

I export as a movie, and then play it in Adobe Flash Player. I do not currently use the FLVPlayback component. The movie clip currently has this code embedded to get the movie to work Youtube:

http://dropcanvas.com/sn5ly