Using the playlist
Overview
The playlist feature makes it possible to specify a list of video clips that are played automatically one after the other.
There are 2 ways to use the playlist:
Statically: a static set of clips is specified, then played as if it were a single clip (the trackbar moves across the whole set of clips).
Dynamically: clips can be added/removed dynamically while the playlist is playing, by invoking Playlist (pl_Add...). In this case, the trackbar is active for the current clip being played.
- All the playlist actions are performed with the Playlist function, detailed below.
- The playlist content can be retrieved with the GetPlaylist function, which returns a list of strings separated by CR/LF.
- The current index in the playlist is returned by the PlaylistIndex property (if opened dynamically).
- When the end of the playlist is reached, the OnPlayerEndOfPlaylist event occurs.
- To check whether the playlist is currently playing, test IsPlaylistActive.
The Playlist function
The Playlist function accepts 2 parameters:
- a first parameter that specifies the action,
- a 2nd parameter that specifies the video clip (used only for pl_Add, pl_Remove and pl_SpecifyPositions).
The first parameter can take one of the following values:
- pl_Add: adds the video clip (specified as 2nd parameter) to the playlist
- pl_Remove: removes the video clip (specified as 2nd parameter) from the playlist
- pl_Clear: clears the playlist
- pl_Loop: enables the loop mode (the playlist restarts from the beginning when the end is reached)
- pl_NoLoop: disables the loop mode
- pl_Play: starts playing the playlist
- pl_Stop: stops playing the playlist after the end of the current clip
- pl_Next: starts playing the next clip (immediately)
- pl_Previous: starts playing the previous clip (immediately)
- pl_SortAlpha: sorts the playlist in alphabetical order
- pl_SortRevAlpha: sorts the playlist in reverse alphabetical order
- pl_Random: enables the "random" mode: the clips are played in a random order
- pl_Sequential: disables the "random" mode: the clips are played sequentially
- pl_SpecifyPositions: specifies a start position and/or a stop position
- pl_Transition
Note
While the static playlist is playing, it can no longer be controlled with the playlist settings: it behaves like a single video clip.
Building the playlist
Invoke Playlist (pl_Add, "... path of the video clip...") as many times as required. Pass an empty string for the "VideoClip" parameter when it is not required (it is required only for pl_Add and pl_Remove). E.g.:
VideoGrabber.Playlist (pl_Clear, '');
VideoGrabber.Playlist (pl_Add, 'vg000004.avi');
VideoGrabber.Playlist (pl_Add, 'vg000002.avi');
VideoGrabber.Playlist (pl_Add, 'StaticImage1.BMP');
VideoGrabber.Playlist (pl_Add, 'vg000003.avi');
VideoGrabber.Playlist (pl_Add, 'vg000005.avi');
VideoGrabber.Playlist (pl_Add, 'vg000001.avi');
VideoGrabber.Playlist (pl_Add, 'StaticImage2.JPG');
Starting the dynamic playlist
Be sure to set all the required options (like pl_Loop, pl_SortAlpha or pl_Random), then invoke pl_Play. E.g.:
VideoGrabber.Playlist (pl_Clear, '');
VideoGrabber.Playlist (pl_Add, 'vg000004.avi');
VideoGrabber.Playlist (pl_Add, 'vg000002.avi');
VideoGrabber.PlayerDuration := 50000000; // specifies 5 seconds of display time for StaticImage1.BMP
VideoGrabber.Playlist (pl_Add, 'StaticImage1.BMP');
VideoGrabber.Playlist (pl_Add, 'vg000003.avi');
VideoGrabber.Playlist (pl_Add, 'vg000005.avi');
VideoGrabber.Playlist (pl_Add, 'vg000001.avi');
VideoGrabber.PlayerDuration := 80000000; // specifies 8 seconds of display time for StaticImage2.JPG
VideoGrabber.Playlist (pl_Add, 'StaticImage2.JPG');
VideoGrabber.PlaylistIndex := 0;
VideoGrabber.Playlist (pl_SortAlpha, '');
VideoGrabber.Playlist (pl_Loop, '');
VideoGrabber.Playlist (pl_Random, '');
VideoGrabber.Playlist (pl_Play, '');
Starting the static playlist
VideoGrabber.Playlist (pl_Clear, "");
VideoGrabber.Playlist (pl_Add, "vg000004.avi");
VideoGrabber.Playlist (pl_Add, "vg000002.avi");
VideoGrabber.Playlist (pl_Add, "vg000003.avi");
VideoGrabber.Playlist (pl_Add, "vg000005.avi");
VideoGrabber.Playlist (pl_Add, "vg000001.avi");
VideoGrabber.PlayerFileName = "PLAYLIST";
VideoGrabber.OpenPlayer();
Specifying a custom video size and/or frame rate for the static playlist
By default, the static playlist plays all the clips at the same video size (640x480) and at the same frame rate (29.97 fps).
- To customize the frame rate, set a FrameRate value > 0.
- To customize the video size, invoke UseNearestVideoSize (width, height, false) before invoking OpenPlayer.
E.g.:
...
VideoGrabber.Playlist (pl_Add, "vg0000006.avi");
VideoGrabber.PlayerFileName = "PLAYLIST";
VideoGrabber.FrameRate = 25.0;
VideoGrabber.UseNearestVideoSize (720, 480, false);
VideoGrabber.OpenPlayer();
To reset the video size later, invoke:
VideoGrabber.UseNearestVideoSize (0, 0, false);
To reset the frame rate, set:
VideoGrabber.FrameRate = 0;
Pausing the playlist
Invoke PausePlayer.
Stopping the playlist
To stop the playlist at the end of the current clip, invoke Playlist (pl_Stop, ''); to close the playlist immediately, invoke ClosePlayer.
Specifying start/stop positions for each clip
Invoke VideoGrabber.Playlist (pl_SpecifyPositions,...) and, immediately after, OpenPlayerAtTimePositions or OpenPlayerAtFramePositions (this does not open the clips but only registers the positions):
VideoGrabber.Playlist (pl_Add, 'myvideoclip1.wmv');
VideoGrabber.Playlist (pl_SpecifyPositions, 'myvideoclip1.wmv');
VideoGrabber.OpenPlayerAtTimePositions (50000000, 120000000, true, true);
VideoGrabber.Playlist (pl_Add, 'myvideoclip2.wmv');
VideoGrabber.Playlist (pl_SpecifyPositions, 'myvideoclip2.wmv');
VideoGrabber.OpenPlayerAtTimePositions (30000000, 130000000, true, true);
VideoGrabber.PlayerFileName:= 'PLAYLIST';
VideoGrabber.OpenPlayer();
In this example, the first clip plays 7 seconds (from 5 seconds to 12 seconds), then the second clip plays 10 seconds (from 3 seconds to 13 seconds). To let a clip play until the end, specify -1 as the stop position.
Using static images or animated GIFs in the playlist
Static images (like BMP and JPG files) can be played alternately with video clips in the dynamic playlists.
To specify the display time of static images, set PlayerDuration to the desired value before the Playlist (pl_Add...) statement (the display time is expressed in 100 ns units, e.g. 7 seconds = 70000000).
E.g.:
VideoGrabber.PlayerDuration = 30000000; // will set 3 seconds for StaticImage1.BMP
VideoGrabber.Playlist (pl_Add, "StaticImage1.BMP");
VideoGrabber.PlayerDuration = 40000000; // will set 4 seconds for StaticImage2.JPG
VideoGrabber.Playlist (pl_Add, "StaticImage2.JPG");
...
VideoGrabber.Playlist (pl_Play, "");