Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 152999

Can I make a dynamic video player stop just by exiting the frame and entering a new one?

$
0
0

Ok so I have a flash presentation with a video clip which I am playing dynamically using a URL netStream. The problem is not getting it to play but rather getting it to stop playing. If I click the stop button, it stops, But if I just navigate to  a new frame, the video disappears but I can still hear the audio. (the only reason it disappears is because i used "video.visible = false" on all other frames other than the one I need it to play on. Additionally, If I navigate to a new frame while the video is playing, I cannot stop it or restart if I return back to the frame that the video is located on. Its like all my video control buttons are rendered useless if I leave the frame while it is playing. Do I need some sort of eventlistener or custom function? I hope I explained that well enough.

 

Here is my code if anyone has any suggestions.

Thanks!

 

 

  //video code

 

 

  var video:Video = new Video(480,204);

  video.y = stage.stageHeight / 2 - 278 / 2;

  video.x = stage.stageWidth / 2 - 290 / 2;

  addChild(video);

 

 

    var nc:NetConnection = new NetConnection();

  nc.connect(null);

 

 

  var ns:NetStream = new NetStream(nc);

 

 

  ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);

  function onStatusEvent(stat:Object):void

  {

  trace(stat.info.code);

  }

 

 

  var meta:Object = new Object();

  meta.onMetaData = function(meta:Object){

  trace(meta.duration);

  };

 

 

  ns.client = meta;

  video.attachNetStream(ns);

 

 

  btn_playvid.addEventListener(MouseEvent.CLICK, playFunction);

  function playFunction(evt:MouseEvent):void

  {

  ns.play("assets/movie.mp4");

  }

 

 

  btn_stopvid.addEventListener(MouseEvent.CLICK, stopFunction);

 

 

  function stopFunction(evt:MouseEvent):void

  {

  ns.pause();

  }

}


Viewing all articles
Browse latest Browse all 152999

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>