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.
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
Here are the tables where FV Player stores playlists and videos:
wp_fv_player_players
wp_fv_player_playermeta
wp_fv_player_videos
wp_fv_player_videometa
Note: The wp_ part of these datababase table names depends on your WordPress database prefix, but you should be able to spot them easily when you look at your database management tool.
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"]');
Editing video properties, in this example the src:
$video = new FV_Player_Db_Video( $video_id );
if ( $video && $video->getIsValid() ) {
$video_url = $video->getSrc();
// Do the required change to the src here
$video_url = str_replace( '/playlist.m3u8', '/playlist_dvr.m3u8', $video_url );
$video->set( 'src', $video_url );
$video->save();
}
Editing src property of all videos belonging to a player, while obtaining the player ID from a post meta field:
$shortcode = get_post_meta( $post_id, 'fv_player', true );
if ( $shortcode ) {
$atts = shortcode_parse_atts( trim( $shortcode, ']' ) );
if ( ! empty( $atts['id'] ) ) {
$player = new FV_Player_Db_Player( $atts['id'] );
if ( $player->getIsValid() ) {
foreach ( $player->getVideos() AS $video ) {
$video_url = $video->getSrc();
// Do the required change to the src here
$video_url = str_replace( '/playlist.m3u8', '/playlist_dvr.m3u8', $video_url );
$video->set( 'src', $video_url );
$video->save();
}
}
}
}
This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
Necessary Cookies
Strictly Necessary Cookie allow you to log in and download your software or post to forums.
We use the WordPress login cookie and the session cookie.
If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.
Support Cookies
Foliovision.com uses self-hosted Rocket.chat and self-hosted Freescout support desk to provide support for FV Player users. These cookies allow our visitors to chat with us and/or submit support tickets.
We are delighted to recommend self-hosted Rocket.chat and especially Freescout to other privacy-conscious independent publishers who would prefer to self-host support.
Please enable Strictly Necessary Cookies first so that we can save your preferences!
3rd Party Cookies
This website uses Google Analytics and Statcounter to collect anonymous information such as the number of visitors to the site, and the most popular pages.
Keeping this cookie enabled helps us to improve our website.
We reluctantly use Google Analytics as it helps us to test FV Player against popular Google Analytics features. Feel free to turn off these cookies if they make you feel uncomfortable.
Statcounter is an independent Irish stats service which we have been using since the beginning of recorded time, sixteen years ago.
Please enable Strictly Necessary Cookies first so that we can save your preferences!