Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Missing audio in video when adding transition

Status
Not open for further replies.

beachboy75

Programmer
Aug 28, 2006
4
NO
Hi!
I'm new to flash 8, and trying to learn video playback in Flash, and I have one question: I've added a transition effect between 3 videos, and when I play the swf file, the audio is missing in the 3 video's.
Is it so that audio automaticly dissapear when I add transitions?

Thanks for any answer...
 
Thank you for your reply, here's my actionscript if its any help:

****************************************
Code:
import mx.transitions.*;
var videoLoadedCount:Number = 0;
var videoPlayerIndex:Number = 0;
var videoList:Array = new Array("flashmovie1.flv","flashmovie2.flv","flashmovie3.flv");

for (var loaderLoop:Number = 1; loaderLoop <= videoList.length;
loaderLoop++){
vidcomp.activeVideoPlayerIndex = loaderLoop;
vidcomp.load(videoList[loaderLoop - 1]);
}
function eready(e:Object):Void {
++videoLoadedCount;
if ( videoLoadedCount == videoList.length ) {
for (var playerLoop:Number = 1; playerLoop <= videoList.length;
playerLoop++ ){
e.target.activeVideoPlayerIndex = playerLoop;
e.target.play();
}
}
}
vidcomp.addEventListener("ready", eready);
function ecomplete(e:Object):Void {
for (var playerLoop:Number = 1; playerLoop <= videoList.length;
playerLoop++) {
e.target.activeVideoPlayerIndex = playerLoop;
e.target.play();
}
}



vidcomp.addEventListener("complete", ecomplete);

function transDone(e) {
vidcomp.visibleVideoPlayerIndex = e.target.content._name;
trace(e.target.content._name);
}
function buttonTransition(m:MovieClip, d:Number) {
if (d != m.visibleVideoPlayer) {
var other:MovieClip = m.getVideoPlayer(d);
m.bringVideoPlayerToFront(d);
var vp:MovieClip = other;
TransitionManager.start(vp,{type:mx.transitions.Blinds,
direction:0,
duration:1,
easing:mx.transitions.easing.None.easeNone,
param1:empty,
param2:empty});
vp._transitionManager.addEventListener("allTransis tionsInDone",transDone);
}
}



video1Button.onPress = function(){
buttonTransition(_level0.vidcomp, 1);
};
video2Button.onPress = function(){
buttonTransition(_level0.vidcomp, 2);
};
video3Button.onPress = function(){
buttonTransition(_level0.vidcomp, 3);
};
 
I have just done a quick test and applying a TransitionManager class to a VideoPlayer did not kill the sound.

Looking at your code, I can see there are few problems. Apart from typos (e.g. "visibleVideoPlayerIndex", not "visibleVideoPlayer"), you're treating indexes such as visibleVideoPlayerIndex and activeVideoPlayerIndex as 1-based (they are zero-based, which is ActionScript standard.) Most importantly only the Player set with visibleVideoPlayerIndex will have the sound, and your code is failing to set that.

Kenneth Kawamoto
 
Thanks for your reply, and ways to correct it. Im not that solid in english so I wonder what you meen by: "treating indexes such as visibleVideoPlayerIndex and activeVideoPlayerIndex as 1-based (they are zero-based, which is ActionScript standard.)" Could you please point out in the code where this mistake is done?

In advance, thank you for your help....
 
I meant your activeVideoPlayerIndex and visibleVideoPlayerIndex starts with1 but it should start with 0. (I was surprised that your code actually worked at all!)

I did simplify and amend your code to demonstrate the transition effect you're after. It does not kill the sound (at least with my test FLV files):
Code:
import mx.transitions.*;
import mx.video.*;
var lo:Object = new Object();
var videoList:Array = new Array("flashmovie1.flv", "flashmovie2.flv", "flashmovie3.flv");
for (var i = 0, videoCount:Number = videoList.length; i<videoCount; i++) {
	vidcomp.activeVideoPlayerIndex = i;
	vidcomp.play(videoList[i]);
	vidcomp.addEventListener("complete", lo);
}
lo.complete = function(eo:Object):Void  {
	if (eo.state="stopped") {
		eo.target[eo.vp].play();
	}
};
function buttonTransition(m:MovieClip, d:Number):Void {
	if (d != m.visibleVideoPlayerIndex) {
		m.bringVideoPlayerToFront(d);
		var tm:TransitionManager = new TransitionManager(m[d]);
		tm.startTransition({type:Blinds, direction:0, duration:1, easing:None.easeNone});
		lo.id = d;
		lo.allTransitionsInDone = function() {
			m.visibleVideoPlayerIndex = this.id;
		};
		tm.addEventListener("allTransitionsInDone", lo);
	}
}
video1Button.onPress = function():Void  {
	buttonTransition(_level0.vidcomp, 0);
};
video2Button.onPress = function() {
	buttonTransition(_level0.vidcomp, 1);
};
video3Button.onPress = function() {
	buttonTransition(_level0.vidcomp, 2);
};

Kenneth Kawamoto
 
Thanks, it did the trick! I will compare theese codes and hopefully be a bit smarter after :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top