-
netStream seek based on previous flv
Hey guys so here's something I'm trying to do.
I have a series of movie clips (flv's). All are the same movie clip of a rotating object but it's different colour in each clip.
When one clip is playing and I click to play another, I would like the clicked movie clip to start playing from the same position at which the previous clip was at. So if a clip had played for 3 seconds and I click a different clip, I would like it to seek and play from 3 seconds instead of 0.
So I've figured that I will need this for the play function of my clips:
PHP Code:
NetStream.seek(NetStream.time + "receive position in seconds of current playing video")
Can anyone tell me how I would go about tracking the data of how many seconds of a clip has played?
My guess is that it will either be metadata or NetStatusEvent related.
-
up to my .as in code
You could "track" it with an enterFrame routine or trap it for use in the other player where you want to with
yourNetStreaminstancename.time
I have a player running that tracks it (lower right of player..shown in seconds (rounded from milliseconds)) ...could just as easily trap it at whatever point I want for re-use to send another player to that point(this example does that but uses embedded cuepoints instead of manually trapped values and seeks the playhead in the same player) :
http://www.km-codex.com/?p=472
Last edited by Chris_Seahorn; 04-15-2009 at 11:37 PM.
-
hmm ok, I think I get what you're saying but may I see some code?
-
up to my .as in code
you'll see a lot of whining on the net about seek being an inexact science due to all kinds of reasons. I say you can get rather in the ballpark tweaking around with different methods. On face value something along the lines of
http://www.km-codex.com/examples/Sync_Cuepoints2.html
function getCue(e:MouseEvent):void
{
var foo:Number = Math.round(stream1.time) * 1000;
stream2.seek(Math.round(foo/1000));
}
in this example...scrub the playhead in the left player to any location and then sync...right player should match
http://www.km-codex.com/examples/Sync_Cuepoints.html
like i say...mess around
Last edited by Chris_Seahorn; 04-16-2009 at 01:09 AM.
-
Ah ok nice, looking pretty simple so far. Thing is I have one NetStream loading flvs dynamically from php generated xml and its 2am and I cant wrap my head around coding that right now.
Will I need to create two streams and have say a default video in stream1 and have the clicked videos load into stream2 and each click for a new video moves the previous video into stream1 and puts the new one into stream2? I'm going to sleep on that...
Here's my code if you can work anything out from it :P
PHP Code:
var connection:NetConnection; var stream:NetStream; var myvideo:Video; connection = new NetConnection(); connection.connect(null); stream = new NetStream(connection); stream.client = this;
var video:Video = new Video(768, 432); video.y = 147;
//stage.addEventListener(Event.RESIZE, resizeListener); //stage.scaleMode = StageScaleMode.NO_SCALE; //stage.align = StageAlign.TOP_LEFT; stage.addChild(video); video.attachNetStream(stream); stream.bufferTime = 1; //stream.receiveAudio(true); stream.receiveVideo(true);
/* function resizeListener(e:Event):void { video.width = stage.stageWidth; video.height = stage.stageWidth / 1.778; } */ function xmlLoaded(evt:Event):void { var myVideos:XML = new XML(evt.target.data); var colourlist:TextField = new TextField(); colourlist.autoSize = TextFieldAutoSize.LEFT; colourlist.multiline = true; colourlist.y = 5*(i+1); for (var i:Number=0; i<myVideos.videoitem.length(); i++) { colourlist.htmlText += "<a href=\"event:"+myVideos.videoitem[i].vidfile+"\"><img src=\"buttons/"+myVideos.videoitem[i].vidbutton+"\" /></a>"; addEventListener(TextEvent.LINK, linkHandler); //creates a listener for ONE specific link in the list } addChild(colourlist); //function to handle clicking on an html link in the list function linkHandler(linkEvent:TextEvent):void { playVideo(linkEvent.text); } //loads the video when the link is clicked function playVideo(vidfile:String) { stream.play("videos/"+vidfile); } //loop the flv stream.addEventListener(NetStatusEvent.NET_STATUS, statusHandler); function statusHandler(event:NetStatusEvent):void { if (event.info.code == "NetStream.Play.Stop") { stream.seek(0); } } }
Last edited by rogueblade; 04-16-2009 at 02:13 AM.
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
|