Results 1 to 4 of 4

Thread: Create FLV video loop

  1. #1
    Join Date
    Feb 2009
    Posts
    66

    Create FLV video loop

    hello friends,

    I want to make FLV video loop. how can I do the same ? can anybody help me providing information regarding this ? please give your ideas and suggestions....thanks

  2. #2
    Join Date
    May 2008
    Posts
    3,316

    Re: Create FLV video loop

    Looping an FLV file first requires to detect the end of the FLV. To detect the end of FLV playback, you can use the NetStream::onStatus event handler, by checking for NetStream.Play.Stop event. However, it is noticed that this event is not always sent (may be due to undocumented bugs in the flv implementation on the NetStream class). For that reason, you to create workaround for FLV files that does not send the NetStream.Play.Stop event.

    use the NetConnection object to open an FLV file. The process of looping the movie is similar when using FlashCom server. The process described here is the standard way of playing FLV files.

    myNetconnection = new NetConnection();
    myNetconnection.connect(null);
    myStream = new NetStream(myNetconnection);
    myStream.setBufferTime(3);
    my_video.attachVideo(myStream);
    myStream.play(videoUrl);

    Download the zip file for this tutorial

  3. #3
    Join Date
    May 2008
    Posts
    4,831

    Re: Create FLV video loop

    There are 2 methods to detect the end of the FLV playback and then loop
    1. Using the onStatus event handler
    2. Using metadata


    1. onStatus event handler
    onStatus is a method of the NetStream class. In this method, you can override for checking the end of FLV playback.

    myStream.onStatus = function(info)
    {
    trace("info="+info.code);
    if (info.code == "NetStream.Play.Stop")
    {
    // Set flag, we will need to wait for
    // "NetStream.Buffer.Empty" before
    // actually restarting the movie.
    stopped=true;
    }
    if (info.code == "NetStream.Buffer.Empty")
    {
    // At this point, the movie has stopped, and
    // the buffer is empty.
    // We're ready to restart the movie.
    if (stopped)
    {
    myStream.seek(0)
    myStream.play(videoUrl);
    stopped=false;
    }
    }
    }

    Check whether the event sent is NetStream.Play.Stop. When you receive NetStream.Play.Stop, it means that the movie has stopped playing. Note - since Flv playback has a tendency to freeze when you start a movie without waiting for the playback buffer to be empty, we should wait for the NetStream.Buffer.Empty event as well. When both conditions are met, then you ready to replay the movie.

  4. #4
    Join Date
    May 2008
    Posts
    4,831

    Re: Create FLV video loop

    2. Metadata
    Macromedia has added a metadata section into a FLV file. The metadata contains the duration of the FLV, among other things. You can use the duration information to check whether a movie has reached the end of playback.
    Note - All FLV files may not have metadata (you will need to use software that supports metadata to create the FLV).

    You can retrieve the duration information by using the following code:

    myStream.onMetaData = function(obj)
    {
    myStreamDuration=obj.duration;
    trace("metadata duration="+myStreamDuration);
    }

    If the FLV has metadata, the above code will show the duration of the FLV.
    If the FLV does not have metadata information, it is recommended that you re-encode the FLV with programs that supports metadata, such as Flix Pro or the Flix Exporter.

    Checking for the end of the playback using metadata is quite straightforward - just add a loop to check if the current playback time is equal to or greater than the duration. You can view the implementation of this method by examining the code on the frame 2 and 3 of the main timeline of the sample movie.

    var maxIdle=5;
    if (myStreamDuration>0)
    {
    myDelta=myStream.time-myStreamDuration;
    if (myDelta<0)
    myDelta=-myDelta;

    if (myDelta<2)
    {
    if (myDelta==lastDelta)
    {
    noStreamMovement++;
    }
    else
    {
    lastDelta=myDelta;
    noStreamMovement=0;
    }
    if (noStreamMovement>maxIdle)
    {
    trace("loop");
    myStream.seek(0);
    myStream.play(videoUrl);
    lastDelta=0;
    noStreamMovement=0;}
    }
    }
    }

Similar Threads

  1. Watercooling: Single loop or Dual Loop
    By Akolekar in forum Hardware Peripherals
    Replies: 3
    Last Post: 21-10-2011, 10:52 PM
  2. Getting iPad to loop or repeat a video
    By Gaganadipika in forum Portable Devices
    Replies: 6
    Last Post: 18-08-2011, 04:46 AM
  3. Reboot Loop in Windows 7 Reboot loop and Safe mode doesn't work
    By mADiRAkSHii in forum Operating Systems
    Replies: 4
    Last Post: 25-01-2011, 07:23 PM
  4. How to create loop query sql ?
    By Beltran in forum Software Development
    Replies: 2
    Last Post: 13-07-2009, 01:42 PM
  5. How to create a script in a DOS batch file to do a loop?
    By Jon Osborn in forum Windows Server Help
    Replies: 2
    Last Post: 27-05-2008, 06:41 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,940,330.86079 seconds with 17 queries