Skip to main content
Sunil Kumar Sah
Inspiring
August 4, 2010
Answered

How to show video frames as still preview image when roll over on seek bar just like Hulu?

  • August 4, 2010
  • 1 reply
  • 7443 views

Hi,

     I just want to show current video frames when mouse roll over on seek bar just like Hulu video player. For reference please see below attached snap shot of Hulu video player.

         Can you please tell me how can I do this, I am using Flash Media Server content as well as HTTP server content in my video player and using Action Script 3.0

Thanks & regards

Sunil Kumar

    This topic has been closed for replies.
    Correct answer Sunil Kumar Sah

    As I am also building a web player, I came across your post. Your solution sounds great

    and I was hoping to also receive see a copy of you solution.  I understand what you're saying

    in your last post but there is nothing like seeing the final code.

    Thanks in advance Sunil.


    Please find below code for both Option 1 & Option 2.

    Please note -

    1) Use your actual variable instead of dummy.

    2) Position of thumbnails should be move as per mouseMove on seekBar. Get the mouse X posion and set the xpos of your thumbnail which contain either Video object or image display holder.

    package  {

      import flash.display.MovieClip;

      import flash.events.MouseEvent;

      import flash.events.TimerEvent;

      import org.osmf.events.TimeEvent;

      import flash.utils.Timer;

      import flash.net.NetStream;

      public class SeekThumb extends MovieClip {

      private var seekBtn:MovieClip;

      private var getVideoFrameAtSecond:Number = -1;

      private var durationOfVideo:Number = 100// Asume that we have 100 seconds video

      private var timer:Timer;

      private var counter:Number = 0;

      private var delay:Number = 1;  // It can be updated as per smoothness.

      private var netStream:NetStream;

      private var lastSeekPos:Number;

      public function SeekThumb() {

      // constructor code

      this.addChild(createSeekButton());

      timer = new Timer(200);

      timer.addEventListener(TimerEvent.TIMER, updateQos);

      counter = delay;

      }

      private function createSeekButton():MovieClip{

      seekBtn = new SeekButton();

      seekBtn.buttonMode = true;

      seekBtn.addEventListener(MouseEvent.MOUSE_MOVE, seekMouseMove, false, 0, true);

      seekBtn.addEventListener(MouseEvent.ROLL_OVER, seekOver, false, 0, true);

      seekBtn.addEventListener(MouseEvent.ROLL_OUT, seekOut, false, 0, true);

      seekBtn.x = 50;

      seekBtn.y = 100;

      return seekBtn;

      }

      private function seekOver(event:MouseEvent):void{

      timer.start();

      }

      private function seekOut(event:MouseEvent):void{

      timer.stop();

      }

      private function updateQos(event:TimerEvent):void{

      //trace("counter = "+counter)

      if(counter>0){

      counter--;

      }else{

      // Enable below funtion as per your need.

      //updateVideoFrame(getVideoFrameAtSecond);

      //addImageOfVideoFramesAt(getVideoFrameAtSecond);// If you want to show your bitmap image then pass the bitmap image params here or customize your methods here

      trace(getVideoFrameAtSecond);

      }

      }

      private function addImageOfVideoFramesAt(seekTime:Number):void{

      var getBitmapMovie:MovieClip = myStoredThumbArray[seekTime]// Set the image url here from array which you have already stored/ traced from main source of image which you provided.

      previewHolder.addChild(getBitmapMovie);

      }

      private function updateVideoFrame(setId:Number):void {

      try {

      if (netStream!=null && lastSeekPos!=setId) {

      lastSeekPos = setId;

      netStream.play(netStreamURL, setId);

      netStream.pause();

      //netStream.soundTransform = setVoluem to 0

      }

      } catch (error:Error) {

      trace("UpdateVideo Frame Error: "+error);

      }

      }

      private function seekMouseMove(event:MouseEvent):void{

      var currentMc:MovieClip = MovieClip(event.currentTarget);

      getVideoFrameAtSecond = Math.round(currentMc.mouseX*durationOfVideo/seekBtn.width);

      counter = delay;

      }

      }

    }

    If still you have any issue don't hesitate to contact

    1 reply

    August 4, 2010

    Hi Sunil,

    Please see if these are helpful,

    http://www.thetechlabs.com/tutorials/audionvideo/how-to-build-a-as3-videoplayer/

    http://www.thetechlabs.com/tutorials/xml/create-a-as3-slideshow-with-xml/

    Regards

    Mamata

    Sunil Kumar Sah
    Inspiring
    August 5, 2010

    Dear Mamta,

                        Thanks for your response but this not what I am looking for. I have developed Flash video player using OOP in AS3 and I also know how to develop flash xml gallery in AS3.

                   My query is how to show  preview image of particular video when I do roll over on seek bar. Please follow the following example. Please see it in attached snap shot image of Hulu video player.

    e.x

            Suppose I have a video player with 400 x 300 (Width x Height) and my seek bar width is equal to my player width. Now when I do roll over on seek bar, i can get current seek time of video on particular point where I have put my mouse over, I just want to load and image of that seek time video frames.

    I hope you got my point. Please suggest me any tutorial of help file so that I can do it.

    Thanks & regards

    Sunil Kumar

    Adobe Employee
    August 5, 2010

    Hi Sunil,

    When you roll over basically you can use another netstream to play same file with start position equal to seek time and playtime equal to 1 i.e. ns.play("filename",seekTime_rollover,1,true);

    Same time you can use small video component which you can make visible or invisible when you roll over seek bar.

    I know this might not be best way of doing it - as it might cause of lot extra play events but as of now that's what which comes to my mind on the fly.

    Will try to think for better solution if i get time.