FV Flowplayer Video Player Shortcodes

Below, you’ll find a detailed guide on how to add the FV Flowplayer Video Player Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the FV Flowplayer Video Player Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the FV Flowplayer Video Player Plugin and the shortcodes it provides:

Plugin Icon
FV Flowplayer Video Player

"FV Flowplayer Video Player is a WordPress plugin that provides an intuitive interface for managing and playing videos. Perfect for all video-related content on your site."

★★★★✩ (87) Active Installs: 30000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [flowplayer]
  • [fv_time]
  • [fvplayer_watched]

FV Flowplayer Video Player [flowplayer] Shortcode

The fv-wordpress-flowplayer plugin shortcode is a functional piece of code that handles the flowplayer content. It is used to create and manage video players on WordPress sites. This shortcode parses various parameters such as ‘src’, ‘splash’, ‘popup’, ‘ad’, etc., to configure the video player. It also handles different conditions like ‘parse_commas’, ‘mobile’, ‘id’, and ‘post’. The shortcode ensures the correct video content is displayed with the desired settings.

Shortcode: [flowplayer]

Parameters

Here is a list of all possible flowplayer shortcode parameters and attributes:

  • id – Identifier for the specific player instance
  • src – Source URL of the video file
  • src1 – Source URL of the first video file in a playlist
  • src2 – Source URL of the second video file in a playlist
  • splash – URL of the splash image displayed before video play
  • ad – URL of the advertisement video to be displayed
  • ad_width – Width of the advertisement video
  • ad_height – Height of the advertisement video
  • ad_skip – Time in seconds when the ad can be skipped
  • align – Alignment of the player on the page
  • autoplay – Determines if the video plays automatically
  • caption – Text displayed as the video caption
  • controlbar – Display controls for the video
  • embed – Allows the video to be embedded elsewhere
  • height – Height of the video player
  • mobile – Source URL of the video file for mobile devices
  • popup – Content to be displayed in a popup after video ends
  • post – The ID of the post containing the video
  • rtmp – RTMP streaming server URL
  • rtmp_path – Path to the video file on the RTMP server
  • skin – Skin used for the video player
  • width – Width of the video player

Examples and Usage

Basic example – Show a simple video with a splash image

[flowplayer src="sample.mp4" splash="splash.jpg"]

Advanced examples

Display a video with a splash image, autoplay enabled, and a custom width and height.

[flowplayer src="sample.mp4" splash="splash.jpg" autoplay="true" width="640" height="360"]

Use the shortcode to display a video with a splash image, an ad, and a popup.

[flowplayer src="sample.mp4" splash="splash.jpg" ad="ad.mp4" popup="popup.jpg"]

Show a video with a splash image, a logo, and a custom skin.

[flowplayer src="sample.mp4" splash="splash.jpg" logo="logo.png" skin="custom"]

Display a video with a splash image and a caption.

[flowplayer src="sample.mp4" splash="splash.jpg" caption="This is a sample video"]

PHP Function Code

In case you have difficulties debugging what causing issues with [flowplayer] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('flowplayer','flowplayer_content_handle');

Shortcode PHP function:

