PDA

View Full Version : NetStream Class Stop Action


Mabron
05-22-2008, 03:48 AM
Problem: When using multiple instances of a FLV player in a FLA AS3 and when one navigates to another frame the video still plays from the earlier frames as one can still hear it...

I tried to implement loading a "phantom-light" FLV on the frame change to stop the video playing but I was not successful, note the code at the bottom...

What can be done?

Attach Code

function playMyFlv(){
_stream.close();
if(autoStart == "true" || is_single_file == false)
{
//player_paused = false;
toolbar.btn_play.dispatchEvent(new Event("mouseDown"));
} else {
autoStart = "true";
if(is_single_file == true){
getSingleImage();
big_play_btn.x = bg.width/2 - big_play_btn.width/2;
big_play_btn.y = bg.height/2 - big_play_btn.height/2;
big_play_btn.visible = true;
}
}
first_run=false;
toolbar.checkPlayButton();
}

function onMetaData(data:Object){
first_run=false;
if(contains(single_image_holder))removeChild(singl e_image_holder);
_timer.start();
_duration = data.duration;
_stream.soundTransform = toolbar.videoVolume;
toolbar.btn_volume.getVolume();
//resizeVideo();
}

function onNetStatus(e:NetStatusEvent){
//trace(e.info.code);
//this resets the player on movie end
if(e.info.code == "NetStream.Play.Stop"){
toolbar.resetMovie(new Event("e"));
first_run=true;
toolbar.alpha = 1;
}
if(e.info.code == "NetStream.Play.Start"){
_video.attachNetStream(_stream);
show_buffer = true;
}

if(e.info.code == "NetStream.Buffer.Empty"){
show_buffer = true;
}
if(e.info.code == "NetStream.Buffer.Full"){
show_buffer = false;
}

console.appendText(e.info.code);
resizeVideo();
}


//*************************This is the Kill Video Test Code HERE********************

/*function killdownload(){
_video.attachVideo(null);
playMyFlv.pause();
playMyFlv.play("nonexist.flv");
}

playMyFlv.onStatus = function (info) {
for (var r in info) {
trace ((r + " = ") + info[r]);
trace(my_video._height);
trace(my_video.height);
trace("-----------");
}
if(info.code == "NetStream.Play.Start"){
}
if(info.code == "NetStream.Play.Stop"){
stopping = true;
//trace("stopping");
}
if(info.code == "NetStream.Buffer.Empty" && stopping){
//trace("stopped");
}
if(info.code == "NetStream.Buffer.Full"){
if(preview){
killdownload();
}
}
};
*/

ddivine
02-23-2009, 09:33 PM
So did u ever find a solution to this problem?:)

Mabron
02-23-2009, 10:02 PM
I just added a line in the AS3 like this...
SetUp: Frames 2, 4, , 5 have my player instance on them, note: with a reset button associated with "mc_toolbar.btn_reset"...then i added these lines...
...
function stopMovies(){
if(currentFrame==4)playerExtreme_mc.toolbar.btn_re set.dispatchEvent(new Event("mouseDown"));
if(currentFrame==2)playerHome_mc.toolbar.btn_reset .dispatchEvent(new Event("mouseDown"));
if(currentFrame==5)playerMillionaire_mc.toolbar.bt n_reset.dispatchEvent(new Event("mouseDown"));

It is a pretty custom solution to my player's setup...but may spark an idea for you...

Best of Luck
Kindly,
matt
}