Overview
FV Player started off as a simple plugin which used to let you insert a single video with a splash screen. It operated with simple shortcodes such as:
[fvplayer src="/videos/intro.mp4" splash="/videos/splash.jpg"]
Then more and more attributes were added:
[fvplayer src="/videos/intro.mp4" src1="/videos/intro.webm" splash="/videos/splash.jpg" splashend="true" autoplay="true" width="640" height="360" caption="Intro" subtitles="/videos/intro.vtt"
And even playlists:
[fvplayer src="/videos/intro.mp4" src1="/videos/intro.webm" splash="/videos/splash.jpg" splashend="true" autoplay="true" width="640" height="360" playlist="/videos/part-1.mp4,/videos/part-1.webm,/videos/part-1.jpg;/videos/part-2.mp4,/videos/part-2.webm,/videos/part-2.jpg;/videos/part-3.mp4,/videos/part-3.webm,/videos/part-3.jpg" caption="Intro;Part 1;Part 2;Part 3" subtitles="/videos/intro.vtt;/videos/part-1.vtt;/videos/part-2.vtt;/videos/part-3.vtt"]
It quickly outgrew the whole concept of shortcodes and it was clear this couldn’t have gone on forever. These shortcodes became too clunky and fragile.
FV Player version 7.3.0.727 introduced the FV Player database. For most people this change was almost invisible – they use the same FV Player editor to create their playlists and FV Player stores that information in 4 different database tables. But what they see in the post content is a very simple shortcode like this:
The new shortcode is a simple database reference. Move your typing cursor into it and hit the FV Player button to edit.
The power users will like the new FV Player screen which lets you manage all the playlists in a single place – the new FV Player section of your WordPress Admin Dashboard:
FV Player WP-Admin screen
This screen appears once you have at least one player stored in database.
The new import/export format:
{"ab":"","ad":"","ad_height":"","ad_width":"","ad_skip":"","align":"","autoplay":"on","controlbar":"","copy_text":"","embed":"","end_actions":"","end_action_value":"","height":"360","hflip":"","lightbox":"","lightbox_caption":"","lightbox_height":"","lightbox_width":"","player_name":"test","player_slug":"","playlist":"","playlist_advance":"","qsel":"","share":"","share_title":"","share_url":"","speed":"","sticky":"","video_ads":"","video_ads_post":"","width":"640","videos":[{"caption":"Intro","end":"","mobile":"","rtmp":"","rtmp_path":"","splash":"/videos/splash.jpg","splash_text":"","src":"/videos/intro.mp4","src1":"/videos/intro.webm","src2":"","start":"","meta":[{"meta_key":"subtitles","meta_value":"/videos/intro.vtt"}]},{"caption":"Part 1","end":"","mobile":"","rtmp":"","rtmp_path":"","splash":"/videos/part-1.jpg","splash_text":"","src":"/videos/part-1.mp4","src1":"/videos/part-1.webm","src2":"","start":"","meta":[{"meta_key":"subtitles","meta_value":"/videos/part-1.vtt"}]},{"caption":"Part 2","end":"","mobile":"","rtmp":"","rtmp_path":"","splash":"/videos/part-2.jpg","splash_text":"","src":"/videos/part-2.mp4","src1":"/videos/part-2.webm","src2":"","start":"","meta":[{"meta_key":"subtitles","meta_value":"/videos/part-2.vtt"}]},{"caption":"Part 3","end":"","mobile":"","rtmp":"","rtmp_path":"","splash":"/videos/part-3.jpg","splash_text":"","src":"/videos/part-3.mp4","src1":"/videos/part-3.webm","src2":"","start":"","meta":[{"meta_key":"subtitles","meta_value":"/videos/part-3.vtt"}]}]}
For programmers it also means there is a new way of interacting with FV Player to set any of the properties. It’s a lot more convenient than having to create bulky shortcodes.
Structure
The database model uses coma separated list of video IDs for player rows, hence the missing link.
Converting old shortcodes to the Database
If you want to convert an old shortcode to the new Database id shortcode, follow these few simple steps:
1. Click on the old shortcode. Your old shortcode should look like this:
2. Click on the FV Player embedd button above your WordPress post field.
3. Your FV Player shortcode will open with all the video preferences automatically filled in.
4. Check all the video preferences and click Update and your old shortcode should convert to the new Database id shortcode as you can see below.
PHP API
Obtaining player data:
$player = new FV_Player_Db_Player( $player_id ); if( $player && $player->getIsValid() ) { $videos = $player->getVideos(); foreach( $videos AS $video ) { // access basic properties var_dump( $video->getSrc() ); // check some video meta values var_dump( $video->getMetaValue('duration') ); // obtain single value for video meta only var_dump( $video->getMetaValue('duration'), true ); } }
Inserting a new player instance:
global $FV_Player_Db; $player_id = $FV_Player_Db->import_player_data(false, false, array( 'player_name' => 'FV Player DB PHP calls demo', 'date_created' => '2020-05-01 08:15:00', // date is optional 'videos' => array( array( // video source is the only required argument 'src' => 'https://video-cdn.site.com/fv-player-db/index.m3u8', 'splash' => 'https://video-cdn.site.com/fv-player-db/splash.jpg', 'caption' => 'FV Player DB Introduction', // optionally you can also provide video meta: 'meta' => array( array( 'meta_key' => 'subtitles_en', 'meta_value' => 'https://video-cdn.site.com/fv-player-db/subtitles.vtt', ), array( 'meta_key' => 'synopsis', // shows up in the Season playlist style 'meta_value' => 'This is just for illustration' ) ) ) // add more videos into the playlist here ) ));
Then you can either insert a shortcode like this into a post:
[fvplayer id="XYZ"]
Or you can call it via PHP:
echo do_shortcode('[fvplayer id="XYZ"]');