function flowplayer_content_handle( $atts, $content = null, $tag = false ) {
	global $fv_fp;
  if( !$fv_fp ) return false;

  if( $fv_fp->_get_option('parse_commas') && strcmp($tag,'flowplayer') == 0 ) {
    
    if( !isset( $atts['src'] ) ) {     
      foreach( $atts AS $key => $att ) {
        if( stripos( $att, 'src=' ) !== FALSE ) {
          if( stripos( $att, ',' ) === FALSE ) {  //  if the broken attribute is not using ','
            $atts['src'] = preg_replace( '/^\s*?src=[\'"](.*)[\'"].*?$/', '$1', $att );
          } else {
            $atts['src'] = preg_replace( '/^\s*?src=[\'"](.*)[\'"],\s*?$/', '$1', $att );
          }
          $i = $key+1;
          unset( $atts[$key] ); // = ''; //  let's remove it, so it won't confuse the rest of workaaround
        }
      }
    }
  
    if( !isset( $atts['splash'] ) ) {
      foreach( $atts AS $key => $att ) {
        if( stripos( $att, 'splash=' ) !== FALSE ) {
          $atts['splash'] = preg_replace( '/^\s*?splash=[\'"](.*)[\'"],\s*?$/', '$1', $att );
          unset( $atts[$key] ); // = ''; //  let's remove it, so it won't confuse the rest of workaround
        }
      }
    }
    
    //  the popup should really be a content of the shortcode, not an attribute
    //  this part will fix the popup if there is any single quote in it.
    if( !isset( $atts['popup'] ) ) {
      $popup = array();
      $is_popup = false;
      foreach( $atts AS $key => $att ) {
        if( !is_numeric( $key ) ) continue;
        if( ( stripos( $att, 'popup=' ) !== FALSE || $is_popup ) && stripos( $att, 'src=' ) === FALSE && stripos( $att, 'splash=' ) === FALSE && stripos( $att, 'ad=' ) === FALSE) {
          $popup[] = $att;
          $is_popup = true;
          unset( $atts[$key] ); // = ''; //  let's remove it, so it won't confuse the rest of workaround
        }
      }
      $popup = implode( ' ', $popup );
      $atts['popup'] = preg_replace( '/^\s*?popup=[\'"](.*)[\'"]\s*?$/mi', '$1', $popup );
    }
    
    //	same for ad code
    if( !isset( $atts['ad'] ) ) {
      $ad = array();
      $is_ad = false;
      foreach( $atts AS $key => $att ) {
        if( !is_numeric( $key ) ) continue;
        if( ( stripos( $att, 'ad=' ) !== FALSE || $is_ad ) && stripos( $att, 'src=' ) === FALSE && stripos( $att, 'splash=' ) === FALSE && stripos( $att, 'popup=' ) === FALSE) {
          $ad[] = $att;
          $is_ad = true;
          unset( $atts[$key] ); // = ''; //  let's remove it, so it won't confuse the rest of workaround
        }
      }
      $ad = implode( ' ', $ad );
      $atts['ad'] = preg_replace( '/^\s*?ad=[\'"](.*)[\'"]\s*?$/mi', '$1', $ad );
    }    
    
  }
  
  $atts = wp_parse_args( $atts, array(
    'ad' => '',
    'ad_width' => '',
    'ad_height' => '',
    'ad_skip' => '',    
    'admin_warning' => '',
    'align' => '',
    'autoplay' => '',
    'caption' => '',
    'caption_html' => '',
    'controlbar' => '',
    'embed' => '',    
    'end_popup_preview' => '',
    'engine' => '',    
    'height' => '',
    'mobile' => '',
    'linking' => '',
    'liststyle' => '',    
    'live' => '',
    'logo' => '',
    'loop' => '',
    'play_button' => '',
    'playlist' => '',    
    'playlist_advance' => '',
    'playlist_hide' => '',
    'popup' => '',    
    'post' => '',
    'redirect' => '',    
    'rtmp' => '',
    'rtmp_path' => '',    
    'share' => '',    
    'skin' => '',
    'speed' => '',
    'splash' => '',
    'splash_text' => '',
    'splashend' => '',    
    'src' => '',
    'src1' => '',
    'src2' => '',
    'sticky' => '',    
    'subtitles' => '',    
    'width' => '',
  ) );

  if( $fv_fp->_get_option('parse_commas') && strcmp($tag,'flowplayer') == 0 ) {
		foreach( $atts AS $k => $v ) {
			if( in_array($k, array('admin_warning','caption','caption_html','playlist','popup','share') ) ) {
				$arguments[$k] = $v;
			} else {
				$arguments[$k] = preg_replace('/\,/', '', $v);
			}
		}
		
	} else {
		$arguments = $atts;
	}
  
  if( ( !isset($arguments['src']) || strlen(trim($arguments['src'])) == 0 ) && isset($arguments['mobile']) && strlen(trim($arguments['mobile'])) ) {
    $arguments['src'] = $arguments['mobile'];
    unset($arguments['mobile']);
  }
  
  $arguments = apply_filters( 'fv_flowplayer_shortcode', $arguments, $fv_fp, $atts );
	
  if( $arguments['post'] == 'this' ) {
    $arguments['post'] = get_the_ID();
  }

  // accepts:
  // 1) [fvplayer id="198"] - a DB-based shortcode in the form
  // 2) [fvplayer src="198" playlist="198;199;200"] - a front-end user's playlist shortcode that is programatically passed to this method
  if( (!empty($arguments['id']) && intval($arguments['id']) > 0) || (!empty($arguments['src']) && is_numeric($arguments['src']) && intval($arguments['src']) > 0) ) {
    $new_player = $fv_fp->build_min_player(false, $arguments);
    if (!empty($new_player['script'])) {
      $GLOBALS['fv_fp_scripts'] = $new_player['script'];
    }

    if ( $new_player ) {
      return $new_player['html'];
    } else {
      return '';
    }
        
  } else  if( intval($arguments['post']) > 0 ) {
    $objVideoQuery = new WP_Query( array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'post_parent' => intval($post), 'post_mime_type' => 'video' ) );
    if( $objVideoQuery->have_posts() ) {
      $sHTML = '';
      while( $objVideoQuery->have_posts() ) {
        $objVideoQuery->the_post();
        $aArgs = $arguments;
        $aArgs['src'] = wp_get_attachment_url(get_the_ID());
        if( $aSplash = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'large' ) ) {
          $aArgs['splash'] = $aSplash[0];
        }
        if( strlen($aArgs['lightbox']) ) {
          $aArgs['lightbox'] .= ';'.html_entity_decode(get_the_title());
        }
        if( strlen($aArgs['caption']) ) {
          $aArgs['caption'] = apply_filters( 'fv_player_caption', $aArgs['caption'], false );
        }

        $new_player = $fv_fp->build_min_player( $aArgs['src'],$aArgs );
        if ( $new_player ) {
          $sHTML .= $new_player['html'];
        }
      }

      return $sHTML;
    }
        
  } else if( $arguments['src'] != '' || ( ( ( strlen($fv_fp->conf['rtmp']) && $fv_fp->conf['rtmp'] != 'false' ) || strlen($arguments['rtmp'])) && strlen($arguments['rtmp_path']) ) ) {
		// build new player
    $new_player = $fv_fp->build_min_player($arguments['src'],$arguments);
    if (!empty($new_player['script'])) {
      $GLOBALS['fv_fp_scripts'] = $new_player['script'];
    }

    if ( $new_player ) {
      return $new_player['html'];
    } else {
      return '';
    }
    
	}
  return false;
}

