|
-
absolute newbie needs help
hi,
after some basic help please.
I got this video jukebox from zain@flashkit.
the first movie plays as soon as it is loaded.
how do i make the movie load but not play until started?
thanks,
keith.
as2 code below. - what do i change to achieve my aim.
PHP Code:
//--------------------- Variables ------------------------// var nDownload:Number; var nPlayback:Number;
var totalLength:Number; //total length(in secs) of movie playing var currentVideo:Number = 0; var totalVideos:Number; var scrubSpeed:Number = 5; //scrubbing speed when scrub buttons are pressed var paused:Boolean = false; //whether movie is paused or not var movieEnded:Boolean;
var aVideos:Array = new Array();
// ---------------------- Load XML -----------------------//
var videoXML:XML = new XML(); videoXML.ignoreWhite = true;
var rootNode:XMLNode; var currNode:XMLNode;
videoXML.onLoad = function():Void{ rootNode = this.firstChild; for(var i:Number = 0; i < rootNode.childNodes.length; i++){ currNode = rootNode.childNodes[i]; aVideos.push({ source:currNode.attributes["source"], title:currNode.attributes["title"], author:currNode.attributes["author"], year:currNode.attributes["year"]} ) } totalVideos = aVideos.length; populateList(); }
videoXML.load("videos.xml");
//------------------------------List Box and Fields-------------------------------//
var cList:Object = mcTab.mcPlaylist.cList; cList.vScrollPolicy = "auto";
var listListener:Object = new Object(); cList.addEventListener("change", listListener);
listListener.change = function(){ var index:Number = cList.selectedIndex; currentVideo = index; populateFields(index); playVideo(aVideos[index].source); }
function populateList():Void{ for(var i:Number=0; i<totalVideos; i++){ cList.addItem(aVideos[i].title); } cList.selectedIndex = currentVideo; populateFields(0); playVideo(aVideos[0].source) }
function populateFields(index:Number):Void{ tTitle.text = aVideos[index].title; tYear.text = aVideos[index].year; tAuthor.text = aVideos[index].author; }
// ---------------- NetConnection and NetStream Objects --------------//
var nc:NetConnection = new NetConnection(); nc.connect(null);
var ns:NetStream = new NetStream(nc); ns.setBufferTime(5); mcVideo.oVideo.attachVideo(ns);
function playVideo(video:String):Void{ movieEnded = false; mcBuffer._visible = true; clearIntervals(); ns.play(video); nDownload = setInterval(downloadProgress, 1000/24); nPlayback = setInterval(playback, 1000/24); }
//-----------------------------------onStatus Event Handlers -------------------//
ns.onStatus = function(oInfo:Object):Void{ trace(oInfo.code); if(oInfo.code == "NetStream.Play.Start"){ //trace("movie has started"); } if(oInfo.code == "NetStream.Play.Stop"){ trace("movie ended"); clearInterval(nPlayback); movieEnded = true; mcBuffer._visible = false; } if(oInfo.code == "NetStream.Play.StreamNotFound"){ trace("movie cannot be found"); } if(oInfo.code == "NetStream.Buffer.Full"){ mcBuffer._visible = false; } if(oInfo.code == "NetStream.Buffer.Empty" && !movieEnded){ trace("buffer empty"); mcBuffer._visible = true; //buffer is empty now we need to check if remaining movie time is less buffer requirement var timeRemaining:Number = totalLength - ns.time; if(timeRemaining < ns.bufferTime){ ns.setBufferTime(timeRemaining); } } }
ns["onMetaData"] = function(oInfo:Object):Void{ totalLength = oInfo.duration; }
trace(ns.bufferTime);
//----------------------------- Download Progress --------------------//
var nBytesLoaded:Number; var nBytesTotal:Number; var percentageLoaded:Number
function downloadProgress():Void{ nBytesLoaded = ns.bytesLoaded; nBytesTotal = ns.bytesTotal; percentageLoaded = nBytesLoaded/nBytesTotal * 100; mcProgressBar.mcDownloadBar._xscale = percentageLoaded; if(percentageLoaded == 100){ clearInterval(nDownload); } }
//----------------------------------------PLAYBACk PROGRESS ----------------------------------//
var percentPlayed:Number;
function playback():Void{ percentPlayed = ns.time/totalLength * 100; mcProgressBar.mcPlayhead._x = percentPlayed * 1.5; }
//-------------------------- Playback controls and Scrub-------------------//
mcControls.mcPlay.onRelease = function():Void{ if(paused){ ns.pause(); paused =!paused; } }
mcControls.mcNext.onRelease = function():Void{ currentVideo++; if(currentVideo == totalVideos){currentVideo = 0;} cList.selectedIndex = currentVideo; populateFields(currentVideo); playVideo(aVideos[currentVideo].source); }
mcControls.mcPrevious.onRelease = function():Void{ currentVideo--; if(currentVideo < 0){currentVideo = totalVideos-1;} cList.selectedIndex = currentVideo; populateFields(currentVideo); playVideo(aVideos[currentVideo].source); }
mcControls.mcForward.onPress = function():Void{ this.onEnterFrame = function():Void{ ns.seek(ns.time + scrubSpeed); } }
mcControls.mcForward.onRelease = function():Void{ delete this.onEnterFrame; }
mcControls.mcRewind.onPress = function():Void{ this.onEnterFrame = function():Void{ ns.seek(ns.time - scrubSpeed); } }
mcControls.mcRewind.onRelease = function():Void{ delete this.onEnterFrame; }
mcControls.mcPause.onRelease = function():Void{ ns.pause(); paused = !paused; }
mcProgressBar.mcPlayhead.onPress = function():Void{ clearInterval(nPlayback); this.startDrag(true, 0, this._y, mcProgressBar.mcDownloadBar._xscale * 1.5, this._y); this.onEnterFrame = function():Void{ ns.seek(this._x * totalLength/150); } }
mcProgressBar.mcPlayhead.onRelease = function():Void{ this.stopDrag(); delete this.onEnterFrame; nPlayback = setInterval(playback, 1000/24); }
mcProgressBar.mcPlayhead.onReleaseOutside = mcProgressBar.mcPlayhead.onRelease;
//-------------------------- MUTE BUTTON ----------------------------------------------------//
var flvSound_mc:MovieClip = _root.createEmptyMovieClip("flvSound_mc",_root.getNextHighestDepth()); flvSound_mc.attachAudio(ns);
var soundHolder_sound:Sound = new Sound(flvSound_mc); soundHolder_sound.setVolume(100);
mcMute.onRelease = function():Void{ if(soundHolder_sound.getVolume() == 100){ soundHolder_sound.setVolume(0); mcMute.gotoAndStop(2); }else{ soundHolder_sound.setVolume(100); mcMute.gotoAndStop(1); } }
//-----------------------------------TOOL TIPs For controls--------------------------------------------// mcTip.tText.autoSize = "left";
mcControls.mcPlay.onRollOver = toolTip; mcControls.mcForward.onRollOver = toolTip; mcControls.mcRewind.onRollOver = toolTip; mcControls.mcNext.onRollOver = toolTip; mcControls.mcPrevious.onRollOver = toolTip; mcControls.mcPause.onRollOver = toolTip;
mcControls.mcPlay.onRollOut = resetTip; mcControls.mcRewind.onRollOut = resetTip; mcControls.mcForward.onRollOut = resetTip; mcControls.mcNext.onRollOut = resetTip; mcControls.mcPrevious.onRollOut = resetTip; mcControls.mcPause.onRollOut = resetTip; mcControls.mcPlay.onRollOut = resetTip;
function toolTip():Void{ switch(this){ case _level0.mcControls.mcNext: mcTip.tTip.text = "next"; break; case _level0.mcControls.mcPrevious: mcTip.tTip.text = "previous"; break; case _level0.mcControls.mcForward: mcTip.tTip.text = "forward"; break; case _level0.mcControls.mcRewind: mcTip.tTip.text = "rewind"; break; case _level0.mcControls.mcPlay: mcTip.tTip.text = "play"; break; case _level0.mcControls.mcPause: mcTip.tTip.text = "pause"; break; } this.onEnterFrame = function():Void{ mcTip._x = _xmouse; } }
function resetTip():Void{ delete this.onEnterFrame; mcTip.tTip.text = ""; }
//-------------------------PLAYLIST TAB FUNCTIONALITY ----//
mcTab.mcHit.onRollOver = function():Void{ mcTab.play(); }
//-----------------------------clear intervals ---------------------//
function clearIntervals():Void{ clearInterval(nDownload); clearInterval(nPlayback); }
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|