Skip to main content
Known Participant
November 28, 2009
Question

NetStream seekbar

  • November 28, 2009
  • 1 reply
  • 1667 views

I'm trying to figure out how I can add a seekbar to my netstream.

I have the duration of the flv through metadata and the current time of the stream, but I can't understand how I should connect them to pass a position to a seek handler. And allso to be able to drag the handler to positions in the stream.

Anyone have any tips on how to do this?

This topic has been closed for replies.

1 reply

November 29, 2009

you need to keep your netstream and seek bar parallel to one another.

If you have a videoPlayer class, it can be a sprite, which holds all your views and controllers.

-netStream

-video

-netConn

-navigation

     -play

     -pause

     -seek

     -fullscreen

now that they are parallel you can use the class they reside in to be the controller to connect the navigation to the video and netStream.

this can be done in a few ways based on how ever you feel more confortable but you will have to rely on events to carry out this work.

ill give you an easy one and you can then go with that to modify it how you wish.

var timer:Timer= new Timer()

      timer.delay=20

          timer.addEventListener(TimerEvent.TIMER,getPlayHead)

timer.start()

function getPlayHead(te:TimerEvent):void{

var playHead:Number= _ns.time  //the seconds of the video.

if(navigation.seekbar.playhead.active){  //check to see if user is pressing this or dragging it, if not then position playhead

nagivation.seekBar.handle.x=playHead/_ns.duration*100  // figure out how many seconds play head is at of totalSeconds and turn that into a percentage from 0-100  // remember this will only work properly if total video has been loaded.  otherwise if the video is still buffering you need to do more calculations to make sure the representation of the play head is in the proper placement of what is currently loaded to the total video.

}else{

_ns.seek((navigation.seekbar.plahead.x/100)*_ns.duration) // this will allow the stream to adjust to the position of the seekbar.

}

}

So i wrote this expecting that you wrote these as classes, which is why i left out a few things such as how do we know if playhead.active,

well i have expected that you have a mouseDown and a mouseUp event or something to this nature that when the class monitors its being pressed, it would be inactive and adjust that to its property.

if you have any questions please let me know