Code file location:

fv-wordpress-flowplayer/fv-wordpress-flowplayer/controller/shortcodes.php

FV Flowplayer Video Player [fv_time] Shortcode

The fv-wordpress-flowplayer plugin shortcode ‘fv_time’ retrieves the duration of a specific video or the current video in a post. It uses the ‘fv_player_time’ function to access the video duration. If a video ID is provided, it fetches the duration directly. If not, it searches for the video in the current post.

Shortcode: [fv_time]

Parameters

Here is a list of all possible fv_time shortcode parameters and attributes:

  • id – Specifies the unique identifier for the specific player

Examples and Usage

Basic example – Display the duration of a specific video by referencing its ID.

[fv_time id=1 /]

Advanced examples

Display the duration of a specific video by referencing its ID, and if not found, it will try to fetch the duration of the video from the current post.

[fv_time id=1 src="video.mp4" /]

Display the duration of the video from the current post if the ID is not specified.

[fv_time /]

PHP Function Code

In case you have difficulties debugging what causing issues with [fv_time] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('fv_time','fv_player_time');

Shortcode PHP function:

function fv_player_time( $args = array() ) {
  global $post, $fv_fp;
	
  if( !empty($args['id']) ) {
    $player = new FV_Player_Db_Player($args['id']);
    if( $player->getIsValid() ) {
      foreach( $player->getVideos() AS $video ) {
        if( $duration = $video->getDuration() ) {
          return flowplayer::format_hms( $duration );
        }
      }
    }
  }
  
  if( $post->ID > 0 && isset($fv_fp->aCurArgs['src']) ) {
    return flowplayer::get_duration( $post->ID, $fv_fp->aCurArgs['src'] );
  } else {
    return flowplayer::get_duration_post();
  }
}

Code file location:

fv-wordpress-flowplayer/fv-wordpress-flowplayer/controller/shortcodes.php

FV Flowplayer Video Player [fvplayer_watched] Shortcode

