//Requires: - FLVPlayback component on the Stage with an instance name of
my_FLVPlybk
// add a cue point to the default player
// add a cue point to the default player
import fl.video.*;
my_FLVPlybk.source =
"rtmp://sas-Flash.OnstreamMedia.com/ondemand/FlashDMSP/latitudeinc/MTV Mall
World/LadiesMan.flv";
my_FLVPlybk.addASCuePoint(10, "1st_switch");
my_FLVPlybk.addEventListener(VideoEvent.READY, ready_listener);
function ready_listener(eventObject:VideoEvent):void {
// add a second video player and create a cue point for it
my_FLVPlybk.activeVideoPlayerIndex = 1;
my_FLVPlybk.source =
"rtmp://sas-Flash.OnstreamMedia.com/ondemand/FlashDMSP/latitudeinc/Hills/ChooseO
rg.flv";
my_FLVPlybk.addASCuePoint(10, "2nd_switch");
my_FLVPlybk.activeVideoPlayerIndex = 0;
};
// add listener for a cuePoint event
my_FLVPlybk.addEventListener(MetadataEvent.CUE_POINT, cp_listener);
// add the handler function for the cuePoint event
function cp_listener(eventObject:MetadataEvent):void {
// display the no. of the video player causing the event
trace("Hit cuePoint event for player: " + eventObject.vp);
// test for the video player and switch FLV files accordingly
if (eventObject.vp == 0) {
my_FLVPlybk.pause();//pause the first FLV file
my_FLVPlybk.activeVideoPlayerIndex = 1;// make the 2nd player active
my_FLVPlybk.visibleVideoPlayerIndex = 1;// make the 2nd player visible
my_FLVPlybk.play();// begin playing the new player/FLV
} else if (eventObject.vp == 1) {
my_FLVPlybk.pause();// pause the 2nd FLV
my_FLVPlybk.activeVideoPlayerIndex = 0;// make the 1st player active
my_FLVPlybk.visibleVideoPlayerIndex = 0;// make the 1st player visible
my_FLVPlybk.play();
}// begin playing the 1st player
}
my_FLVPlybk.addEventListener(VideoEvent.COMPLETE, complete_listener);
function complete_listener(eventObject:VideoEvent):void {
trace("Hit complete event for player: " + eventObject.vp);
if (eventObject.vp == 0) {
my_FLVPlybk.activeVideoPlayerIndex = 1;
my_FLVPlybk.visibleVideoPlayerIndex = 1;
my_FLVPlybk.play();
} else {
my_FLVPlybk.closeVideoPlayer(1);
}
}
//trace audio volume
my_FLVPlybk.addEventListener(MetadataEvent.METADATA_RECEIVED, Loaded);
function Loaded(event:MetadataEvent):void {
trace(my_FLVPlybk.metadata.audiodatarate);
}
my_FLVPlybk.addEventListener(VideoEvent.PLAYING_STATE_ENTERED, isplaying);
function isplaying(e:VideoEvent):void {
trace(my_FLVPlybk.volume);
}
I can add that (using the code by rob day) that
my_FLVPlybk.soundtransfom.volume = 0;
and it can't be changed.
import fl.video.*;
my_FLVPlybk.source =
"rtmp://sas-Flash.OnstreamMedia.com/ondemand/FlashDMSP/latitudeinc/History/05Wri
tingTheDeclOfIndepence_H264.flv";
my_FLVPlybk.addASCuePoint(40, "1st_switch");
my_FLVPlybk.addEventListener(VideoEvent.READY, ready_listener);
function ready_listener(eventObject:VideoEvent):void {
my_FLVPlybk.activeVideoPlayerIndex = 1;
my_FLVPlybk.source =
"rtmp://sas-Flash.OnstreamMedia.com/ondemand/FlashDMSP/latitudeinc/Hills/ChooseO
rg.flv";
my_FLVPlybk.addASCuePoint(10, "2nd_switch");
my_FLVPlybk.activeVideoPlayerIndex = 0;
my_FLVPlybk.bufferTime=6;
}
my_FLVPlybk.addEventListener(MetadataEvent.CUE_POINT, cp_listener);
function cp_listener(eventObject:MetadataEvent):void {
if (eventObject.vp == 0) {
my_FLVPlybk.pause();
my_FLVPlybk.volume=0;//mute the player
my_FLVPlybk.activeVideoPlayerIndex = 1;
my_FLVPlybk.visibleVideoPlayerIndex = 1;
my_FLVPlybk.play();
my_FLVPlybk.volume=1;// set the volume
my_FLVPlybk.bufferTime=6;
} else if (eventObject.vp == 1) {
my_FLVPlybk.pause();
my_FLVPlybk.volume=0;
my_FLVPlybk.activeVideoPlayerIndex = 0;
my_FLVPlybk.visibleVideoPlayerIndex = 0;
my_FLVPlybk.play();
my_FLVPlybk.volume=1;
my_FLVPlybk.bufferTime=6;
}
}
my_FLVPlybk.addEventListener(VideoEvent.COMPLETE, complete_listener);
function complete_listener(eventObject:VideoEvent):void {
if (eventObject.vp == 0) {
my_FLVPlybk.volume=0;
my_FLVPlybk.activeVideoPlayerIndex = 1;
my_FLVPlybk.visibleVideoPlayerIndex = 1;
my_FLVPlybk.play();
my_FLVPlybk.volume=1;
} else {
my_FLVPlybk.closeVideoPlayer(1);
}
}