The FV Player Watched Videos shortcode provides a list of videos a user has watched. It fetches data based on user ID and post type, and can include all or a specified number of videos. It displays the video caption, link to the post where the video is embedded, and the percentage of the video watched. If no videos have been watched, it returns “No watched videos”.

Shortcode: [fvplayer_watched]

Parameters

Here is a list of all possible fvplayer_watched shortcode parameters and attributes:

  • count – Sets the maximum number of watched videos to display.
  • include – Determines which watched videos to include in the list.
  • post_type – Specifies the type of posts to consider for watched videos.
  • user_id – Identifies the user’s watched videos to display.

Examples and Usage

Basic example – Display the last 20 videos watched by the current user.

[fvplayer_watched]

Advanced examples

Display the last 10 videos watched by the current user.

[fvplayer_watched count=10]

Display the last 20 videos watched by a specific user. Replace ‘user_id’ with the ID of the user.

[fvplayer_watched user_id=1]

Display the last 20 videos of a specific post type watched by the current user. Replace ‘post_type’ with the type of the post.

[fvplayer_watched post_type='post']

Display the last 20 videos watched by the current user and include all details.

[fvplayer_watched include='all']

Display the last 20 videos watched by the current user and include debug information.

[fvplayer_watched fvplayer_watched_debug='true']

PHP Function Code

In case you have difficulties debugging what causing issues with [fvplayer_watched] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'fvplayer_watched', 'fvplayer_watched' );

Shortcode PHP function:

function fvplayer_watched( $args = array() ) {
  $args = wp_parse_args( $args, array(
    'count' => 20,
    'include' => 'all',
    'post_type' => 'any',
    'user_id' => get_current_user_id()
  ) );

  $args['full_details'] = true;

  $video_ids = fv_player_get_user_watched_video_ids( $args );
  if( count($video_ids) == 0 ) {
    return "<p>No watched videos.</p>";
  }

  $actual_video_ids = array_filter( array_keys($video_ids), 'is_numeric' );

  global $wpdb;
  $videos2durations = $wpdb->get_results( $wpdb->prepare( "
    SELECT v.id AS video_id, vm.meta_value AS duration FROM
      {$wpdb->prefix}fv_player_videos AS v
    JOIN {$wpdb->prefix}fv_player_videometa AS vm
      ON v.id = vm.id_video
    WHERE
      v.id IN (".implode( ',', $actual_video_ids ).") AND
      vm.meta_key = 'duration'" ) );

  $html = "<ul>\n";
  foreach( $video_ids AS $video_id => $data ) {

    global $FV_Player_Db;
    $objVideo = new FV_Player_Db_Video( $video_id, array(), $FV_Player_Db );
    if( $objVideo->getCaption() ) {
      $line = $objVideo->getCaption();
    } else {
      $line = $objVideo->getCaptionFromSrc();
    }

    if( isset($_GET['fvplayer_watched_debug']) ) {
      $line .= ' (player #'.$data['player_id'].', video #'.$video_id.')';
    }

    $post = get_post( $data['post_id'] );
    if( $post ) {
      $line .= " in <a href='".get_permalink($post)."'>".$post->post_title."</a>";
    }
    if( isset($_GET['fvplayer_watched_debug']) ) {
      $line .= ' (post #'.$data['post_id'].')';
    }

    if( !empty($data['time']) ) {

      foreach( $videos2durations AS $details ) {
        if( $details->video_id == $video_id ) {
          // In some strange cases the duration might not be set right
		      if( $data['time'] <= intval($details->duration) ) {
            if( isset($_GET['fvplayer_watched_debug']) ) {
              $data['message'] .= ' out of '.flowplayer::format_hms($details->duration).' ('.$data['time'].' out of '.$details->duration.')';
            }
            $line .= ' (<abbr title="'.esc_attr($data['message']).'">'.round( 100 * $data['time'] / intval($details->duration) ).'%</abbr>)';
		      }
        }
      }
    }

    $html .= "<li>".$line."</li>\n";
  }
  $html .= "</ul>\n";

  return $html;
}

Code file location:

fv-wordpress-flowplayer/fv-wordpress-flowplayer/controller/shortcodes.php

Conclusion

Now that you’ve learned how to embed the FV Flowplayer Video Player Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *