FV Flowplayer Video Player - Version 7.5.13.727

Version Description

  • 2021/12/20 =

  • New feature - drag&drop video upload and encoding with the Bunny Stream service!

  • New feature - Editor now detects the HLS stream type to show Live stream and Audio stream checkboxes only when needed

  • Compatibility - Editor - jQuery 3.6 fixes

  • Bugfix - Editor - prevent autosave attempt right after opening the editor

Download this release

Release Info

Developer FolioVision
Plugin Icon 128x128 FV Flowplayer Video Player
Version 7.5.13.727
Comparing to
See all releases

Code changes from version 7.5.12.727 to 7.5.13.727

Files changed (36) hide show
  1. controller/editor.php +1 -1
  2. css/s3-browser.css +1 -1
  3. flowplayer.php +13 -2
  4. flowplayer/fv-player.min.js +1 -1
  5. flowplayer/modules/pending-encoding.module.js +1 -1
  6. js/bunny_stream-admin.js +265 -0
  7. js/bunny_stream-browser.js +159 -0
  8. js/bunny_stream-shortcode-editor.js +55 -0
  9. js/bunny_stream-upload.js +206 -0
  10. js/media-library-browser-base.js +22 -1
  11. js/shortcode-editor.js +113 -69
  12. models/bunny-stream-wizard/images/bunnycdn-api-2x.png +0 -0
  13. models/bunny-stream-wizard/images/bunnycdn-api.png +0 -0
  14. models/bunny-stream-wizard/images/logo.png +0 -0
  15. models/bunny-stream-wizard/images/pricing-2x.png +0 -0
  16. models/bunny-stream-wizard/images/pricing.png +0 -0
  17. models/bunny-stream-wizard/step_0_introduction.php +30 -0
  18. models/bunny-stream-wizard/step_1_api_key.php +61 -0
  19. models/bunny-stream-wizard/step_2_stream_libs.php +150 -0
  20. models/bunny-stream-wizard/step_finish.php +21 -0
  21. models/checker.php +26 -3
  22. models/class.fv-player-bunny_stream-api.php +69 -0
  23. models/class.fv-player-bunny_stream-browser.php +241 -0
  24. models/class.fv-player-bunny_stream-wizard.php +45 -0
  25. models/class.fv-player-bunny_stream.php +485 -0
  26. models/db.php +4 -2
  27. models/flowplayer-frontend.php +11 -5
  28. models/list-table.php +4 -4
  29. models/media-browser.php +4 -1
  30. models/player-position-save.php +12 -7
  31. models/video-encoder/class.fv-player-encoder-list-table.php +7 -1
  32. models/video-encoder/video-encoder.php +31 -8
  33. readme.txt +7 -0
  34. view/bunny-stream-categories.php +23 -0
  35. view/bunny-stream-settings.php +48 -0
  36. view/wizard.php +16 -16
controller/editor.php CHANGED
@@ -18,7 +18,7 @@ function fv_player_shortcode_editor_scripts_enqueue() {
18
  wp_register_script('fvwpflowplayer-domwindow', flowplayer::get_plugin_url().'/js/jquery.colorbox-min.js',array('jquery'), $fv_wp_flowplayer_ver );
19
  wp_enqueue_script('fvwpflowplayer-domwindow');
20
 
21
- wp_register_script('fvwpflowplayer-shortcode-editor', flowplayer::get_plugin_url().'/js/shortcode-editor.js',array('jquery','jquery-ui-sortable'), $fv_wp_flowplayer_ver );
22
  wp_register_script('fvwpflowplayer-editor-screenshots', flowplayer::get_plugin_url().'/js/editor-screenshots.js',array('jquery','fvwpflowplayer-shortcode-editor','flowplayer'), $fv_wp_flowplayer_ver );
23
 
24
  wp_localize_script( 'fvwpflowplayer-shortcode-editor', 'fv_player_editor_conf', array(
18
  wp_register_script('fvwpflowplayer-domwindow', flowplayer::get_plugin_url().'/js/jquery.colorbox-min.js',array('jquery'), $fv_wp_flowplayer_ver );
19
  wp_enqueue_script('fvwpflowplayer-domwindow');
20
 
21
+ wp_register_script('fvwpflowplayer-shortcode-editor', flowplayer::get_plugin_url().'/js/shortcode-editor.js',array('jquery','jquery-ui-sortable'), defined('SCRIPT_DEBUG') ? filemtime( dirname(__FILE__).'/../js/shortcode-editor.js' ) : $fv_wp_flowplayer_ver );
22
  wp_register_script('fvwpflowplayer-editor-screenshots', flowplayer::get_plugin_url().'/js/editor-screenshots.js',array('jquery','fvwpflowplayer-shortcode-editor','flowplayer'), $fv_wp_flowplayer_ver );
23
 
24
  wp_localize_script( 'fvwpflowplayer-shortcode-editor', 'fv_player_editor_conf', array(
css/s3-browser.css CHANGED
@@ -281,7 +281,7 @@
281
  z-index: 2; /* or a file uploader link will be invisibly over the UL with thumbs */
282
  }
283
 
284
- #browser-dropdown {
285
  margin-top: 10px;
286
  }
287
 
281
  z-index: 2; /* or a file uploader link will be invisibly over the UL with thumbs */
282
  }
283
 
284
+ #browser-dropdown, #media-search-input {
285
  margin-top: 10px;
286
  }
287
 
flowplayer.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: FV Player
4
  Plugin URI: http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer
5
  Description: Formerly FV WordPress Flowplayer. Supports MP4, HLS, MPEG-DASH, WebM and OGV. Advanced features such as overlay ads or popups. Uses Flowplayer 7.2.7.
6
- Version: 7.5.12.727
7
  Author URI: http://foliovision.com/
8
  License: GPL-3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.txt
@@ -27,7 +27,7 @@ License URI: http://www.gnu.org/licenses/gpl-3.0.txt
27
  */
28
 
29
  global $fv_wp_flowplayer_ver;
30
- $fv_wp_flowplayer_ver = '7.5.12.727.2';
31
  $fv_wp_flowplayer_core_ver = '7.2.7.2';
32
  include_once( dirname( __FILE__ ) . '/includes/extra-functions.php' );
33
  if( file_exists( dirname( __FILE__ ) . '/includes/module.php' ) ) {
@@ -102,3 +102,14 @@ include_once(dirname( __FILE__ ).'/models/migration-wizard.class.php');
102
  include_once(dirname( __FILE__ ).'/models/migration-wizard.php');
103
 
104
  include_once(dirname( __FILE__ ) . '/models/stats.php');
 
 
 
 
 
 
 
 
 
 
 
3
  Plugin Name: FV Player
4
  Plugin URI: http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer
5
  Description: Formerly FV WordPress Flowplayer. Supports MP4, HLS, MPEG-DASH, WebM and OGV. Advanced features such as overlay ads or popups. Uses Flowplayer 7.2.7.
6
+ Version: 7.5.13.727
7
  Author URI: http://foliovision.com/
8
  License: GPL-3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.txt
27
  */
28
 
29
  global $fv_wp_flowplayer_ver;
30
+ $fv_wp_flowplayer_ver = '7.5.13.727';
31
  $fv_wp_flowplayer_core_ver = '7.2.7.2';
32
  include_once( dirname( __FILE__ ) . '/includes/extra-functions.php' );
33
  if( file_exists( dirname( __FILE__ ) . '/includes/module.php' ) ) {
102
  include_once(dirname( __FILE__ ).'/models/migration-wizard.php');
103
 
104
  include_once(dirname( __FILE__ ) . '/models/stats.php');
105
+
106
+ add_action('plugins_loaded', 'fv_player_bunny_stream_include' );
107
+
108
+ if( !function_exists( 'fv_player_bunny_stream_include' ) ) {
109
+ function fv_player_bunny_stream_include() {
110
+ do_action( 'fv_player_load_video_encoder_libs' );
111
+ if ( class_exists( 'FV_Player_Video_Encoder' ) ) {
112
+ require_once( dirname( __FILE__ ).'/models/class.fv-player-bunny_stream.php' );
113
+ }
114
+ }
115
+ }
flowplayer/fv-player.min.js CHANGED
@@ -1 +1 @@
1
- if(typeof fv_flowplayer_conf!="undefined"){try{if(typeof window.localStorage=="object"&&typeof window.localStorage.volume!="undefined"){delete fv_flowplayer_conf.volume}}catch(e){}flowplayer.conf=fv_flowplayer_conf;flowplayer.conf.fullscreen=false;flowplayer.conf.chromecast=false;flowplayer.conf.embed=false;flowplayer.conf.share=false;flowplayer.conf.analytics=false;if(typeof fv_flowplayer_conf.disable_localstorage!="undefined"){flowplayer.conf.storage={}}try{flowplayer.conf.key=atob(flowplayer.conf.key)}catch(e){}if(!flowplayer.support.android&&flowplayer.conf.dacast_hlsjs){function FVAbrController(hls){this.hls=hls;this.nextAutoLevel=3}FVAbrController.prototype.nextAutoLevel=function(nextLevel){this.nextAutoLevel=nextLevel};FVAbrController.prototype.destroy=function(){};flowplayer.conf.hlsjs={startLevel:-1,abrController:FVAbrController}}function parseIOSVersion(UA){var e=/iP(ad|hone)(; CPU)? OS (\d+_\d)/.exec(UA);if(e&&e.length>1){return parseFloat(e[e.length-1].replace("_","."),10)}return 0}if(flowplayer.support.iOS&&flowplayer.support.iOS.chrome&&flowplayer.support.iOS.version==0){flowplayer.support.iOS.version=parseIOSVersion(navigator.userAgent)}if(flowplayer.support.iOS&&parseInt(flowplayer.support.iOS.version)>=13||!flowplayer.support.iOS&&flowplayer.support.browser.safari&&parseInt(flowplayer.support.browser.version)>=8){flowplayer.conf.hlsjs.safari=true}flowplayer.support.fvmobile=!!(!flowplayer.support.firstframe||flowplayer.support.iOS||flowplayer.support.android);var fls=flowplayer.support;if(flowplayer.conf.mobile_native_fullscreen&&"ontouchstart"in window&&fls.fvmobile){flowplayer.conf.native_fullscreen=true}if("ontouchstart"in window){if(fls.android&&fls.android.version<4.4&&!(fls.browser.chrome&&fls.browser.version>54)){flowplayer.conf.native_fullscreen=true}if(fls.iOS&&(fv_player_in_iframe()||fls.iOS.version<7)){flowplayer.conf.native_fullscreen=true}}}if(typeof fv_flowplayer_translations!="undefined"){flowplayer.defaults.errors=fv_flowplayer_translations}var fv_player_did_autoplay=false;function fv_player_videos_parse(args,root){try{var videos=JSON.parse(args)}catch(e){return false}var regex=new RegExp("[\\?&]fv_flowplayer_mobile=([^&#]*)");var results=regex.exec(location.search);if((results!=null&&results[1]=="yes"||(jQuery(window).width()<=480||jQuery(window).height()<=480))&&(results==null||results[1]!="no")){var fv_fp_mobile=false;jQuery(videos.sources).each(function(k,v){if(v.mobile){videos.sources[k]=videos.sources[0];videos.sources[0]=v;fv_fp_mobile=true}if(fv_fp_mobile){jQuery(root).after('<p class="fv-flowplayer-mobile-switch">'+fv_flowplayer_translations.mobile_browser_detected_1+' <a href="'+document.URL+'?fv_flowplayer_mobile=no">'+fv_flowplayer_translations.mobile_browser_detected_2+"</a>.</p>")}})}root.trigger("fv_player_videos_parse",videos);return videos}function fv_player_in_iframe(){try{return window.self!==window.top}catch(e){return true}}jQuery(document).ready(function(){var loading_count=0;var loading=setInterval(function(){loading_count++;if(loading_count<1e3&&(window.fv_video_intelligence_conf&&!window.FV_Player_IMA||window.fv_vast_conf&&!window.FV_Player_IMA||window.fv_player_pro&&!window.FV_Flowplayer_Pro&&document.getElementById("fv_player_pro")!=fv_player_pro||window.fv_player_user_playlists&&!fv_player_user_playlists.is_loaded||window.FV_Player_JS_Loader_scripts_total&&window.FV_Player_JS_Loader_scripts_loaded<FV_Player_JS_Loader_scripts_total)){return}clearInterval(loading);fv_player_preload()},10)});function fv_escape_attr(text){var map={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return text.replace(/[&<>"']/g,function(m){return map[m]})}function fv_player_preload(){if(flowplayer.support.touch){jQuery(".fp-playlist-external.fv-playlist-design-2017").addClass("visible-captions")}flowplayer(function(api,root){if(localStorage.flowplayerTestStorage){delete localStorage.flowplayerTestStorage}root=jQuery(root);var fp_player=root.find(".fp-player");var splash_click=false;if(root.hasClass("fixed-controls")){root.find(".fp-controls").on("click",function(e){if(!api.loading&&!api.ready){e.preventDefault();e.stopPropagation();api.load()}})}if(!flowplayer.support.volume&&!flowplayer.support.autoplay){root.find(".fp-volume").hide()}if(root.data("volume")==0&&root.hasClass("no-controlbar")){root.find(".fp-volume").remove()}var playlist=jQuery(".fp-playlist-external[rel="+root.attr("id")+"]");if((!api.conf.playlist||api.conf.playlist.length==0)&&playlist.length&&playlist.find("a[data-item]").length>0){var items=[];playlist.find("a[data-item]").each(function(){if(parsed=fv_player_videos_parse(jQuery(this).attr("data-item"),root)){items.push(parsed)}else{jQuery(this).remove()}});api.conf.playlist=items;api.conf.clip=items[0]}else if(!api.conf.clip){api.conf.clip=fv_player_videos_parse(jQuery(root).attr("data-item"),root)}jQuery("a",playlist).on("click",function(e){e.preventDefault();splash_click=true;var $this=jQuery(this),playlist=jQuery(".fp-playlist-external[rel="+root.attr("id")+"]"),index=jQuery("a",playlist).index(this);$prev=$this.prev("a"),item=$this.data("item");if(location.href.match(/wp-admin/)&&$this.parents(".fv-player-editor-preview").length>0){fv_flowplayer_conf.current_video_to_edit=index;$this.parents(".fv-player-custom-video").find(".edit-video .fv-player-editor-button").trigger("click");return false}if($prev.length&&$this.is(":visible")&&!$prev.is(":visible")){$prev.trigger("click");return false}if(jQuery("#"+$this.parent().attr("rel")).hasClass("dynamic-playlist"))return;var playlist=jQuery(".fp-playlist-external[rel="+root.attr("id")+"]");fv_player_playlist_active(playlist,this);if(api){if(api.error){api.pause();api.error=api.loading=false;root.removeClass("is-error");root.find(".fp-message.fp-shown").remove()}if(!api.video||api.video.index==index)return;api.play(index)}var new_splash=item.splash;if(!new_splash){new_splash=$this.find("img").attr("src")}player_splash(root,fp_player,item,new_splash);var rect=root[0].getBoundingClientRect();if(rect.bottom-100<0){jQuery("html, body").animate({scrollTop:jQuery(root).offset().top-100},300)}});var playlist_external=jQuery("[rel="+root.attr("id")+"]");var playlist_progress=false;var splash_img=root.find(".fp-splash");var splash_text=root.find(".fv-fp-splash-text");function player_splash(root,fp_player,item,new_splash){var splash_img=root.find("img.fp-splash");if(new_splash){if(splash_img.length==0){splash_img=jQuery('<img class="fp-splash" />');fp_player.prepend(splash_img)}splash_img.attr("alt",item.fv_title?fv_escape_attr(item.fv_title):"video");splash_img.attr("src",new_splash)}else if(splash_img.length){splash_img.remove()}}api.bind("load",function(e,api,video){if(!api.conf.playlist.length){return}if(video.type.match(/^audio/)&&!splash_click){var anchor=playlist_external.find("a").eq(video.index);var item=anchor.data("item");var new_splash=item.splash;if(!new_splash){new_splash=anchor.find("img").attr("src")}player_splash(root,fp_player,item,new_splash)}splash_click=false});api.bind("ready",function(e,api,video){setTimeout(function(){if(video.index>-1){if(playlist_external.length>0){var playlist_item=jQuery("a",playlist_external).eq(video.index);fv_player_playlist_active(playlist_external,playlist_item);playlist_progress=playlist_item.find(".fvp-progress")}}},100);splash_img=root.find(".fp-splash");if(!video.is_audio_stream&&!video.type.match(/^audio/)){splash_img.remove();splash_text.remove()}});api.bind("unload",function(){jQuery(".fp-playlist-external .now-playing").remove();jQuery(".fp-playlist-external a").removeClass("is-active");var iframe=fp_player.find("iframe.fp-engine");if(iframe.length){iframe.after(splash_text);iframe.after(splash_img)}else{fp_player.prepend(splash_text);fp_player.prepend(splash_img)}playlist_progress=false});api.bind("progress",function(e,api,time){if(playlist_progress.length){api.playlist_thumbnail_progress(playlist_progress,api.video,time)}});api.bind("error-subtitles",function(){console.log("error-subtitles");fv_player_notice(root,fv_flowplayer_translations[8],2e3)});var playlist=jQuery(root).parent().find("div.fp-playlist-vertical[rel="+jQuery(root).attr("id")+"]");if(playlist.length){function check_size_and_all(args){var property=playlist.hasClass("fp-playlist-only-captions")?"height":"max-height";if(playlist.parents(".fp-playlist-text-wrapper").hasClass("is-fv-narrow")){property="max-height"}playlist.css(property,vertical_playlist_height());if(property=="max-height")playlist.css("height","auto")}check_size_and_all();jQuery(window).on("resize tabsactivate",function(){setTimeout(check_size_and_all,0)})}function vertical_playlist_height(args){var height=root.height();if(height==0)height=root.css("max-height");return height}api.show_status=function(type){var status="";["loading","ready","playing","paused","seeking"].every(function(v,k){if(api[v])status+=" "+v;return true});console.log("FV Player Status ("+type+")",status)};if(!window.fv_player_loaded){window.fv_player_loaded=true;setTimeout(function(){jQuery(document).trigger("fv_player_loaded");var event=new CustomEvent("fv_player_loaded",[]);document.dispatchEvent(event)},100)}setTimeout(function(){root.trigger("fv_player_loaded")},10)});if(window.self!=window.top&&!location.href.match(/fv_player_preview/)){embed_size();jQuery(window.self).resize(embed_size)}function embed_size(){jQuery(".flowplayer.fp-is-embed").each(function(){var root=jQuery(this);if(!root.hasClass("has-chapters")&&!root.hasClass("has-transcript")&&jQuery(".fp-playlist-external[rel="+root.attr("id")+"]").length==0){root.height(jQuery(window).height())}})}if(typeof fv_flowplayer_playlists!="undefined"){for(var i in fv_flowplayer_playlists){if(!fv_flowplayer_playlists.hasOwnProperty(i))continue;jQuery("#"+i).flowplayer({playlist:fv_flowplayer_playlists[i]})}}fv_player_load();fv_autoplay_exec();jQuery(document).ajaxComplete(function(){fv_player_load()});jQuery(window).on("hashchange",fv_autoplay_exec)}function fv_player_load(forced_el){if(forced_el&&forced_el.lenght>1){console.log("FV Player: Can't use fv_player_load with more than a single forced element!")}var load_players=forced_el,forced_api=false;if(!load_players)load_players=jQuery(".flowplayer");load_players.each(function(i,el){var root=jQuery(el);var api=root.data("flowplayer");if(api){if(forced_el)forced_api=api;return}if(forced_el){root.find(".fp-preload, .fvfp_admin_error").remove();if(root.attr("data-item-lazy")){root.attr("data-item",root.attr("data-item-lazy"));root.removeAttr("item-lazy")}else if(playlist=jQuery("[rel="+root.attr("id")+"]")){playlist.find("a[data-item-lazy]").each(function(k,v){v=jQuery(v);v.attr("data-item",v.attr("data-item-lazy"));v.removeAttr("data-item-lazy")})}}var conf=false;if(root.attr("data-item")){conf={clip:fv_player_videos_parse(root.attr("data-item"),root)}}else if(playlist=jQuery("[rel="+root.attr("id")+"]")){if(playlist.find("a[data-item]").length==0)return;var items=[];playlist.find("a[data-item]").each(function(){if(parsed=fv_player_videos_parse(jQuery(this).attr("data-item"),root)){items.push(parsed)}else{jQuery(this).remove()}});conf={playlist:items}}if(conf){conf=flowplayer.extend(conf,root.data());forced_api=flowplayer(root[0],conf);root.data("flowplayer",forced_api)}});jQuery(".fv-playlist-slider-wrapper").each(function(i,el){var items=jQuery(this).find("a");jQuery(this).find(".fp-playlist-external").css("width",items.outerWidth()*items.length)});if(typeof jQuery().tabs!="undefined"){jQuery("body").removeClass("fv_flowplayer_tabs_hide");jQuery(".fv_flowplayer_tabs_content").tabs()}if(forced_el&&forced_api){return forced_api}}function fv_player_playlist_active(playlist,item){if(playlist){jQuery("a",playlist).removeClass("is-active");jQuery(".now-playing").remove()}$playlist=jQuery(playlist);$item=jQuery(item);var scroll_parent=false;$item.addClass("is-active");var is_design_2014=$playlist.hasClass("fv-playlist-design-2014");if((is_design_2014&&$item.find("h4").length==0||!is_design_2014)&&$item.find(".now-playing").length==0)$item.prepend('<strong class="now-playing"><span>'+fv_flowplayer_translations.playlist_current+"</span></strong>");if(!$playlist.parent().find(".flowplayer").length){scroll_parent=true}if(($playlist.hasClass("fp-playlist-vertical")||$playlist.hasClass("fp-playlist-horizontal")&&$playlist.hasClass("is-audio"))&&!fullyVisibleY($item.get(0))){var $el=scroll_parent?$playlist.parent():$playlist;$el.animate({scrollTop:$el.scrollTop()+($item.position().top-$el.position().top)},750)}else if($playlist.hasClass("fp-playlist-horizontal")&&!fullyVisibleX($item.get(0))){var $el=scroll_parent?$playlist.parent():$playlist;$el.animate({scrollLeft:$el.scrollLeft()+($item.position().left-$el.position().left)},750)}function fullyVisibleY(el){var rect=el.getBoundingClientRect(),top=rect.top,height=rect.height,bottom=top+height,el=el.parentNode;do{rect=el.getBoundingClientRect();if(bottom<=rect.bottom===false)return false;if(top<=rect.top)return false;el=el.parentNode}while(el!=document.body);return bottom<=document.documentElement.clientHeight}function fullyVisibleX(el){var rect=el.getBoundingClientRect(),left=rect.left,width=rect.width,right=left+width,el=el.parentNode;do{rect=el.getBoundingClientRect();if(right<=rect.right===false)return false;if(left<=rect.left)return false;el=el.parentNode}while(el!=document.body);return right<=document.documentElement.clientWidth}}var fv_fp_date=new Date;var fv_fp_utime=fv_fp_date.getTime();function fv_parse_sharelink(src){src=src.replace("https?://[^./].","");var prefix="fvp_";if(src.match(/(youtube.com)/)){return prefix+src.match(/(?:v=)([A-Za-z0-9_-]*)/)[1]}else if(src.match(/(vimeo.com)|(youtu.be)/)){return prefix+src.match(/(?:\/)([^/]*$)/)[1]}else{var match=src.match(/(?:\/)([^/]*$)/);if(match){return prefix+match[1].match(/^[^.]*/)[0]}}return prefix+src}function fv_player_get_video_link_hash(api){var hash=fv_parse_sharelink(typeof api.video.sources_original!="undefined"&&typeof api.video.sources_original[0]!="undefined"?api.video.sources_original[0].src:api.video.sources[0].src);if(typeof api.video.id!="undefined"){hash=fv_parse_sharelink(api.video.id.toString())}return hash}function fv_player_time_hms(seconds){if(isNaN(seconds)){return NaN}var sec_num=parseInt(seconds,10);var hours=Math.floor(sec_num/3600);var minutes=Math.floor(sec_num/60)%60;var seconds=sec_num%60;if(hours){hours+="h"}else{hours=""}if(hours&&minutes<10){minutes="0"+minutes+"m"}else if(minutes){minutes+="m"}else{minutes=""}if((hours||minutes)&&seconds<10){seconds="0"+seconds}seconds+="s";var timeString=hours+minutes+seconds;return timeString}function fv_player_time_hms_ms(seconds){if(isNaN(seconds)){return NaN}seconds=parseFloat(seconds).toFixed(3);var miliseconds=(seconds+"").split(".");if(typeof miliseconds[1]!="undefined"&&miliseconds[1]>0){miliseconds=miliseconds[1]+"ms"}else{miliseconds=""}var timeString=fv_player_time_hms(seconds)+miliseconds;return timeString}function fv_player_time_seconds(time,duration){if(!time)return-1;var seconds=0;var match=time.match(/(\d+[a-z]{1,2})/g);match.forEach(function(item){if(item.endsWith("h")){seconds+=3600*parseInt(item)}else if(item.endsWith("m")){seconds+=60*parseInt(item)}else if(item.endsWith("s")&&!item.endsWith("ms")){seconds+=parseInt(item)}else if(item.endsWith("ms")){if(parseInt(item)){seconds+=parseInt(item)/1e3}}});return duration?Math.min(seconds,duration):seconds}function fv_autoplay_init(root,index,time,abStart,abEnd){if(fv_autoplay_exec_in_progress)return;fv_autoplay_exec_in_progress=true;var api=root.data("flowplayer");if(!api)return;var fTime=fv_player_time_seconds(time);abEnd=fv_player_time_seconds(abEnd);abStart=fv_player_time_seconds(abStart);if(root.parent().hasClass("ui-tabs-panel")){var tabId=root.parent().attr("id");jQuery("[aria-controls="+tabId+"] a").trigger("click")}if(!root.find(".fp-player").attr("class").match(/\bis-sticky/)){var offset=jQuery(root).offset().top-(jQuery(window).height()-jQuery(root).height())/2;window.scrollTo(0,offset);api.one("ready",function(){window.scrollTo(0,offset)})}if(root.hasClass("lightboxed")){setTimeout(function(){jQuery("[href=\\#"+root.attr("id")+"]").trigger("click")},0)}if(index){if(fv_player_video_link_autoplay_can(api,parseInt(index))){if(api.ready){fv_player_video_link_seek(api,fTime)}else{api.play(parseInt(index));api.one("ready",function(){fv_player_video_link_seek(api,fTime,abEnd,abStart)})}}else if(flowplayer.support.inlineVideo){api.one(api.playing?"progress":"ready",function(e,api){api.play(parseInt(index));api.one("ready",function(){fv_player_video_link_seek(api,fTime,abEnd,abStart)})});root.find(".fp-splash").attr("src",jQuery("[rel="+root.attr("id")+"] div").eq(index).find("img").attr("src"));if(!fv_player_in_iframe()){fv_player_notice(root,fv_flowplayer_translations[11],"progress")}}}else{if(api.ready){fv_player_video_link_seek(api,fTime)}else{if(fv_player_video_link_autoplay_can(api)){api.load()}else if(!fv_player_in_iframe()){fv_player_notice(root,fv_flowplayer_translations[11],"progress")}api.one("ready",function(){fv_player_video_link_seek(api,fTime,abEnd,abStart)})}}}function fv_player_video_link_seek(api,fTime,abEnd,abStart){fv_autoplay_exec_in_progress=false;var do_seek=setInterval(function(){if(api.loading)return;if(fTime>0||api.video.time>0){if(!!api.custom_seek){api.custom_seek(fTime)}else{api.seek(fTime)}}if(abEnd&&abStart)api.trigger("link-ab",[api,abStart,abEnd]);clearInterval(do_seek)},10)}var fv_autoplay_exec_in_progress=false;function fv_autoplay_exec(){var autoplay=true;if(typeof flowplayer!=="undefined"&&typeof fv_flowplayer_conf!="undefined"&&fv_flowplayer_conf.video_hash_links&&window.location.hash.substring(1).length){var aHash=window.location.hash.match(/\?t=/)?window.location.hash.substring(1).split("?t="):window.location.hash.substring(1).split(",");var hash=aHash[0];var time=aHash[1]===undefined?false:aHash[1];var abStart=aHash[2]===undefined?false:aHash[2];var abEnd=aHash[3]===undefined?false:aHash[3];jQuery(".flowplayer").each(function(){var root=jQuery(this);if(root.hasClass("lightbox-starter")){root=jQuery(root.attr("href"))}var api=root.data("flowplayer");if(!api)return;var playlist=typeof api.conf.playlist!=="undefined"&&api.conf.playlist.length>1?api.conf.playlist:[api.conf.clip];for(var item in playlist){if(!playlist.hasOwnProperty(item))continue;var id=typeof playlist[item].id!=="undefined"?fv_parse_sharelink(playlist[item].id.toString()):false;if(hash===id&&autoplay){console.log("fv_autoplay_exec for "+id,item);fv_autoplay_init(root,parseInt(item),time,abStart,abEnd);autoplay=false;return false}}for(var item in playlist){if(!playlist.hasOwnProperty(item))continue;var src=fv_parse_sharelink(playlist[item].sources[0].src);if(hash===src&&autoplay){console.log("fv_autoplay_exec for "+src,item);fv_autoplay_init(root,parseInt(item),time,abStart,abEnd);autoplay=false;return false}}})}if(autoplay&&flowplayer.support.firstframe){jQuery(".flowplayer[data-fvautoplay]").each(function(){var root=jQuery(this),api=root.data("flowplayer"),autoplay=root.attr("data-fvautoplay");if(!fv_player_did_autoplay&&autoplay){if((flowplayer.support.android||flowplayer.support.iOS)&&api&&api.conf.clip.sources[0].type=="video/youtube"){console.log("FV Player: Autoplay for YouTube not supported on Android and iOS");return}else{fv_player_did_autoplay=true;if(api.conf.playlist.length&&!isNaN(parseFloat(autoplay))&&isFinite(autoplay)){api.play(parseInt(autoplay))}else{api.load()}var play_icon=root.find(".fp-play").addClass("invisible"),control_bar=root.find(".fp-controls").addClass("invisible");api.one("progress",function(){play_icon.removeClass("invisible");control_bar.removeClass("invisible")});if(autoplay=="muted"){api.mute(true,true)}}}})}}function fv_player_video_link_autoplay_can(api,item){var video=item?api.conf.playlist[item]:api.conf.clip;if(video.sources[0].type=="video/youtube"&&(flowplayer.support.iOS||flowplayer.support.android)||fv_player_in_iframe())return false;return flowplayer.support.firstframe}function fv_player_notice(root,message,timeout){var notices=jQuery(".fvfp-notices",root);if(!notices.length){notices=jQuery('<div class="fvfp-notices">');jQuery(".fp-player",root).append(notices)}var notice=jQuery('<div class="fvfp-notice-content">'+message+"</div></div>");notices.append(notice);if(typeof timeout=="string"){var player=jQuery(root).data("flowplayer");player.on(timeout,function(){notice.fadeOut(100,function(){jQuery(this).remove()})})}if(timeout>0){setTimeout(function(){notice.fadeOut(2e3,function(){jQuery(this).remove()})},timeout)}return notice}var fv_player_clipboard=function(text,successCallback,errorCallback){try{fv_player_doCopy(text);successCallback()}catch(e){if(typeof errorCallback!="undefined")errorCallback(e)}};function fv_player_doCopy(text){var textarea=document.createElement("textarea");textarea.value=text;textarea.style.opacity=0;textarea.style.position="absolute";textarea.setAttribute("readonly",true);document.body.appendChild(textarea);var selected=document.getSelection().rangeCount>0?document.getSelection().getRangeAt(0):false;if(navigator.userAgent.match(/ipad|ipod|iphone/i)){var editable=textarea.contentEditable;textarea.contentEditable=true;var range=document.createRange();range.selectNodeContents(textarea);var sel=window.getSelection();sel.removeAllRanges();sel.addRange(range);textarea.setSelectionRange(0,999999);textarea.contentEditable=editable}else{textarea.select()}try{var result=document.execCommand("copy");if(selected){document.getSelection().removeAllRanges();document.getSelection().addRange(selected)}document.body.removeChild(textarea);return result}catch(err){throw new Error("Unsuccessfull")}}flowplayer(function(api,root){root=jQuery(root);if(typeof api.conf.disable_localstorage!="undefined"){return}var hlsjs;flowplayer.engine("hlsjs-lite").plugin(function(params){hlsjs=params.hls;hlsjs.on(Hls.Events.ERROR,function(event,data){if(data.type=="mediaError"&&data.details=="fragParsingError"&&data.fatal==true){hlsjs.destroy();api.trigger("error",[api,{code:3}]);setTimeout(function(){root.removeClass("is-seeking");root.addClass("is-paused")},0)}});if(flowplayer.support.browser.safari){hlsjs.on(Hls.Events.KEY_LOADED,function(event){if(event=="hlsKeyLoaded"){setTimeout(function(){if(api.loading){console.log("FV Player: Safari stuck loading HLS, resuming playback...");api.resume()}},0)}})}var pick_quality=flowplayer.conf.hd_streaming&&!flowplayer.support.fvmobile?720:false;if(jQuery(params.root).data("hd_streaming")==false)pick_quality=false;if(localStorage.FVPlayerHLSQuality)pick_quality=localStorage.FVPlayerHLSQuality;if(pick_quality){hlsjs.on(Hls.Events.MANIFEST_PARSED,function(_,data){var found=false;jQuery.each(data.levels,function(k,v){if(v.height==pick_quality)found=k});if(!localStorage.FVPlayerHLSQuality&&!found){jQuery.each(data.levels,function(k,v){if(v.height>found)found=k})}if(found){console.log("FV Player: Picked "+data.levels[found].height+"p quality");hlsjs.startLevel=found;hlsjs.currentLevel=found}})}});root=jQuery(root);var search=document.location.search;if(localStorage.FVPlayerDashQuality){if(!api.conf.dash)api.conf.dash={};api.conf.dash.initialVideoQuality="restore"}root.on("click",".fp-qsel-menu a",function(){if(api.engine.engineName=="hlsjs-lite"){var quality=jQuery(this).data("quality");if(quality==-1){localStorage.removeItem("FVPlayerHLSQuality")}else{var level=hlsjs.levels[quality];localStorage.FVPlayerHLSQuality=level.height}}});if(localStorage.FVPlayerHLSQuality){api.conf.hlsjs.startLevel=parseInt(localStorage.FVPlayerHLSQuality);api.conf.hlsjs.testBandwidth=false;api.conf.hlsjs.autoLevelEnabled=false}else if(flowplayer.conf.hd_streaming&&!flowplayer.support.fvmobile){api.conf.hlsjs.startLevel=3;api.conf.hlsjs.testBandwidth=false;api.conf.hlsjs.autoLevelEnabled=false}api.bind("quality",function(e,api,quality){if(api.engine.engineName=="dash"){if(quality==-1){localStorage.removeItem("FVPlayerDashQuality")}else if(bitrates[quality]){localStorage.FVPlayerDashQuality=bitrates[quality].height}}});var bitrates=[];var last_quality=-1;api.bind("ready",function(e,api){root.find(".fp-qsel-menu strong").text(fv_flowplayer_translations.quality);if(api.engine.engineName=="dash"){bitrates=api.engine.dash.getBitrateInfoListFor("video");if(localStorage.FVPlayerDashQuality&&api.conf.dash.initialVideoQuality){api.quality(api.conf.dash.initialVideoQuality)}quality_sort()}else if(api.engine.engineName=="hlsjs-lite"){root.addClass("is-loading");api.loading=true;api.one("progress",function(){if(api.loading){root.removeClass("is-loading");api.loading=false}});if(api.video.qualities&&api.video.qualities.length>2){var qswitch=-1;if(localStorage.FVPlayerHLSQuality){jQuery(api.video.qualities).each(function(k,v){if(v.value==localStorage.FVPlayerHLSQuality){qswitch=localStorage.FVPlayerHLSQuality;return false}})}else if(flowplayer.conf.hd_streaming&&!flowplayer.support.fvmobile){jQuery(api.video.qualities).each(function(k,v){var height=parseInt(v.label);if(height>0&&qswitch==-1&&height>=720&&height<=720){qswitch=v.value}})}qswitch=parseInt(qswitch);if(qswitch>-1){root.one("progress",function(){setTimeout(function(){api.quality(qswitch)})})}quality_sort()}}else if(api.video.sources_fvqs&&api.video.sources_fvqs.length>0&&api.video.src.match(/vimeo.*?\.mp4/)){setTimeout(quality_sort,0)}root.find("a[data-quality]").removeClass("is-current")});if(search.match(/dash_debug/)||search.match(/hls_debug/))var debug_log=jQuery('<div class="fv-debug" style="background: gray; color: white; top: 10%; position: absolute; z-index: 1000">').appendTo(root.find(".fp-player"));api.bind("ready progress",quality_process);api.bind("quality",function(){setTimeout(quality_process,0)});function quality_process(){if(api.engine.engineName=="dash"){var stream_info=bitrates[api.engine.dash.getQualityFor("video")];if(stream_info.qualityIndex!=last_quality){last_quality=stream_info.qualityIndex;quality_label(stream_info.qualityIndex,bitrates)}if(search.match(/dash_debug/))quality_debug(stream_info.width,stream_info.height,stream_info.bitrate)}else if(api.engine.engineName=="hlsjs-lite"){if(hlsjs.currentLevel!=last_quality){last_quality=hlsjs.currentLevel;quality_label(hlsjs.currentLevel,hlsjs.levels)}if(search.match(/hls_debug/)){var level=hlsjs.levels[hlsjs.currentLevel];if(level){quality_debug(level.width,level.height,level.bitrate)}}}}function quality_label(index,qualities){if(!qualities[index])return;var height=qualities[index].height,hd_limit=541,lowest=1e5;jQuery(qualities).each(function(k,v){if(v.height>=720&&v.height<1400)hd_limit=720;if(v.height<lowest)lowest=v.height;if(localStorage.FVPlayerHLSQuality==v.height){root.find("a[data-quality]").removeClass("fp-selected fp-color");root.find("a[data-quality="+k+"]").addClass("fp-selected fp-color")}});root.find("a[data-quality]").removeClass("is-current");root.find("a[data-quality="+index+"]").addClass("is-current");var label="SD";if(height>=360&&lowest<height)label="SD";if(height>=hd_limit)label="HD";if(height>=1400)label="4K";root.find(".fp-qsel").html(label)}function quality_debug(w,h,br){debug_log.html("Using "+w+"x"+h+" at "+Math.round(br/1024)+" kbps")}function quality_sort(){var menu=root.find(".fp-qsel-menu");menu.children().each(function(i,a){menu.prepend(a)});menu.children().each(function(i,a){if(/^NaNp/.test(jQuery(a).html())){var bitrate=jQuery(a).html().match(/\((.*?)\)/);if(bitrate&&typeof bitrate[1]!=="undefined"){jQuery(a).html(bitrate[1])}}else{jQuery(a).html(jQuery(a).html().replace(/\(.*?\)/,""))}});menu.prepend(menu.find("a[data-quality=-1]"));menu.prepend(menu.find("strong"))}});flowplayer(function(api,root){root=jQuery(root);var player_id=root.attr("id"),ad=false;if(root.data("end_popup_preview")){jQuery(document).ready(function(){api.trigger("finish",[api])})}function ad_height_check(){var count=0;var ad_height_check=setInterval(function(){var height=ad&&ad.find(".adsbygoogle").height();count++;if(count>20*10||height>0)clearInterval(ad_height_check);if(height>root.height()){ad.addClass("tall-ad")}},50)}function show_ad(){var ad_data=root.attr("data-ad");if(typeof ad_data!="undefined"&&ad_data.length){try{ad_data=JSON.parse(ad_data)}catch(e){return false}if(!ad&&!root.hasClass("is-cva")&&root.width()>=parseInt(ad_data.width)){var html=ad_data.html;html=html.replace("%random%",Math.random());ad=jQuery('<div id="'+player_id+'_ad" class="wpfp_custom_ad">'+html+"</div>");root.find(".fp-player").append(ad);ad_height_check();setTimeout(function(){if(root.find(".wpfp_custom_ad video").length){api.pause()}},500)}}}function show_popup(event){var popup_data=root.attr("data-popup");if(typeof popup_data!="undefined"&&popup_data.length){try{popup_data=JSON.parse(popup_data)}catch(e){return false}if(event=="finish"||popup_data.pause||popup_data.html.match(/fv-player-ppv-purchase-btn-wrapper/)){root.addClass("is-popup-showing");root.find(".fp-player").append('<div id="'+player_id+'_custom_popup" class="wpfp_custom_popup">'+popup_data.html+"</div>")}}}api.bind("ready",function(e,api){if(ad.length==1){ad.remove();ad=false}if(!root.data("ad_show_after")){show_ad()}}).bind("progress",function(e,api,current){if(current>root.data("ad_show_after")){show_ad()}}).bind("finish",function(e,api){if(typeof api.video.index=="undefined"||api.video.index+1==api.conf.playlist.length){show_popup(e.type)}}).bind("pause",function(e,api){show_popup(e.type)}).bind("resume unload seek",function(e,api){if(root.hasClass("is-popup-showing")){root.find(".wpfp_custom_popup").remove();root.removeClass("is-popup-showing")}})});jQuery(document).on("click",".fv_fp_close",function(){var ad=jQuery(this).parents(".wpfp_custom_ad_content"),video=ad.find("video");ad.fadeOut();if(video.length)video[0].pause();return false});jQuery(document).on("focus",".fv_player_popup input[type=text], .fv_player_popup input[type=email], .fv_player_popup textarea",function(){var api=jQuery(this).parents(".flowplayer").data("flowplayer");if(api)api.disable(true)});jQuery(document).on("blur",".fv_player_popup input[type=text], .fv_player_popup input[type=email], .fv_player_popup textarea",function(){var api=jQuery(this).parents(".flowplayer").data("flowplayer");if(api)api.disable(false)});flowplayer(function(api,root){api.on("ready",function(e,api,video){api.one("progress",function(){jQuery(root).find(".fp-airplay").toggle(api.engine.engineName=="html5")})})});flowplayer(function(api,root){var root=jQuery(root),bean=flowplayer.bean,time=0,last=0,timer,event_name;if(typeof ga=="undefined"&&api.conf.fvanalytics&&typeof _gat=="undefined"&&typeof gtag=="undefined"){if(is_ga_4(api)){jQuery.getScript({url:"https://www.googletagmanager.com/gtag/js?id="+api.conf.fvanalytics,cache:true},function(){window.dataLayer=window.dataLayer||[];window.gtag=function(){window.dataLayer.push(arguments)};window.gtag("js",new Date);window.gtag("config",api.conf.fvanalytics)})}else{jQuery.getScript({url:"https://www.google-analytics.com/analytics.js",cache:true},function(){ga("create",api.conf.fvanalytics,"auto")})}}if(!window._paq&&api.conf.matomo_domain&&api.conf.matomo_site_id){var u="//"+api.conf.matomo_domain+"/";var _paq=window._paq=window._paq||[];_paq.push(["setTrackerUrl",u+"matomo.php"]);_paq.push(["setSiteId",api.conf.matomo_site_id]);var d=document,g=d.createElement("script"),s=d.getElementsByTagName("script")[0];g.type="text/javascript";g.async=true;g.src=u+"matomo.js";s.parentNode.insertBefore(g,s)}api.bind("progress",function(e,api,current){fv_track(e,api,current)}).bind("finish ready ",function(e,api){for(var j in fv_ga_events){if(!fv_ga_events.hasOwnProperty(j))continue;root.removeData("fv_track_"+fv_ga_events[j])}}).bind("error",function(e,api,error){setTimeout(function(){if(!api.error)return;var video=typeof api.video!="undefined"&&typeof api.video.src!="undefined"?api.video:false;if(!video&&typeof api.conf.clip!="undefined"&&typeof api.conf.clip.sources!="undefined"&&typeof api.conf.clip.sources[0]!="undefined"&&typeof api.conf.clip.sources[0].src!="undefined")video=api.conf.clip.sources[0];var name=fv_player_track_name(root,video);if(name&&!name.match(/\/\/vimeo.com\/\d/)){if(is_ga_4(api)){}else{fv_player_track(api,false,"Video "+(root.hasClass("is-cva")?"Ad ":"")+"error",error.message,name)}}},100)});api.bind("load unload",fv_track_seconds_played).bind("progress",function(e,api){if(!api.seeking){time+=last?+new Date-last:0;last=+new Date}if(!timer){timer=setTimeout(function(){timer=null;if(!is_ga_4(api)){fv_player_track(api,false,"Flowplayer heartbeat",api.engine.engineName+"/"+api.video.type,"Heartbeat",0)}},10*60*1e3)}}).bind("pause",function(){last=0});api.bind("shutdown",function(){bean.off(window,"unload",fv_track_seconds_played)});bean.on(window,"unload",fv_track_seconds_played);var fv_ga_events=is_ga_4(api)?["Play","25 Percent Played","50 Percent Played","75 Percent Played","100 Percent Played"]:["start","first quartile","second quartile","third quartile","complete"];function fv_track_seconds_played(e,api_not_needed,video){video=video||api.video;if(e.type==="load"){event_name=fv_player_track_name(root,video)}if(time){fv_player_track(api,false,"Video / Seconds played",api.engine.engineName+"/"+api.video.type,event_name,Math.round(time/1e3));time=0;if(timer){clearTimeout(timer);timer=null}}}function fv_track(e,api,data){var video=api.video,dur=video.duration,i=0;var name=fv_player_track_name(root,video);if(dur){if(data>19*dur/20)i=4;else if(data>3*dur/4)i=3;else if(data>dur/2)i=2;else if(data>dur/4)i=1}if(api.live)i=0;if(root.data("fv_track_"+fv_ga_events[i]))return;for(var j in fv_ga_events){if(!fv_ga_events.hasOwnProperty(j))continue;if(j==i)break;if(!root.data("fv_track_"+fv_ga_events[j]))return}root.trigger("fv_track_"+fv_ga_events[i].replace(/ /,"_"),[api,name]);root.data("fv_track_"+fv_ga_events[i],true);fv_player_track(api,false,"Video "+(root.hasClass("is-cva")?"Ad ":"")+fv_ga_events[i],api.engine.engineName+"/"+video.type,name)}api.get_time_played=function(){return time/1e3}});function is_ga_4(api){if(typeof api.conf.fvanalytics!="undefined"&&api.conf.fvanalytics&&api.conf.fvanalytics.startsWith("G-"))return true;return false}function fv_player_track(api,ga_id,event,engineType,name,value){if(!ga_id)ga_id=flowplayer.conf.fvanalytics;if(typeof engineType=="undefined")engineType="Unknown engine";if(/fv_player_track_debug/.test(window.location.href))console.log("FV Player Track: "+event+" - "+engineType+" '"+name+"'",value);if(typeof gtag!="undefined"){if(is_ga_4(api)){gtag("event",event,{video_current_time:api.video.time,video_provider:engineType,video_duration:api.video.duration,value:value?value:1})}else{gtag("event",event,{event_category:engineType,event_label:name,value:value?value:1})}}else if(ga_id&&typeof ga!="undefined"){ga("create",ga_id,"auto",name,{allowLinker:true});ga("require","linker");if(value){ga("send","event",event,engineType,name,value)}else{ga("send","event",event,engineType,name)}}else if(ga_id&&typeof _gat!="undefined"){var tracker=_gat._getTracker(ga_id);if(typeof tracker._setAllowLinker=="undefined"){return}tracker._setAllowLinker(true);if(value){tracker._trackEvent(event,engineType,name,value)}else{tracker._trackEvent(event,engineType,name)}}if(flowplayer.conf.matomo_domain&&flowplayer.conf.matomo_site_id&&typeof _paq!="undefined"){if(value){_paq.push(["trackEvent",event,engineType,name,value])}else{_paq.push(["trackEvent",event,engineType,name])}}}function fv_player_track_name(root,video){var name=root.attr("title");if(!name&&typeof video.fv_title!="undefined")name=video.fv_title;if(!name&&typeof video.title!="undefined")name=video.title;if(!name&&typeof video.src!="undefined"){name=video.src.split("/").slice(-1)[0].replace(/\.(\w{3,4})(\?.*)?$/i,"");if(video.type.match(/mpegurl/))name=video.src.split("/").slice(-2)[0].replace(/\.(\w{3,4})(\?.*)?$/i,"")+"/"+name}return name}flowplayer(function(api,root){root=jQuery(root);var player=root.find(".fp-player"),had_no_volume=root.hasClass("no-volume"),had_fp_mute=root.hasClass("fp-mute"),had_fp_full=root.hasClass("fp-full"),buttons_count=0;function check_size(){var width=player.width()||root.width(),video_index=api.video.index?api.video.index:0;if(width>900){jQuery(".fp-subtitle",root).addClass("is-wide")}else{jQuery(".fp-subtitle",root).removeClass("is-wide")}root.toggleClass("is-tiny",width<400);root.toggleClass("is-small",width<600&&width>=400);var too_narrow=width<480+buttons_count*35;if(typeof api.fv_timeline_chapters_data!="undefined"&&typeof api.fv_timeline_chapters_data[video_index]!="undefined"){too_narrow=true}if(!had_fp_full){root.toggleClass("fp-full",root.hasClass("has-abloop")||too_narrow)}var size="";if(width<400)size="is-tiny";else if(width<600&&width>=400)size="is-small";root.trigger("fv-player-size",[size]);var el=player;if(root.parent().hasClass("fp-playlist-vertical-wrapper")||root.parent().hasClass("fp-playlist-text-wrapper"))el=root.parent();if(el.width()<=560){el.addClass("is-fv-narrow")}else{el.removeClass("is-fv-narrow")}if(width<=320){root.addClass("no-volume fp-mute")}else{if(!had_no_volume)root.removeClass("no-volume");if(!had_fp_mute)root.removeClass("fp-mute")}}check_size();jQuery(window).on("resize",check_size);api.on("ready fullscreen fullscreen-exit sticky sticky-exit",function(e){setTimeout(function(){buttons_count=root.find(".fp-controls > strong:visible").length+root.find(".fp-controls > .fp-icon:visible").length;check_size()},0)});api.on("unload pause finish error",function(){if(typeof checker!=="undefined")clearInterval(checker)})});jQuery(window).on("resize tabsactivate",function(){jQuery(".fp-playlist-external").each(function(){var playlist=jQuery(this);if(playlist.parent().width()>=900)playlist.addClass("is-wide");else playlist.removeClass("is-wide")})}).trigger("resize");flowplayer(function(api,root){api.bind("ready",function(){if(/Chrome/.test(navigator.userAgent)&&parseFloat(/Chrome\/(\d\d)/.exec(navigator.userAgent)[1],10)>54){if(api.video.subtitles){jQuery(root).addClass("chrome55fix-subtitles")}else{jQuery(root).addClass("chrome55fix")}}});root=jQuery(root);var image_src=root.css("background-image");if(image_src){image_src=image_src.replace(/url\((['"])?(.*?)\1\)/gi,"$2").split(",");if(!image_src||!image_src[0].match(/^(https?:)?\/\//))return;var image=new Image;image.src=image_src[0];var image_ratio=image.height/image.width;var player_ratio=root.height()/root.width();var ratio_diff=Math.abs(player_ratio-image_ratio);if(ratio_diff<.05){root.css("background-size","cover")}}});(function($){$(window).on("resize",function(){var iframe=$("iframe[id][src][height][width]");iframe.each(function(){if($(this).attr("id").match(/(fv_vimeo_)|(fv_ytplayer_)/)&&$(this).width()<=$(this).attr("width"))$(this).height($(this).width()*$(this).attr("height")/$(this).attr("width"))});var wistia=jQuery(".wistia_embed");wistia.each(function(){$(this).height($(this).width()*$(this).data("ratio"))})}).trigger("resize")})(jQuery);jQuery(document).on("tabsactivate",".fv_flowplayer_tabs_content",function(event,ui){var oldPlayer=jQuery(ui.oldPanel).find(".flowplayer").data("flowplayer");if(typeof oldPlayer!="undefined"){oldPlayer.pause()}var objPlayer=jQuery(".flowplayer",ui.newPanel);var api=objPlayer.data("flowplayer");api.load()});flowplayer(function(api,root){root=jQuery(root);var bean=flowplayer.bean;if(root.hasClass("is-audio")){bean.off(root[0],"mouseenter");bean.off(root[0],"mouseleave");root.removeClass("is-mouseout");root.addClass("fixed-controls").addClass("is-mouseover");api.on("error",function(e,api,error){jQuery(".fp-message",root).html(jQuery(".fp-message",root).html().replace(/video/,"audio"))});root.on("click",function(e){if(!api.ready){e.preventDefault();e.stopPropagation();api.load()}})}});flowplayer(function(api,root){if(!api.conf.fv_chromecast)return;if(!window["__onGCastApiAvailable"]){jQuery.getScript({url:"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js",cache:true});window["__onGCastApiAvailable"]=function(loaded){if(!loaded)return;initialize()}}var conf=api.conf.chromecast||{},session,timer,trigger,bean=flowplayer.bean,common=flowplayer.common,waiting_for_seek=false;function initialize(){var applicationId,sessionRequest,apiConfig;applicationId=conf.applicationId||chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID;sessionRequest=new chrome.cast.SessionRequest(applicationId);apiConfig=new chrome.cast.ApiConfig(sessionRequest,sessionListener,receiverListener);chrome.cast.initialize(apiConfig,onInitSuccess,onError)}function sessionListener(){}function receiverListener(ev){console.log("FV Player: Chromecast listener",ev);if(ev!==chrome.cast.ReceiverAvailability.AVAILABLE)return;flowplayer.conf.chromecast_available=true}function onInitSuccess(){}function onError(){console.log("chromecast onError")}function createUIElements(){var btnContainer=common.find(".fp-header",root)[0];if(!btnContainer)return;common.find(".fp-chromecast",btnContainer).forEach(common.removeNode);common.find(".fp-chromecast-engine",root).forEach(common.removeNode);trigger=common.createElement("a",{class:"fp-chromecast fp-icon",title:"Play on Cast device"});btnContainer.appendChild(trigger);var chromeCastEngine=common.createElement("div",{class:"fp-chromecast-engine"}),chromeCastStatus=common.createElement("p",{class:"fp-chromecast-engine-status"}),chromeCastIcon=common.createElement("p",{class:"fp-chromecast-engine-icon"});chromeCastEngine.appendChild(chromeCastIcon);chromeCastEngine.appendChild(chromeCastStatus);var engine=common.find(".fp-engine",root)[0];if(!engine)common.prepend(common.find(".fp-player",root)[0]||root,chromeCastEngine);else engine.parentNode.insertBefore(chromeCastEngine,engine)}function destroy(){clearInterval(timer);timer=null;api.release();common.toggleClass(root,"is-chromecast",false);common.toggleClass(trigger,"fp-active",false)}function get_media(){var media=false;var sources=api.video.sources_fvqs||api.video.sources;for(var i in sources){var type=sources[i].type;if(type=="video/mp4"||type=="video/fv-mp4"||type=="application/dash+xml"){media=sources[i];break}}if(!media){for(var i in sources){if(sources[i].type=="application/x-mpegurl"){media=sources[i];break}}}if(api.video.fvhkey&&!api.conf.hls_cast)return false;if(media){var top_quality=false,mp4_qualities=["fullhd","hd","md","sd"];for(var quality in mp4_qualities){var re=new RegExp("-"+mp4_qualities[quality]);for(var i in api.video.sources_fvqs){var source=api.video.sources_fvqs[i];if(source.src.match(re)&&source.type=="video/mp4"){top_quality=source;break}}if(top_quality){media=top_quality;break}}}return media}function load_media(){var media=get_media();if(!media){return false}var cast_subtitles=[];if(api.video.subtitles){api.video.subtitles.forEach(function(v,k){if(v.src.match(/\.srt/)){console.log("FV Player: Chromecast doesn't support SRT subtitles")}var subtitles=new chrome.cast.media.Track(k,chrome.cast.media.TrackType.TEXT);subtitles.trackContentId=v.src;subtitles.trackContentType="text/vtt";subtitles.subtype=chrome.cast.media.TextTrackType.SUBTITLES;subtitles.name=v.label;subtitles.language=v.srclang+"-"+k,subtitles.customData=null;cast_subtitles.push(subtitles)})}var mediaInfo=new chrome.cast.media.MediaInfo(media.src,media.type);mediaInfo.tracks=cast_subtitles;var request=new chrome.cast.media.LoadRequest(mediaInfo);if(!api.live){request.currentTime=api.video.time}clearInterval(timer);timer=false;session.loadMedia(request,onMediaDiscovered,function onMediaError(e){console.log("onMediaError",e)})}function onMediaDiscovered(chromecast){switch_tracks(chromecast);chromecast.addUpdateListener(function(alive){if(!session)return;timer=timer||setInterval(function(){api.trigger("progress",[api,chromecast.getEstimatedTime()]);chromecast.activeTrackIds.forEach(function(track_id){jQuery.each(chromecast.media.tracks,function(k,v){if(v.trackId==track_id&&v.type=="AUDIO"){var found=hilight_audio_track("data-audio",v.language);if(!found){hilight_audio_track("data-lang",v.language)}return false}})})},500);if(alive){common.toggleClass(root,"is-chromecast",true);common.toggleClass(trigger,"fp-active",true);api.hijack({pause:function(){console.log("hijacked pause!");chromecast.pause()},resume:function(){if(api.finished){clearInterval(timer);timer=null;api.release();load_media();return}chromecast.play()},seek:function(time){var req=new chrome.cast.media.SeekRequest;req.currentTime=time;chromecast.seek(req)}})}var playerState=chromecast.playerState;if(api.paused&&playerState===chrome.cast.media.PlayerState.PLAYING)api.trigger("resume",[api]);if(api.playing&&playerState===chrome.cast.media.PlayerState.PAUSED)api.trigger("pause",[api]);if(api.seeking&&playerState===chrome.cast.media.PlayerState.BUFFERING){waiting_for_seek=true}if(api.seeking&&playerState===chrome.cast.media.PlayerState.PLAYING&&waiting_for_seek){waiting_for_seek=false;api.trigger("seek",[api])}if(playerState==chrome.cast.media.PlayerState.IDLE&&chromecast.idleReason==chrome.cast.media.IdleReason.FINISHED){api.trigger("finish",[api])}common.toggleClass(root,"is-loading",playerState===chrome.cast.media.PlayerState.BUFFERING)})}api.bind("ready",function(e,api,video){if(session){if(get_media()){api.one("progress",function(e,api){api.release();api.pause();api.mute(false,true);load_media()});api.mute(true,true)}else{session.stop();session=null;destroy();jQuery(trigger).hide()}return}if(!flowplayer.conf.chromecast_available)return;if(get_media()){createUIElements();jQuery(trigger).show()}else{FV_Flowplayer_Pro.log("FV Player: Can't find media source suitable for Chromecast!");jQuery(trigger).hide()}});bean.on(root,"click",".fp-chromecast",function(ev){ev.preventDefault();if(session){api.trigger("pause",[api]);if(session.media[0].media){var seek=session.media[0].getEstimatedTime();setTimeout(function(){api.seek(seek)},0)}session.stop();session=null;destroy();return}if(api.playing)api.pause();chrome.cast.requestSession(function(s){jQuery(root).addClass("is-loading");session=s;var receiverName=session.receiver.friendlyName;common.html(common.find(".fp-chromecast-engine-status",root)[0],"Playing on device "+receiverName);load_media()},function(err){console.error("requestSession error",err)})});bean.on(root,"click",".fv-fp-hls-menu [data-audio], .fp-subtitle-menu [data-subtitle-index]",function(){if(session&&session.media[0].media){switch_tracks(session.media[0]);return false}});jQuery(window).on("unload",function(){if(session){session.stop()}});function hilight_audio_track(attr,chromecast_language){var audio_tracks_menu=jQuery(root).find(".fv-fp-hls-menu a"),found=false;audio_tracks_menu.each(function(k,el){if(jQuery(el).attr(attr)===chromecast_language){jQuery(el).addClass("fp-selected");found=true}else{jQuery(el).removeClass("fp-selected")}});return found}function switch_tracks(chromecast){console.log(chromecast.media.tracks);var audio=jQuery(root).find(".fv-fp-hls-menu [data-audio].fp-selected").data("audio"),audio_lang=jQuery(root).find(".fv-fp-hls-menu [data-audio].fp-selected").data("lang"),subtitle_index=jQuery(root).find(".fp-subtitle-menu [data-subtitle-index].fp-selected").data("subtitle-index"),subtitles=subtitle_index>-1?api.video.subtitles[subtitle_index].srclang:false;var audio_found=false,subtitles_found=false,tracks_selected=[];jQuery.each(chromecast.media.tracks,function(k,v){if(v.language==audio&&v.type=="AUDIO"){audio_found=v}if(v.language==subtitles+"-"+subtitle_index&&v.type=="TEXT"){subtitles_found=v}});if(!audio_found){jQuery.each(chromecast.media.tracks,function(k,v){if(v.language==audio_lang&&v.type=="AUDIO"){audio_found=v;return false}})}var debug_log="";if(audio_found){tracks_selected.push(audio_found.trackId);debug_log+=audio_found.language+" audio"}if(subtitles_found){tracks_selected.push(subtitles_found.trackId);if(debug_log)debug_log+=" ";debug_log+=subtitles_found.language+" subtitles"}if(tracks_selected){var request=new chrome.cast.media.EditTracksInfoRequest(tracks_selected);chromecast.editTracksInfo(request,function(){console.log("FV Player: Chromecast "+debug_log+" loaded")},function(){console.log("FV Player: Chromecast "+debug_log+" failed")})}}});jQuery(document).on("mfpClose",function(){if(typeof jQuery(".flowplayer").data("flowplayer")!="undefined")jQuery(".flowplayer").data("flowplayer").unload()});jQuery(document).on("click",".vc_tta-tab a",function(){var api=jQuery(".flowplayer.is-playing").data("flowplayer");if(api)api.pause()});flowplayer(function(api,root){root=jQuery(root);api.bind("ready",function(){setTimeout(function(){var video=jQuery("video",root);if(video.length>0){video.prop("autoplay",false)}},100);root.find("video.fp-engine").addClass("intrinsic-ignore")})});jQuery(".flowplayer").on("ready",function(e,api){if(/BB10/.test(navigator.userAgent)){api.fullscreen()}});var fv_flowplayer_safety_resize_arr=Array();function fv_flowplayer_safety_resize(){var fv_flowplayer_safety_resize_init=false;jQuery(".flowplayer").each(function(){if(!jQuery(this).is(":visible")||jQuery(this).hasClass("lightboxed")||jQuery(this).hasClass("lightbox-starter")||jQuery(this).hasClass("is-audio"))return;if(jQuery(this).width()<30||jQuery(this).height()<20){fv_flowplayer_safety_resize_init=true;var el=jQuery(this);while(jQuery(el).width()<30||jQuery(el).width()==jQuery(this).width()){if(jQuery(el).parent().length==0)break;el=jQuery(el).parent()}jQuery(this).width(jQuery(el).width());jQuery(this).height(parseInt(jQuery(this).width()*jQuery(this).attr("data-ratio")));fv_flowplayer_safety_resize_arr[jQuery(this).attr("id")]=el}});if(fv_flowplayer_safety_resize_init){jQuery(window).resize(function(){jQuery(".flowplayer").each(function(){if(jQuery(this).hasClass("lightboxed")||jQuery(this).hasClass("lightbox-starter"))return;if(fv_flowplayer_safety_resize_arr[jQuery(this).attr("id")]){jQuery(this).width(fv_flowplayer_safety_resize_arr[jQuery(this).attr("id")].width());jQuery(this).height(parseInt(jQuery(this).width()*jQuery(this).attr("data-ratio")))}})})}}if(typeof flowplayer.conf.safety_resize!="undefined"&&flowplayer.conf.safety_resize){jQuery(document).ready(function(){setTimeout(function(){fv_flowplayer_safety_resize()},10)})}var isIE11=!!navigator.userAgent.match(/Trident.*rv[ :]*11\./);if(isIE11){jQuery(document).ready(function(){jQuery(".fp-waiting").hide()});flowplayer(function(api,root){api.bind("load",function(e){jQuery(e.currentTarget).find(".fp-waiting").show()}).bind("beforeseek",function(e){jQuery(e.currentTarget).find(".fp-waiting").show()}).bind("progress",function(e){jQuery(e.currentTarget).find(".fp-waiting").hide()}).bind("seek",function(e){jQuery(e.currentTarget).find(".fp-waiting").hide()}).bind("fullscreen",function(e){jQuery("#wpadminbar").hide()}).bind("fullscreen-exit",function(e){jQuery("#wpadminbar").show()})})}if(flowplayer.support.browser&&flowplayer.support.browser.msie&&parseInt(flowplayer.support.browser.version,10)<9){jQuery(".flowplayer").each(function(){jQuery(this).css("width",jQuery(this).css("max-width"));jQuery(this).css("height",jQuery(this).css("max-height"))})}if(location.href.match(/elementor-preview=/)){console.log("FV Player: Elementor editor is active");setInterval(fv_player_load,1e3)}else if(location.href.match(/brizy-edit-iframe/)){console.log("FV Player: Brizy editor is active");setInterval(fv_player_load,1e3)}if(window.DELEGATE_NAMES){flowplayer(function(api,root){fv_player_notice(root,fv_flowplayer_translations.chrome_extension_disable_html5_autoplay)})}flowplayer(function(api,root){flowplayer.bean.off(root,"contextmenu")});if(location.href.match(/elementor-preview=/)){console.log("FV Player: Elementor editor is active");setInterval(fv_player_load,1e3)}flowplayer(function(player,root){root=jQuery(root);if(typeof root.data("fv-embed")=="undefined"||!root.data("fv-embed")||root.data("fv-embed")=="false")return;player.embedCode=function(){var video=player.video;var width=root.width();var height=root.height();height+=2;if(root.hasClass("has-chapters")||root.hasClass("has-transcript")){height+=300}if(jQuery(".fp-playlist-external[rel="+root.attr("id")+"]").length>0){height+=150+20}var link=root.data("fv-embed")+"#"+fv_player_get_video_link_hash(player);return'<iframe src="'+link+'" allowfullscreen width="'+width+'" height="'+height+'" frameborder="0" style="max-width:100%"></iframe>'}});jQuery(document).on("click",".flowplayer .embed-code-toggle",function(){var root=jQuery(this).closest(".flowplayer");if(typeof fv_player_editor_conf!="undefined"){fv_player_notice(root,fv_player_editor_translations.embed_notice,2e3);return false}var button=jQuery(this);var player=button.parents(".flowplayer");var api=player.data("flowplayer");if(typeof api.embedCode=="function"){player.find(".embed-code textarea").val(api.embedCode())}fv_player_clipboard(player.find(".embed-code textarea").val(),function(){fv_player_notice(player,fv_flowplayer_translations.embed_copied,2e3)},function(){button.parents(".fvp-share-bar").find(".embed-code").toggle();button.parents(".fvp-share-bar").toggleClass("visible")});return false});flowplayer(function(player,root){if(jQuery(root).data("fullscreen")==false){return}player.one("ready",function(e,api,video){if(jQuery(root).find(".fp-fullscreen").length==0){jQuery(root).find(".fp-header").append('<a class="fp-fullscreen fp-icon"></a>')}});var FS_ENTER="fullscreen",FS_EXIT="fullscreen-exit",FS_SUPPORT=flowplayer.support.fullscreen,win=window,scrollX,scrollY,bean=flowplayer.bean;player.fullscreen=function(flag){if(player.disabled)return;var video=common.find("video.fp-engine",root)[0];if(flowplayer.conf.native_fullscreen&&video&&flowplayer.support.iOS){player.trigger(FS_ENTER,[player]);bean.on(document,"webkitfullscreenchange.nativefullscreen",function(){if(document.webkitFullscreenElement!==video)return;bean.off(document,".nativefullscreen");bean.on(document,"webkitfullscreenchange.nativefullscreen",function(){if(document.webkitFullscreenElement)return;bean.off(document,".nativefullscreen");player.trigger(FS_EXIT,[player])})});video.webkitEnterFullScreen();bean.one(video,"webkitendfullscreen",function(){bean.off(document,"fullscreenchange.nativefullscreen");player.trigger(FS_EXIT,[player]);common.prop(video,"controls",true);common.prop(video,"controls",false)});return}var wrapper=jQuery(root).find(".fp-player")[0];if(flag===undefined)flag=!player.isFullscreen;if(flag){scrollY=win.scrollY;scrollX=win.scrollX}if(FS_SUPPORT){if(flag){["requestFullScreen","webkitRequestFullScreen","mozRequestFullScreen","msRequestFullscreen"].forEach(function(fName){if(typeof wrapper[fName]==="function"){wrapper[fName]({navigationUI:"hide"});if(fName==="webkitRequestFullScreen"&&!document.webkitFullscreenElement){wrapper[fName]()}}})}else{["exitFullscreen","webkitCancelFullScreen","mozCancelFullScreen","msExitFullscreen"].forEach(function(fName){if(typeof document[fName]==="function"){document[fName]()}})}}else{player.trigger(flag?FS_ENTER:FS_EXIT,[player])}return player};var lastClick,common=flowplayer.common;player.on("mousedown.fs",function(){if(+new Date-lastClick<150&&player.ready)player.fullscreen();lastClick=+new Date});player.on(FS_ENTER,function(){common.addClass(root,"is-fullscreen");common.toggleClass(root,"fp-minimal-fullscreen",common.hasClass(root,"fp-minimal"));common.removeClass(root,"fp-minimal");if(!FS_SUPPORT)common.css(root,"position","fixed");player.isFullscreen=true}).on(FS_EXIT,function(){var oldOpacity;common.toggleClass(root,"fp-minimal",common.hasClass(root,"fp-minimal-fullscreen"));common.removeClass(root,"fp-minimal-fullscreen");if(!FS_SUPPORT&&player.engine==="html5"){oldOpacity=root.css("opacity")||"";common.css(root,"opacity",0)}if(!FS_SUPPORT)common.css(root,"position","");common.removeClass(root,"is-fullscreen");if(!FS_SUPPORT&&player.engine==="html5")setTimeout(function(){root.css("opacity",oldOpacity)});player.isFullscreen=false;if(player.engine.engineName!="fvyoutube"){win.scrollTo(scrollX,scrollY)}}).on("unload",function(){if(player.isFullscreen)player.fullscreen()});player.on("shutdown",function(){FULL_PLAYER=null;common.removeNode(wrapper)})});flowplayer(function(api,root){root=jQuery(root);if(flowplayer.conf.wpadmin||jQuery(root).hasClass("is-audio"))return;var playlist=jQuery(".fp-playlist-external[rel="+root.attr("id")+"]"),playlist_with_fullscreen=playlist.hasClass("fp-playlist-season")||playlist.hasClass("fp-playlist-polaroid");fsforce=root.data("fsforce")==true;if(root.data("fullscreen")==false){return}if(flowplayer.conf.mobile_force_fullscreen&&flowplayer.support.fvmobile||!flowplayer.support.fullscreen&&fsforce||playlist_with_fullscreen){if(!flowplayer.support.fullscreen){api.bind("ready",function(){if(api.video.vr)return;api.fullscreen(true)})}root.on("click",function(){if(!api.ready||api.paused)api.fullscreen(true)});jQuery("[rel="+root.attr("id")+"] a").on("click",function(e){if(!api.isFullscreen){api.fullscreen();api.resume()}});api.on("resume",function(){if(api.video.vr)return;if(!api.isFullscreen)api.fullscreen()});api.on("finish",function(){if(api.conf.playlist.length==0||api.conf.playlist.length-1==api.video.index)api.fullscreen(false)}).on("fullscreen",function(a,api){root.addClass("forced-fullscreen")}).on("fullscreen-exit",function(a,api){api.pause();root.removeClass("forced-fullscreen")})}else if(fsforce){var position,unload=root.find(".fp-unload"),is_closing=false;api.isFakeFullscreen=false;unload.show();root.on("click",function(e){if(!api.ready&&e.target!=unload[0])api.fakeFullscreen(true)});unload.on("click",function(e){if(api.ready){api.fullscreen(false)}else if(api.loading){is_closing=true;api.one("resume",function(e){is_closing=false;api.pause()})}api.fakeFullscreen(false);return false});jQuery("[rel="+root.attr("id")+"] a").on("click",function(e){if(!api.isFakeFullscreen){api.fakeFullscreen();api.resume()}});api.on("resume",function(){if(!is_closing&&!api.isFakeFullscreen)api.fakeFullscreen()}).on("finish",function(){if(api.conf.playlist.length==0||api.conf.playlist.length-1==api.video.index)api.fakeFullscreen(false)}).on("fullscreen",function(a,api){root.removeClass("fake-fullscreen")}).on("fullscreen-exit",function(a,api){if(api.isFakeFullscreen)api.fakeFullscreen(true,true)}).on("unload",function(a,api){});api.fakeFullscreen=function(flag,force){if(!force&&(api.isFakeFullscreen==flag||api.disabled))return;if(position===undefined)position=root.css("position");if(flag===undefined)flag=!api.isFakeFullscreen;api.isFakeFullscreen=flag;api.trigger(flag?"fakefullscreen":"fakefullscreen-exit",[api]);root.toggleClass("is-fullscreen fake-fullscreen forced-fullscreen",flag);if(flag){root.css("position","fixed")}else{root.css("position",position)}}}if(flowplayer.support.android&&flowplayer.conf.mobile_landscape_fullscreen&&window.screen&&window.screen.orientation){api.on("fullscreen",function(a,api){if(typeof api.video.width!="undefined"&&typeof api.video.height!="undefined"&&(api.video.width!=0&&api.video.height!=0&&api.video.width<api.video.height)){screen.orientation.lock("portrait-primary")}else{screen.orientation.lock("landscape-primary")}})}});flowplayer(function(api,root){root=jQuery(root);var hlsjs,player,audioUXGroup,audioGroups,hls_audio_button,hls_audio_menu,mse=window.MediaSource||window.WebKitMediaSource;flowplayer.engine("hlsjs-lite").plugin(function(params){hlsjs=params.hls});api.bind("ready",function(e,api){removeAudioMenu();if(hlsjs&&api.video.type=="application/x-mpegurl"){parseAudioTracksHlsJs(hlsjs);createAudioMenu()}});api.one("progress",function(){if(api.engine.engineName=="html5"&&api.video.type=="application/x-mpegurl"){parseAudioTracksSafari();createAudioMenu()}});function getVideoTagAudioTracks(){var video=root.find("video");if(video.length&&video[0].audioTracks){return video[0].audioTracks}return[]}function hilightAudioTrack(audioTrack){if(!audioTrack.name)audioTrack.name=audioTrack.label;root.find(".fv-fp-hls-menu a").each(function(k,el){jQuery(el).toggleClass("fp-selected",jQuery(el).attr("data-audio")===audioTrack.name)})}function createAudioMenu(){if(!audioUXGroup||audioUXGroup.length<2){return}hls_audio_button=jQuery('<strong class="fv-fp-hls">'+fv_flowplayer_translations.audio_button+"</strong>");hls_audio_menu=jQuery('<div class="fp-menu fv-fp-hls-menu"></div>').insertAfter(root.find(".fp-controls"));hls_audio_menu.append("<strong>"+fv_flowplayer_translations.audio_menu+"</strong>");audioUXGroup.forEach(function(audioTrack){hls_audio_menu.append('<a data-audio="'+audioTrack.name+'" data-lang="'+audioTrack.lang+'">'+audioTrack.name+"</a>")});hls_audio_button.insertAfter(root.find(".fp-controls .fp-volume")).on("click",function(e){e.preventDefault();e.stopPropagation();if(hls_audio_menu.hasClass("fp-active")){api.hideMenu(hls_audio_menu[0])}else{root.click();api.showMenu(hls_audio_menu[0])}});jQuery("a",hls_audio_menu).on("click",function(e){var adata=e.target.getAttribute("data-audio");if(hlsjs){var gid=hlsjs.audioTracks[hlsjs.audioTrack].groupId;var atrack=hlsjs.audioTracks.filter(function(at){return at.groupId===gid&&(at.name===adata||at.lang===adata)})[0];hlsjs.audioTrack=atrack.id;hilightAudioTrack(atrack)}else{var tracks=getVideoTagAudioTracks();for(var i in tracks){if(!tracks.hasOwnProperty(i))continue;if(tracks[i].label==adata){tracks[i].enabled=true;hilightAudioTrack(tracks[i])}}}});if(hlsjs){hilightAudioTrack(hlsjs.audioTracks[hlsjs.audioTrack])}else{var tracks=getVideoTagAudioTracks();for(var i in tracks){if(!tracks.hasOwnProperty(i))continue;if(tracks[i].enabled){hilightAudioTrack(tracks[i])}}}}function removeAudioMenu(){jQuery(hls_audio_menu).remove();jQuery(hls_audio_button).remove()}function parseAudioTracksHlsJs(data){audioGroups=[];audioUXGroup=[];data.levels.forEach(function(level){var agroup=level.attrs.AUDIO;if(agroup&&audioGroups.indexOf(agroup)<0){audioGroups.push(agroup)}if(audioGroups.length){audioUXGroup=data.audioTracks.filter(function(audioTrack){return audioTrack.groupId===audioGroups[0]})}})}function parseAudioTracksSafari(){audioGroups=[];audioUXGroup=[];var tracks=getVideoTagAudioTracks();for(var i in tracks){if(!tracks.hasOwnProperty(i))continue;audioUXGroup.push({id:tracks[i].id,name:tracks[i].label})}}});flowplayer(function(api,root){var store_engine_pos=-1;var store_engine=false;api.on("error",function(e,api,err){if(err.code!=4||api.engine.engineName!="hlsjs")return;console.log("FV Player: HLSJS failed to play the video, switching to Flash HLS");api.error=api.loading=false;jQuery(root).removeClass("is-error");jQuery(flowplayer.engines).each(function(k,v){if(flowplayer.engines[k].engineName=="hlsjs"){store_engine_pos=k;store_engine=flowplayer.engines[k];delete flowplayer.engines[k]}});var index=typeof api.video.index!="undefined"?api.video.index:0;var video=index>0?api.conf.playlist[index].sources:api.conf.clip.sources;video.index=index;api.load({sources:video});api.bind("unload error",function(){flowplayer.engines[store_engine_pos]=store_engine})})});flowplayer(function(api,root){var initialDelay=30,continueDelay=10,useDelay=initialDelay,retryLabel=fv_flowplayer_translations.live_stream_retry,timer;api.clearLiveStreamCountdown=function(){if(timer){clearInterval(timer);api.error=api.loading=false;jQuery(root).removeClass("is-error");jQuery(root).find(".fp-message.fp-shown").remove();api.unload()}};api.conf.flashls={manifestloadmaxretry:2};api.on("ready",function(){useDelay=initialDelay;retryLabel=fv_flowplayer_translations.live_stream_retry}).on("progress",function(){useDelay=continueDelay;retryLabel=fv_flowplayer_translations.live_stream_continue;clearInterval(timer)});api.on("error",function(e,api,err){setTimeout(function(){if(!api.conf.clip.live&&!api.conf.live&&!(err.video&&err.video.src.match(/\/\/vimeo.com\/event\//)))return;var delay=useDelay;if(api.conf.clip.streaming_time){delay=api.conf.clip.streaming_time-Math.floor(Date.now()/1e3)}else if(api.conf.clip.live_starts_in){delay=api.conf.clip.live_starts_in}var startLabel=fv_flowplayer_translations.live_stream_starting.replace(/%d/,secondsToDhms(delay));retryLabel=retryLabel.replace(/%d/,secondsToDhms(delay));var message=api.conf.clip.live_starts_in?startLabel:retryLabel;clearInterval(timer);if(err.code===1||err.code===2||err.code===4){root.className+=" is-offline";if(flowplayer.support.flashVideo){api.one("flashdisabled",function(){root.querySelector(".fp-flash-disabled").style.display="none"})}var messageElement=root.querySelector(".fp-ui .fp-message");messageElement.innerHTML=message;var reload_delay=delay>300?300:delay;timer=setInterval(function(){reload_delay-=1;delay-=1;if(reload_delay>0&&messageElement){messageElement.querySelector("span").innerHTML=secondsToDhms(delay)}else{clearInterval(timer);if(!api.error){return}api.error=api.loading=false;messageElement=root.querySelector(".fp-ui .fp-message");if(messageElement){root.querySelector(".fp-ui").removeChild(messageElement)}root.className=root.className.replace(/\bis-(error|offline)\b/g,"");api.load()}},1e3)}},1)});function secondsToDhms(seconds){seconds=Number(seconds);var d=Math.floor(seconds/(3600*24));var h=Math.floor(seconds%(3600*24)/3600);var m=Math.floor(seconds%3600/60);var s=Math.floor(seconds%60);var t=fv_flowplayer_translations;var output=d>0?d==1?t.duration_1_day.replace(/%s/,d):t.duration_n_days.replace(/%s/,d):"";if(output&&h>0)output+=", ";output+=h>0?h==1?t.duration_1_hour.replace(/%s/,h):t.duration_n_hours.replace(/%s/,h):"";if(output&&m>0)output+=", ";output+=m>0?m==1?t.duration_1_minute.replace(/%s/,m):t.duration_n_minutes.replace(/%s/,m):"";if(output&&s>0)output+=t.and;output+=s>0?s==1?t.duration_1_second.replace(/%s/,s):t.duration_n_seconds.replace(/%s/,s):"";return output}});flowplayer(function(api,root){root=jQuery(root);var hlsjs;flowplayer.engine("hlsjs-lite").plugin(function(params){hlsjs=params.hls});api.on("ready",function(e,api){if(hlsjs&&api.conf.playlist.length&&api.engine.engineName!="hlsjs-lite"){hlsjs.destroy()}})});flowplayer(function(api,root){if(!flowplayer.support.browser.safari&&!flowplayer.support.iOS)return;root=jQuery(root);var video_tag=false,did_start_playing=false,are_waiting_already=0;api.on("ready",function(e,api,video){are_waiting_already=0;did_start_playing=false;if(api.engine.engineName=="html5"&&video.src.match(/\?/)){video_tag=root.find("video");if(!video_tag.data("fv-ios-recovery")){video_tag.on("waiting",wait_for_stalled);video_tag.data("fv-ios-recovery",true)}api.one("progress",function(){did_start_playing=true})}});api.bind("beforeseek",wait_for_stalled);function debug(e){console.log("FV Player: iOS video element: "+e.type)}function wait_for_stalled(){if(!did_start_playing){return}if(video_tag&&api.engine.engineName=="html5"){are_waiting_already++;if(are_waiting_already>1){if(are_waiting_already>3){console.log("FV Player: iOS video element needs a push, triggering 'stalled'");video_tag.trigger("stalled")}return}console.log("FV Player: iOS video element will trigger error after 'stalled' arrives");video_tag.one("stalled",function(){var time=api.video.time;if(api.video.type.match(/video\//)){console.log("FV Player: Running check of video file...");var test_video=document.createElement("video");test_video.src=api.video.src;test_video.onloadedmetadata=function(){are_waiting_already=0;console.log("FV Player: Video link works")};test_video.onerror=function(){console.log("FV Player: Video link issue!");if(are_waiting_already>0){api.trigger("error",[api,{code:4,video:api.video}])}};return}setTimeout(function(){console.log(api.video.time,time);if(api.video.time!=time){console.log("FV Player: iOS video element continues playing, no need for error");return}if(api.paused){console.log("FV Player: iOS video element paused, no need for error");return}api.trigger("error",[api,{code:4,video:api.video}])},5e3)})}}});!function(e){var n=!1;if("function"==typeof define&&define.amd&&(define(e),n=!0),"object"==typeof exports&&(module.exports=e(),n=!0),!n){var o=window.Cookies,t=window.Cookies=e();t.noConflict=function(){return window.Cookies=o,t}}}(function(){function e(){for(var e=0,n={};e<arguments.length;e++){var o=arguments[e];for(var t in o)n[t]=o[t]}return n}function n(o){function t(n,r,i){var c;if("undefined"!=typeof document){if(arguments.length>1){if("number"==typeof(i=e({path:"/"},t.defaults,i)).expires){var a=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*i.expires),i.expires=a}i.expires=i.expires?i.expires.toUTCString():"";try{c=JSON.stringify(r),/^[\{\[]/.test(c)&&(r=c)}catch(e){}r=o.write?o.write(r,n):encodeURIComponent(r+"").replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),n=(n=(n=encodeURIComponent(n+"")).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape);var s="";for(var f in i)i[f]&&(s+="; "+f,!0!==i[f]&&(s+="="+i[f]));return document.cookie=n+"="+r+s}n||(c={});for(var p=document.cookie?document.cookie.split("; "):[],d=/(%[0-9A-Z]{2})+/g,u=0;u<p.length;u++){var l=p[u].split("="),C=l.slice(1).join("=");this.json||'"'!==C.charAt(0)||(C=C.slice(1,-1));try{var m=l[0].replace(d,decodeURIComponent);if(C=o.read?o.read(C,m):o(C,m)||C.replace(d,decodeURIComponent),this.json)try{C=JSON.parse(C)}catch(e){}if(n===m){c=C;break}n||(c[m]=C)}catch(e){}}return c}}return t.set=t,t.get=function(e){return t.call(t,e)},t.getJSON=function(){return t.apply({json:!0},[].slice.call(arguments))},t.defaults={},t.remove=function(n,o){t(n,"",e(o,{expires:-1}))},t.withConverter=n,t}return n(function(){})});flowplayer.bean.off(document,"keydown.fp");flowplayer(function(api,root){var bean=flowplayer.bean;if(!api.conf.keyboard)return;bean.on(root,"mouseenter mouseleave",function(e){fv_player_focused=!api.disabled&&e.type=="mouseover"?api:0;if(fv_player_focused)fv_player_focusedRoot=root});api.bind("ready",function(e,api,video){if(video.subtitles&&video.subtitles.length>0){var help=jQuery(root).find(".fp-help").html();help+='<div class="fp-help-section fp-help-subtitles"><p><em>c</em>cycle through subtitles</p></div>';jQuery(root).find(".fp-help").html(help)}else{jQuery(root).find(".fp-help-subtitles").remove()}})});flowplayer.bean.on(document,"keydown.fp",function(e){if(typeof fv_player_focused=="undefined")return;var api=fv_player_focused,focusedRoot=api?fv_player_focusedRoot:false,common=flowplayer.common;var el=api&&!api.disabled?api:0,metaKeyPressed=e.ctrlKey||e.metaKey||e.altKey,key=e.which,conf=el&&el.conf;if(common.hasClass(focusedRoot,"no-controlbar")||common.hasClass(focusedRoot,"is-cva"))return;if(!el||!conf.keyboard||el.disabled)return;if([63,187,191].indexOf(key)!=-1){common.toggleClass(focusedRoot,"is-help");return false}if(key==27&&common.hasClass(focusedRoot,"is-help")){common.toggleClass(focusedRoot,"is-help");return false}if(!metaKeyPressed&&el.ready){e.preventDefault();if(e.shiftKey){if(key==39)el.speed(true);else if(key==37)el.speed(false);else if(key==78)el.next();else if(key==80)el.prev();return}if(key<58&&key>47)return el.seekTo(key-48);switch(key){case 38:case 75:el.volume(el.volumeLevel+.15);break;case 40:case 74:el.volume(el.volumeLevel-.15);break;case 39:case 76:el.seeking=true;el.seek(api.video.time+5);break;case 37:case 72:el.seeking=true;el.seek(api.video.time-5);break;case 190:el.seekTo();break;case 32:el.toggle();break;case 70:if(conf.fullscreen)el.fullscreen();break;case 77:el.mute();break;case 81:el.unload();break;case 67:if(!api.video.subtitles||api.video.subtitles.length==0)break;var current_subtitles=jQuery(focusedRoot).find(".fp-dropdown li.active[data-subtitle-index]").data("subtitle-index");if(typeof current_subtitles=="undefined")current_subtitles=-1;current_subtitles++;if(current_subtitles>api.video.subtitles.length-1){current_subtitles=-1}api.trigger("fv-subtitles-switched");if(current_subtitles>-1){el.loadSubtitles(current_subtitles);fv_player_notice(focusedRoot,fv_flowplayer_translations.subtitles_switched+" "+api.video.subtitles[current_subtitles].label,"fv-subtitles-switched")}else{el.disableSubtitles();fv_player_notice(focusedRoot,fv_flowplayer_translations.subtitles_disabled,"fv-subtitles-switched")}break}}});flowplayer(function(api,root){api.bind("load",function(e,api,data){var player=jQuery(e.currentTarget);if(player.data("live")){var live_check=setTimeout(function(){player.find(".fp-ui").append('<div class="fp-message">'+fv_flowplayer_translations.live_stream_failed+"</div>");player.addClass("is-error")},1e4);jQuery(e.currentTarget).data("live_check",live_check)}}).bind("ready",function(e,api,data){clearInterval(jQuery(e.currentTarget).data("live_check"))}).bind("error",function(e,api,data){var player=jQuery(e.currentTarget);if(player.data("live")){player.find(".fp-message").html(fv_flowplayer_translations.live_stream_failed_2)}})});(function($){flowplayer(function(api,root){if(jQuery(root).hasClass("is-cva"))return;$(document).on("submit","#"+jQuery(root).attr("id")+" .mailchimp-form",function(e){e.preventDefault();$(".mailchimp-response",root).remove();$("input[type=submit]",root).attr("disabled","disabled").addClass("fv-form-loading");var data={action:"fv_wp_flowplayer_email_signup"};$("[name]",this).each(function(){data[this.name]=$(this).val()});$.post(fv_player.ajaxurl,data,function(response){response=JSON.parse(response);$('<div class="mailchimp-response"></div>').insertAfter(".mailchimp-form",root);if(response.text.match(/already subscribed/)){response.status="ERROR"}if(response.status==="OK"){$(".mailchimp-form input[type=text],.mailchimp-form input[type=email]",root).val("");$(".mailchimp-response",root).removeClass("is-fv-error").html(response.text);setTimeout(function(){$(".wpfp_custom_popup",root).fadeOut()},2e3)}else{$(".mailchimp-response",root).addClass("is-fv-error").html(response.text)}$("input[type=submit]",root).removeAttr("disabled").removeClass("fv-form-loading")})})})})(jQuery);function fv_flowplayer_mobile_switch(id){var regex=new RegExp("[\\?&]fv_flowplayer_mobile=([^&#]*)");var results=regex.exec(location.search);if((results!=null&&results[1]=="yes"||(jQuery(window).width()<=480||jQuery(window).height()<=480))&&(results==null||results[1]!="no")){var fv_fp_mobile=false;jQuery("#wpfp_"+id+" video source").each(function(){if(jQuery(this).attr("id")!="wpfp_"+id+"_mobile"){fv_fp_mobile=true;jQuery(this).remove()}});if(fv_fp_mobile){jQuery("#wpfp_"+id).after('<p class="fv-flowplayer-mobile-switch">'+fv_flowplayer_translations.mobile_browser_detected_1+' <a href="'+document.URL+'?fv_flowplayer_mobile=no">'+fv_flowplayer_translations.mobile_browser_detected_2+"</a>.</p>")}}}if(typeof fv_flowplayer_mobile_switch_array!="undefined"){for(var i in fv_flowplayer_mobile_switch_array){if(!fv_flowplayer_mobile_switch_array.hasOwnProperty(i))continue;fv_flowplayer_mobile_switch(i)}}flowplayer(function(api,root){if(!flowplayer.support.touch)return;jQuery.fn.fv_single_double_click=function(single_click_callback,double_click_callback,timeout){return this.each(function(){var clicks=0,self=this;jQuery(this).on("click",function(event){clicks++;if(clicks==1){setTimeout(function(){if(clicks==1){single_click_callback.call(self,event)}else{double_click_callback.call(self,event)}clicks=0},timeout||300)}})})};root=jQuery(root);var left=jQuery('<div class="fv-fp-tap-left"><span>-10s</span></div>'),right=jQuery('<div class="fv-fp-tap-right"><span>+10s</span></div>');left.fv_single_double_click(function(){api.toggle()},function(e){maybe_seek(e,left,api.ready?api.video.time-10:false)});right.fv_single_double_click(function(){api.toggle()},function(e){maybe_seek(e,right,api.ready?api.video.time+10:false)});root.find(".fp-ui").append(left).append(right);function maybe_seek(e,el,time){if(api.ready){api.seek(time);animation(el)}else{api.toggle()}e.preventDefault()}function animation(el){el.addClass("is-active");setTimeout(function(){el.removeClass("is-active")},500)}});flowplayer(function(api,root){root=jQuery(root);var instance_id=root.data("flowplayer-instance-id");flowplayer.audible_instance=-1;api.one("load",function(){setTimeout(function(){api.conf.splash=false},0)});api.on("ready",function(){var is_muted=root.data("volume")==0;if(!is_muted){flowplayer.audible_instance=instance_id}jQuery(".flowplayer[data-flowplayer-instance-id]").each(function(){var player=jQuery(this).data("flowplayer");var current_instance_id=jQuery(this).data("flowplayer-instance-id");if(flowplayer.audible_instance==-1||current_instance_id==flowplayer.audible_instance||current_instance_id==instance_id)return;if(player){if(player.ready){if(api.conf.multiple_playback){if(!is_muted){player.mute(true,true)}}else if(player.playing){player.pause()}}else{player.clearLiveStreamCountdown();player.unload()}}})}).on("mute",function(e,api,muted){if(!muted&&flowplayer.audible_instance!=instance_id){flowplayer(flowplayer.audible_instance).mute(true,true);flowplayer.audible_instance=instance_id}}).on("resume",function(){if(!api.conf.multiple_playback){jQuery(".flowplayer[data-flowplayer-instance-id]").each(function(){if(instance_id==jQuery(this).data("flowplayer-instance-id"))return;var player=jQuery(this).data("flowplayer");if(player&&player.playing){player.pause()}})}})});function fv_flowplayer_browser_ff_m4v(hash){if(flowplayer.support.browser&&flowplayer.support.browser.mozilla&&navigator.appVersion.indexOf("Win")!=-1){jQuery("#wpfp_"+hash).attr("data-engine","flash")}}if(typeof fv_flowplayer_browser_ff_m4v_array!="undefined"){for(var i in fv_flowplayer_browser_ff_m4v_array){if(!fv_flowplayer_browser_ff_m4v_array.hasOwnProperty(i))continue;fv_flowplayer_browser_ff_m4v(i)}}function fv_flowplayer_browser_chrome_fail(hash,sAttributes,sVideo,bAutobuffer){jQuery("#wpfp_"+hash).bind("error",function(e,api,error){if(/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())&&error!=null&&(error.code==3||error.code==4||error.code==5)){api.unload();jQuery("#wpfp_"+hash).attr("id","bad_wpfp_"+hash);jQuery("#bad_wpfp_"+hash).after('<div id="wpfp_'+hash+'" '+sAttributes+' data-engine="flash"></div>');jQuery("#wpfp_"+hash).flowplayer({playlist:[[{mp4:sVideo}]]});if(bAutobuffer){jQuery("#wpfp_"+hash).bind("ready",function(e,api){api.play()})}else{jQuery("#wpfp_"+hash).flowplayer().play(0)}jQuery("#bad_wpfp_"+hash).remove()}})}if(typeof fv_flowplayer_browser_chrome_fail_array!="undefined"){for(var i in fv_flowplayer_browser_chrome_fail_array){if(!fv_flowplayer_browser_chrome_fail_array.hasOwnProperty(i))continue;fv_flowplayer_browser_chrome_fail(i,fv_flowplayer_browser_chrome_fail_array[i]["attrs"],fv_flowplayer_browser_chrome_fail_array[i]["mp4"],fv_flowplayer_browser_chrome_fail_array[i]["auto_buffer"])}}function fv_flowplayer_browser_ie(hash){if(flowplayer.support.browser&&flowplayer.support.browser.msie&&parseInt(flowplayer.support.browser.version,10)>=9||!!navigator.userAgent.match(/Trident.*rv[ :]*11\./)){jQuery("#wpfp_"+hash).attr("data-engine","flash")}}if(typeof fv_flowplayer_browser_ie_array!="undefined"){for(var i in fv_flowplayer_browser_ie_array){if(!fv_flowplayer_browser_ie_array.hasOwnProperty(i))continue;fv_flowplayer_browser_ie(i)}}function fv_flowplayer_browser_chrome_mp4(hash){var match=window.navigator.appVersion.match(/Chrome\/(\d+)\./);if(match!=null){var chrome_ver=parseInt(match[1],10);if(/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())&&chrome_ver<28&&navigator.appVersion.indexOf("Win")!=-1||/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())&&chrome_ver<27&&navigator.appVersion.indexOf("Linux")!=-1&&navigator.userAgent.toLowerCase().indexOf("android")==-1){jQuery("#wpfp_"+hash).attr("data-engine","flash")}}}if(navigator.platform.indexOf("iPhone")!=-1||navigator.platform.indexOf("iPod")!=-1||navigator.platform.indexOf("iPad")!=-1||navigator.userAgent.toLowerCase().indexOf("android")!=-1){flowplayer(function(api,root){api.bind("error",function(e,api,error){if(error.code==10){jQuery(e.target).find(".fp-message").html(fv_flowplayer_translations.unsupported_format)}})})}jQuery(document).ready(function(){if(navigator.platform.indexOf("iPhone")!=-1||navigator.platform.indexOf("iPod")!=-1||navigator.platform.indexOf("iPad")!=-1){jQuery(window).trigger("load")}jQuery(".flowplayer").on("mouseleave",function(){jQuery(this).find(".fvp-share-bar").removeClass("visible");jQuery(this).find(".embed-code").hide()})});if(typeof flowplayer!=="undefined"){flowplayer(function(api,root){root=jQuery(root);var notice=false,hlsjs;flowplayer.engine("hlsjs-lite").plugin(function(params){hlsjs=params.hls});var playlist=api.conf.playlist.length?api.conf.playlist:[api.conf.clip];if(playlist[0].pending_encoding){show_notice(playlist[0])}api.on("load",function(e,api,video){if(video.pending_encoding){show_notice(video);if(hlsjs){hlsjs.destroy()}return false}remove_notice()});function show_notice(video){remove_notice();var title="Video is being processed",message="Please return later to see the actual video in this player.";if(video.pending_encoding_error){title="Video unavailable";message="There was an error in the video encoding."}else if(video.pending_encoding_progress){message+="<br /><br />("+video.pending_encoding_progress+" done)"}notice=jQuery('<div class="fv-player-encoder-video-processing-modal"><div><h2>'+title+"</h2><p>"+message+"</p></div></div");root.append(notice)}function remove_notice(){if(notice){notice.remove()}}})}if(!Date.now){Date.now=function(){return(new Date).getTime()}}(function($){var sendPositionsEvery=60,ajaxCall=null,maxCookieSize=2500,localStorageEnabled=null,cookiePositionsKeyName="video_positions",cookiePlaylistsKeyName="player_playlist_item",tempPositionCookieKeyName="video_positions_tmp",tempPlaylistsCookieKeyName="player_playlist_item_tmp",tempSawCookieKeyName="video_saw_tmp",playPositions=[],playlistIndexes=[],sawVideo=[],getSerialized=function(data){var serialized=JSON.stringify(data),dataSize=getTextByteSize(serialized);if(dataSize>maxCookieSize){while(dataSize>maxCookieSize){for(var i in data){if(!data.hasOwnProperty(i))continue;delete data[i];serialized=JSON.stringify(data);dataSize=getTextByteSize(serialized);break}}}return serialized},getVideoId=function(video){if(video.id){return video.id}var out=typeof video.sources_original!="undefined"&&typeof video.sources_original[0]!="undefined"?video.sources_original[0].src:video.sources[0].src;if(typeof video.sources_original=="undefined"||typeof video.sources_original[0]=="undefined"){out=removeAWSSignatures(out)}return out},getTextByteSize=function(txt){return encodeURIComponent(txt).length},getCookieKey=function(key){return localStorageEnabled?localStorage.getItem(key):Cookies.get(key)},setCookieKey=function(key,value){return localStorageEnabled?localStorage.setItem(key,value):Cookies.set(key,value)},removeCookieKey=function(key){if(localStorageEnabled){localStorage.removeItem(key)}{Cookies.remove(key)}},removeVideoPosition=function(e,api){if(api.video.sources){var video_id=getVideoId(api.video);playPositions[video_id]=0;sawVideo[video_id]=1}},removeAWSSignatures=function(videoURL){return videoURL.replace(/(X-Amz-Algorithm=[^&]+&?)/gm,"").replace(/(X-Amz-Credential=[^&]+&?)/gm,"").replace(/(X-Amz-Date=[^&]+&?)/gm,"").replace(/(X-Amz-Expires=[^&]+&?)/gm,"").replace(/(X-Amz-SignedHeaders=[^&]+&?)/gm,"").replace(/(X-Amz-Signature=[^&]+&?)/gm,"")},sendVideoPositions=function(async,callback){var beaconSupported="sendBeacon"in navigator;if(async!==true){async=false}if(!callback||typeof callback=="undefined"){callback=function(){}}postDataPositions=[];postDataPlaylists=[];for(var video_name in playPositions){if(!playPositions.hasOwnProperty(video_name))continue;postDataPositions.push({name:video_name,position:playPositions[video_name],saw:typeof sawVideo[video_name]!="undefined"?sawVideo[video_name]:false})}for(var player_id in playlistIndexes){if(!playlistIndexes.hasOwnProperty(player_id))continue;postDataPlaylists.push({player:player_id,item:playlistIndexes[player_id]})}if(!postDataPlaylists.length){removeCookieKey(tempPlaylistsCookieKeyName)}if(!postDataPositions.length){removeCookieKey(tempPositionCookieKeyName);removeCookieKey(tempSawCookieKeyName);return}if(flowplayer.conf.is_logged_in=="1"){if(beaconSupported){try{var temp_position_data={},temp_saw_data={},temp_playlist_data={};for(var i in postDataPositions){if(!postDataPositions.hasOwnProperty(i))continue;temp_position_data[postDataPositions[i].name]=postDataPositions[i].position;temp_saw_data[postDataPositions[i].name]=postDataPositions[i].saw}for(var i in postDataPlaylists){if(!postDataPlaylists.hasOwnProperty(i))continue;temp_playlist_data[postDataPlaylists[i].player]=postDataPlaylists[i].item}setCookieKey(tempPositionCookieKeyName,getSerialized(temp_position_data));setCookieKey(tempSawCookieKeyName,getSerialized(temp_saw_data));setCookieKey(tempPlaylistsCookieKeyName,getSerialized(temp_playlist_data))}catch(e){return}var fd=new FormData;fd.append("action","fv_wp_flowplayer_video_position_save");fd.append("videoTimes",encodeURIComponent(JSON.stringify(postDataPositions)));fd.append("playlistItems",encodeURIComponent(JSON.stringify(postDataPlaylists)));navigator.sendBeacon(fv_player.ajaxurl,fd);return false}else{return jQuery.ajax({type:"POST",async:async,url:fv_player.ajaxurl,complete:callback,data:{action:"fv_wp_flowplayer_video_position_save",videoTimes:postDataPositions,playlistItems:postDataPlaylists}})}}else{try{var data_positions=getCookieKey(cookiePositionsKeyName);var data_playlist_item=getCookieKey(cookiePlaylistsKeyName);if(data_positions&&typeof data_positions!=="undefined"){data_positions=JSON.parse(data_positions)}else{data_positions={}}if(data_playlist_item&&typeof data_playlist_item!=="undefined"){data_playlist_item=JSON.parse(data_playlist_item)}else{data_playlist_item={}}for(var i in postDataPositions){if(!postDataPositions.hasOwnProperty(i))continue;data_positions[postDataPositions[i].name]=postDataPositions[i].position}for(var i in postDataPlaylists){if(!postDataPlaylists.hasOwnProperty(i))continue;data_playlist_item[postDataPlaylists[i].player]=postDataPlaylists[i].item}var serialized_positions=JSON.stringify(data_positions),serialized_playlist_items=JSON.stringify(data_playlist_item),dataSize_postions=getTextByteSize(serialized_positions),dataSize_playlist_items=getTextByteSize(serialized_playlist_items);if(dataSize_postions>maxCookieSize){while(dataSize_postions>maxCookieSize){for(var i in data_positions){if(!data_positions.hasOwnProperty(i))continue;delete data_positions[i];serialized_positions=JSON.stringify(data_positions);dataSize_postions=getTextByteSize(serialized_positions);break}}}if(dataSize_playlist_items>maxCookieSize){while(dataSize_playlist_items>maxCookieSize){for(var i in data_positions){if(!data_playlist_item.hasOwnProperty(i))continue;delete data_playlist_item[i];serialized_playlist_items=JSON.stringify(data_playlist_item);dataSize_playlist_items=getTextByteSize(serialized_positions);break}}}setCookieKey(cookiePositionsKeyName,serialized_positions);setCookieKey(cookiePlaylistsKeyName,serialized_playlist_items)}catch(e){return}}return false};flowplayer(function(api,root){if(typeof api.conf.disable_localstorage!="undefined"){return}var $root=jQuery(root),enabled=flowplayer.conf.video_position_save_enable&&$root.data("save-position")!="false"||$root.data("save-position"),progressEventsCount=0,player_id=$root.data("player-id")?$root.data("player-id"):false,item_changed=false,seekIntoPosition=function(e,api){if(api.video&&api.video.live)return;var video_id=getVideoId(api.video),position=api.video.position;if(flowplayer.conf.is_logged_in!="1"){var data=getCookieKey(cookiePositionsKeyName);if(data&&typeof data!=="undefined"){try{data=JSON.parse(data);if(data[video_id]){position=data[video_id]}}catch(e){return}}}if(!!api.get_custom_end&&api.get_custom_end()<position){position=false}if(!!api.get_custom_start&&api.get_custom_start()>0){if(position<api.get_custom_start()){position=false}}api.bind("progress",storeVideoPosition);if(position){seek(position)}},storeVideoPosition=function(e,api){if(api.live){return}if(api.video.sources){var video_id=getVideoId(api.video),position=Math.round(api.video.time);playPositions[video_id]=position;if(api.conf.playlist.length>0){if(player_id)playlistIndexes[player_id]=api.video.index}if(progressEventsCount++>=sendPositionsEvery&&flowplayer.conf.closingPage){if(ajaxCall){ajaxCall.abort()}ajaxCall=sendVideoPositions(true,function(){ajaxCall=null});progressEventsCount=0}}},forceSavePosition=function(e,api){var inPlaylist=false;for(var i in api.conf.playlist){if(!api.conf.playlist.hasOwnProperty(i))continue;inPlaylist=true;break}if(inPlaylist&&!flowplayer.conf.closingPage){progressEventsCount=sendPositionsEvery+1;storeVideoPosition(e,api);sendVideoPositions()}},seek=function(position){if(!!api.custom_seek){api.custom_seek(position);return}var seek_count=0;var do_seek=setInterval(function(){if(++seek_count>20)clearInterval(do_seek);if(api.loading)return;api.seek(parseInt(position));clearInterval(do_seek)},10)},processTempData=function(temp_data_name,video_id){var data=getCookieKey(temp_data_name),output=false;if(data&&typeof data!=="undefined"){try{data=JSON.parse(data);if(typeof data[video_id]!="undefined"){output=data[video_id];delete data[video_id];var stillHasData=false;for(var i in data){if(!data.hasOwnProperty(i))continue;stillHasData=true;break}if(stillHasData){setCookieKey(temp_data_name,JSON.stringify(data))}else{removeCookieKey(temp_data_name)}}return output}catch(e){}}},restorePlaylistItem=function(e,api){if(typeof api=="undefined"||api.conf.playlist.length==0)return;var item_index=-1;if(player_id){if(flowplayer.conf.is_logged_in!="1"){var data=getCookieKey(cookiePlaylistsKeyName);if(data&&typeof data!=="undefined"){try{data=JSON.parse(data);if(data[player_id]){item_index=data[player_id]}}catch(e){return}}}else if(flowplayer.conf.is_logged_in=="1"){item_index=api.conf.playlist.length>0?processTempData(tempPlaylistsCookieKeyName,player_id):false}}if(item_index>=0&&!item_changed){api.play(item_index);item_changed=true}};if(!enabled)return;if(getCookieKey(tempPlaylistsCookieKeyName)){$root.removeData("playlist_start")}api.bind("finish",removeVideoPosition);api.one("progress",seekIntoPosition);api.bind("unload",function(){item_changed=false;api.one("ready",restorePlaylistItem)});api.one("ready",restorePlaylistItem);jQuery(".fp-ui",root).on("click",function(){restorePlaylistItem()});api.playlist_thumbnail_progress=function(el,video,position){if(!!api.get_custom_start&&api.get_custom_start(video)>0){position-=api.get_custom_start(video);if(position<0)position=0}var duration=video.duration;if(!!api.get_custom_duration&&api.get_custom_duration()>0){duration=api.get_custom_duration()}if(!duration){duration=el.data("duration")}if(!duration)return;var progress=100*position/duration;el.css("width",progress+"%")};if(flowplayer.conf.is_logged_in=="1"){var playlist=api.conf.playlist.length>0?api.conf.playlist:[api.conf.clip],playlist_external=jQuery("[rel="+jQuery(root).attr("id")+"]");for(var i in playlist){if(!playlist.hasOwnProperty(i))continue;var video_id=getVideoId(playlist[i]),position=processTempData(tempPositionCookieKeyName,video_id),saw=processTempData(tempSawCookieKeyName,video_id);if(position){if(api.conf.playlist.length){api.conf.playlist[i].sources[0].position=position;var playlist_progress=jQuery("a",playlist_external).eq(i).find(".fvp-progress");if(playlist_progress.length){api.playlist_thumbnail_progress(playlist_progress,api.conf.playlist[i],position)}}else{api.conf.clip.sources[0].position=position}}if(saw){if(api.conf.playlist.length){api.conf.playlist[i].sources[0].saw=true}else{api.conf.clip.sources[0].saw=true}}}}api.bind("finish",function(e,api){if(api.conf.playlist.length){api.conf.playlist[api.video.index].sources[0].saw=true}else{api.conf.clip.sources[0].saw=true}})});jQuery(window).on("beforeunload pagehide",function(){if(!flowplayer.conf.closingPage){flowplayer.conf.closingPage=true;sendVideoPositions()}});if(typeof fv_flowplayer_conf.disable_localstorage!="undefined"){localStorageEnabled=false}if(localStorageEnabled!==null){return localStorageEnabled}localStorageEnabled=true;try{localStorage.setItem("t","t");if(localStorage.getItem("t")!=="t"){localStorageEnabled=false}localStorage.removeItem("t")}catch(e){localStorageEnabled=false}})(jQuery);flowplayer(function(api,root){root=jQuery(root);if(api.conf.playlist.length==0)return;var real_videos=0;jQuery(api.conf.playlist).each(function(k,v){if(typeof v.click=="undefined"){real_videos++}});if(real_videos<2)return;var playlist=jQuery(".fp-playlist-external[rel="+root.attr("id")+"]");var playlist_button=jQuery('<strong class="fv-fp-list">Item 1.</strong>'),playlist_button_name=jQuery('<strong class="fv-fp-list-name">Item 1.</strong>'),playlist_menu=jQuery('<div class="fp-menu fv-fp-list-menu"></div>').insertAfter(root.find(".fp-controls"));var i=0,item_index=[],track_item=[];jQuery(api.conf.playlist).each(function(k,v){if(typeof v.click=="undefined"){var title=parse_title(playlist.find("h4").eq(i));playlist_menu.append('<a data-index="'+k+'">'+(i+1)+". "+title+"</a>");track_item[k]=title;item_index.push(k);i++}});function playlist_button_click(e){e.preventDefault();e.stopPropagation();if(playlist_menu.hasClass("fp-active")){api.hideMenu(playlist_menu[0])}else{root.trigger("click");api.showMenu(playlist_menu[0])}}playlist_button.insertAfter(root.find(".fp-controls .fp-volume")).on("click",playlist_button_click);playlist_button_name.insertAfter(playlist_button).on("click",playlist_button_click);jQuery("a",playlist_menu).on("click",function(){if(typeof api.conf.playlist[jQuery(this).data("index")-1]!="undefined"&&typeof api.conf.playlist[jQuery(this).data("index")-1].click!="undefined"){api.play(jQuery(this).data("index")-1)}else{api.play(jQuery(this).data("index"))}});api.on("ready",function(e,api,video){playlist_menu.find("a").removeClass("fp-selected");var thumb=playlist_menu.find("a[data-index="+video.index+"]");thumb.addClass("fp-selected");var label=fv_flowplayer_translations.playlist_item_no;label=label.replace(/%d/,item_index.indexOf(video.index)+1);label=label.replace(/%s/,parse_title(thumb.find("h4")));playlist_button.html(label);playlist_button_name.html(item_index.indexOf(video.index)+1+". "+track_item[video.index])});function parse_title(el){var tmp=el.clone();tmp.find("i.dur").remove();return tmp.text()}});flowplayer(function(api,root){root=jQuery(root);var playlist=api.conf.playlist,videoIndex;api.bind("load",function(e,api,video){videoIndex=video.index});api.bind("error",function(e,api,error){setTimeout(function(){if(playlist.length>0&&api.error==true){videoIndex=api.video.index;if(api.conf.video_checker=="1"&&playlist[videoIndex].video_checker&&playlist[videoIndex].video_checker.length>0){console.log("FV Player: Video checker message present, stopping auto-advance to next playlist item");return false}api.error=api.loading=false;root.removeClass("is-error");root.find(".fp-message.fp-shown").remove();videoIndex++;if(videoIndex>playlist.length-1){videoIndex=0}console.log("FV Player: Playlist item failure, auto-advancing to "+(videoIndex+1)+". item");api.play(videoIndex)}},1e3)})});flowplayer(function(api,root){root=jQuery(root);var original_prev,original_next,random_seed;if(!root.data("button-no-picture")&&!root.data("button-repeat")&&!root.data("button-rewind"))return;api.bind("ready",function(e,api){if(typeof original_next=="undefined"&&typeof original_prev=="undefined"){original_next=api.next;original_prev=api.prev}if(!api.video.type.match(/^audio/)&&root.data("button-no-picture")&&root.find(".fv-fp-no-picture").length==0){var button_no_picture=jQuery('<span class="fv-fp-no-picture"><svg viewBox="0 0 90 80" width="18px" height="18px" class="fvp-icon fvp-nopicture"><use xlink:href="#fvp-nopicture"></use></svg></span>');button_no_picture.insertAfter(root.find(".fp-controls .fp-volume")).on("click",function(e){e.preventDefault();e.stopPropagation();jQuery(".fp-engine",root).slideToggle(20);jQuery(this).toggleClass("is-active fp-color-fill")})}if(root.data("button-repeat")){if(api.conf.playlist.length>0&&root.find(".fv-fp-playlist").length==0){var t=fv_flowplayer_translations,playlist_button=jQuery('<strong class="fv-fp-playlist mode-normal"> <svg viewBox="0 0 80.333 80" width="18px" height="18px" class="fvp-icon fvp-replay-list"><title>'+t.playlist_replay_all+'</title><use xlink:href="#fvp-replay-list"></use></svg> <svg viewBox="0 0 80.333 71" width="18px" height="18px" class="fvp-icon fvp-shuffle"><title>'+t.playlist_shuffle+'</title><use xlink:href="#fvp-shuffle"></use></svg> <svg viewBox="0 0 80.333 71" width="18px" height="18px" class="fvp-icon fvp-replay-track"><title>'+t.playlist_replay_video+'</title><use xlink:href="#fvp-replay-track"></use></svg> <span id="fvp-playlist-play" title="'+t.playlist_play_all+'">'+t.playlist_play_all_button+"</span> </strong>"),playlist_menu=jQuery('<div class="fp-menu fv-fp-playlist-menu"> <a data-action="repeat_playlist"><svg viewBox="0 0 80.333 80" width="18px" height="18px" class="fvp-icon fvp-replay-list"><title>'+t.playlist_replay_all+'</title><use xlink:href="#fvp-replay-list"></use></svg> <span class="screen-reader-text">'+t.playlist_replay_all+'</span></a> <a data-action="shuffle_playlist"><svg viewBox="0 0 80.333 71" width="18px" height="18px" class="fvp-icon fvp-shuffle"><title>'+t.playlist_shuffle+'</title><use xlink:href="#fvp-shuffle"></use></svg> <span class="screen-reader-text">'+t.playlist_shuffle+'</span></a> <a data-action="repeat_track"><svg viewBox="0 0 80.333 71" width="18px" height="18px" class="fvp-icon fvp-replay-track"><title>'+t.playlist_replay_video+'</title><use xlink:href="#fvp-replay-track"></use></svg> <span class="screen-reader-text">'+t.playlist_replay_video+'</span></a> <a class="fp-selected" data-action="normal"><span id="fvp-playlist-play" title="'+t.playlist_play_all+'">'+t.playlist_play_all_button+"</span></a> </div>").insertAfter(root.find(".fp-controls"));api.conf.playlist_shuffle=api.conf.track_repeat=false;random_seed=randomize();var should_advance=api.conf.advance;playlist_button.insertAfter(root.find(".fp-controls .fp-volume")).on("click",function(e){e.preventDefault();e.stopPropagation();if(playlist_menu.css("right")!=="auto"){playlist_menu.css({right:"auto",left:playlist_button.position().left+"px"})}if(playlist_menu.hasClass("fp-active")){api.hideMenu(playlist_menu[0])}else{root.trigger("click");api.showMenu(playlist_menu[0])}});jQuery("a",playlist_menu).on("click",function(){jQuery(this).siblings("a").removeClass("fp-selected");jQuery(this).addClass("fp-selected");playlist_button.removeClass("mode-normal mode-repeat-track mode-repeat-playlist mode-shuffle-playlist");var action=jQuery(this).data("action");if(action=="repeat_playlist"){playlist_button.addClass("mode-repeat-playlist");api.conf.loop=true;api.conf.advance=true;api.video.loop=api.conf.track_repeat=false;api.conf.playlist_shuffle=false}else if(action=="shuffle_playlist"){playlist_button.addClass("mode-shuffle-playlist");api.conf.loop=true;api.conf.advance=true;api.conf.playlist_shuffle=true}else if(action=="repeat_track"){playlist_button.addClass("mode-repeat-track");api.conf.track_repeat=api.video.loop=true;api.conf.loop=api.conf.playlist_shuffle=false}else if(action=="normal"){playlist_button.addClass("mode-normal");api.conf.track_repeat=api.video.loop=false;api.conf.loop=api.conf.playlist_shuffle=false}if(api.conf.playlist_shuffle){api.next=function(){api.play(random_seed.pop());if(random_seed.length==0)random_seed=randomize()};api.prev=function(){api.play(random_seed.shift());if(random_seed.length==0)random_seed=randomize()}}else{api.next=original_next;api.prev=original_prev}});if(api.conf.loop){jQuery("a[data-action=repeat_playlist]",playlist_menu).trigger("click")}api.on("progress",function(){api.video.loop=api.conf.track_repeat});api.on("finish.pl",function(e,api){console.log("playlist_repeat",api.conf.loop,"advance",api.conf.advance,"video.loop",api.video.loop);if(api.conf.playlist_shuffle){api.play(random_seed.pop());if(random_seed.length==0)random_seed=randomize()}})}else if(root.find(".fv-fp-track-repeat").length==0&&api.conf.playlist.length==0){var button_track_repeat=jQuery('<strong class="fv-fp-track-repeat"><svg viewBox="0 0 80.333 71" width="18px" height="18px" class="fvp-icon fvp-replay-track"><use xlink:href="#fvp-replay-track"></use></svg></strong>');button_track_repeat.insertAfter(root.find(".fp-controls .fp-volume")).on("click",function(e){e.preventDefault();e.stopPropagation();jQuery(this).toggleClass("is-active fp-color-fill",api.video.loop);if(api.video.loop){api.video.loop=false}else{api.video.loop=true}});if(api.conf.loop){button_track_repeat.addClass("is-active fp-color-fill")}}}if(root.data("button-rewind")){if(root.find(".fv-fp-rewind").length==0){var button_rewind=jQuery('<span class="fv-fp-rewind"><svg viewBox="0 0 24 24" width="21px" height="21px" class="fvp-icon fvp-rewind"><use xlink:href="#fvp-rewind"></use></svg></span>');button_rewind.insertBefore(root.find(".fp-controls .fp-playbtn")).on("click",function(e){e.preventDefault();e.stopPropagation();api.seek(api.video.time-10)});button_rewind.toggle(!api.video.live)}if(root.find(".fv-fp-forward").length==0){var button_forward=jQuery('<span class="fv-fp-forward"><svg viewBox="0 0 24 24" width="21px" height="21px" class="fvp-icon fvp-forward"><use xlink:href="#fvp-forward"></use></svg></span>');button_forward.insertAfter(root.find(".fp-controls .fp-playbtn")).on("click",function(e){e.preventDefault();e.stopPropagation();api.seek(api.video.time+10)});button_forward.toggle(!api.video.live)}}}).bind("unload",function(){root.find(".fv-fp-no-picture").remove();root.find(".fv-fp-playlist").remove();root.find(".fv-fp-track-repeat").remove()});function array_shuffle(a){var j,x,i;for(i=a.length;i;i--){j=Math.floor(Math.random()*i);x=a[i-1];a[i-1]=a[j];a[j]=x}return a}function randomize(random_seed){random_seed=[];jQuery(api.conf.playlist).each(function(k,v){random_seed.push(k)});random_seed=array_shuffle(random_seed);console.log("FV Player Randomizer random seed:",random_seed);return random_seed}});flowplayer(function(api,root){var $root=jQuery(root),start_index=$root.data("playlist_start");if(typeof start_index=="undefined")return;function start_position_changer(){if($root.data("position_changed")!==1&&api.conf.playlist.length){start_index--;api.play(start_index);$root.data("position_changed",1)}}api.bind("unload",function(){start_index=$root.data("playlist_start");$root.removeData("position_changed");api.one("ready",start_position_changer)});api.one("ready",start_position_changer);jQuery(".fp-ui",root).on("click",function(){start_position_changer();$root.data("position_changed",1)})});document.addEventListener("custombox:overlay:close",function(e){console.log("FV Player: Custombox/Popup anything ligtbox closed");var $players=jQuery(this).find(".flowplayer");if($players.length==0)return;console.log("FV Player: Custombox/Popup anything ligtbox contains a player");$players.each(function(index,player){var api=jQuery(player).data("flowplayer");if(typeof api!="undefined"){if(api.playing){console.log("FV Player: Custombox/Popup anything ligtbox video pause");api.pause()}else if(api.loading){api.one("ready",function(){console.log("FV Player: Custombox/Popup anything ligtbox video unload");api.unload()})}}})});flowplayer(function(api,root){api.bind("finish",function(){var finished_at=api.video.time;if(api.video.loop){api.one("pause",function(){if(finished_at<=api.video.time){api.resume()}})}})});function fv_flowplayer_amazon_s3(hash,time){jQuery("#wpfp_"+hash).bind("error",function(e,api,error){var fv_fp_date=new Date;if(error.code==4&&fv_fp_date.getTime()>fv_fp_utime+parseInt(time)){jQuery(e.target).find(".fp-message").delay(500).queue(function(n){jQuery(this).html(fv_flowplayer_translations.video_expired);n()})}})}flowplayer(function(api,root){root=jQuery(root);root.find(".fp-logo").removeAttr("href");if(root.hasClass("no-controlbar")){var timelineApi=api.sliders.timeline;timelineApi.disable(true);api.bind("ready",function(){timelineApi.disable(true)})}jQuery(".fvfp_admin_error",root).remove();root.find(".fp-logo, .fp-header").on("click",function(e){if(e.target!==this)return;root.find(".fp-ui").trigger("click")});jQuery(".fvp-share-bar .sharing-facebook",root).append('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="#fff"><title>Facebook</title><path d="M11.9 5.2l-2.6 0 0-1.6c0-0.7 0.3-0.7 0.7-0.7 0.3 0 1.6 0 1.6 0l0-2.9 -2.3 0c-2.6 0-3.3 2-3.3 3.3l0 2 -1.6 0 0 2.9 1.6 0c0 3.6 0 7.8 0 7.8l3.3 0c0 0 0-4.2 0-7.8l2.3 0 0.3-2.9Z"/></svg>');jQuery(".fvp-share-bar .sharing-twitter",root).append('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="#fff"><title>Twitter</title><path d="M16 3.1c-0.6 0.3-1.2 0.4-1.9 0.5 0.7-0.4 1.2-1 1.4-1.8 -0.6 0.4-1.3 0.6-2.1 0.8 -0.6-0.6-1.4-1-2.4-1 -2 0.1-3.2 1.6-3.2 4 -2.7-0.1-5.1-1.4-6.7-3.4 -0.9 1.4 0.2 3.8 1 4.4 -0.5 0-1-0.1-1.5-0.4l0 0.1c0 1.6 1.1 2.9 2.6 3.2 -0.7 0.2-1.3 0.1-1.5 0.1 0.4 1.3 1.6 2.2 3 2.3 -1.6 1.7-4.6 1.4-4.8 1.3 1.4 0.9 3.2 1.4 5 1.4 6 0 9.3-5 9.3-9.3 0-0.1 0-0.3 0-0.4 0.6-0.4 1.2-1 1.6-1.7Z"/></svg>');jQuery(".fvp-share-bar .sharing-email",root).append('<svg xmlns="http://www.w3.org/2000/svg" height="16" viewBox="0 0 16 16" width="16" fill="#fff"><title>Email</title><path d="M8 10c0 0 0 0-1 0L0 6v7c0 1 0 1 1 1h14c1 0 1 0 1-1V6L9 10C9 10 8 10 8 10zM15 2H1C0 2 0 2 0 3v1l8 4 8-4V3C16 2 16 2 15 2z"/></svg>');jQuery(".fp-header",root).prepend(jQuery(".fvp-share-bar",root));if(api.conf.playlist.length){var show=true;var playlist=api.conf.playlist;if(playlist.length==2){if(typeof playlist[0].click!="undefined"&&typeof playlist[1].click=="undefined"){show=false}if(typeof playlist[0].click=="undefined"&&typeof playlist[1].click!="undefined"){show=false}}else if(playlist.length==3){if(typeof playlist[0].click!="undefined"&&typeof playlist[1].click=="undefined"&&typeof playlist[2].click!="undefined"){show=false}}if(show){var prev=jQuery('<a class="fp-icon fv-fp-prevbtn"></a>');var next=jQuery('<a class="fp-icon fv-fp-nextbtn"></a>');root.find(".fp-controls .fp-playbtn").before(prev).after(next);prev.on("click",function(){api.trigger("prev",[api]);api.prev()});next.on("click",function(){api.trigger("next",[api]);api.next()})}}if(typeof fv_player_editor_conf!="undefined"){root.on("click",".fvp-sharing > li",function(e){e.preventDefault();fv_player_notice(root,fv_player_editor_translations.link_notice,2e3);return false})}api.bind("pause resume finish unload ready",function(e,api){root.addClass("no-brand")});api.one("ready",function(){root.find(".fp-fullscreen").clone().appendTo(root.find(".fp-controls"))});api.on("ready",function(e,api,video){setTimeout(function(){jQuery(".fvp-share-bar",root).show();jQuery(".fv-player-buttons-wrap",root).appendTo(jQuery(".fv-player-buttons-wrap",root).parent().find(".fp-ui"))},100)});api.bind("finish",function(){var url=root.data("fv_redirect");if(url&&(typeof api.video.is_last=="undefined"||api.video.is_last)){location.href=url}});if(flowplayer.support.iOS&&flowplayer.support.iOS.version==11){api.bind("error",function(e,api,error){if(error.code==4)root.find(".fp-engine").hide()})}jQuery(document).on("contextmenu",".flowplayer",function(e){e.preventDefault()});api.one("ready",function(e,api,video){root.find(".fp-chromecast").insertAfter(root.find(".fp-header .fp-fullscreen"))});root.find(".fp-waiting").html('<div class="fp-preload"><b></b><b></b><b></b><b></b></div>');var id=root.attr("id"),alternative=!flowplayer.conf.native_fullscreen&&flowplayer.conf.mobile_alternative_fullscreen,events_enter="fakefullscreen",events_exit="fakefullscreen-exit";if(!flowplayer.support.fullscreen){events_enter+=" fullscreen";events_exit+=" fullscreen-exit"}api.bind(events_enter,function(e,api){jQuery("#wpadminbar, .nc_wrapper").hide();if(alternative||e.type=="fakefullscreen"){if(api.video.type=="video/youtube")return;root.before('<span data-fv-placeholder="'+id+'"></span>');root.appendTo("body")}});api.bind(events_exit,function(e,api,video){jQuery("#wpadminbar, .nc_wrapper").show();if(alternative||e.type=="fakefullscreen-exit"){jQuery("span[data-fv-placeholder="+id+"]").replaceWith(root)}})});(function(){var extension=function(flowplayer){flowplayer(function(api,root){if(!jQuery(root).data("speedb"))return;var support=flowplayer.support;if(!support.video||!support.inlineVideo)return;var common=flowplayer.common,bean=flowplayer.bean,ui=common.find(".fp-ui",root)[0],controlbar=common.find(".fp-controls",ui)[0],speeds=api.conf.speeds;bean.on(root,"click",".fp-speed",function(){var menu=common.find(".fp-speed-menu",root)[0];if(common.hasClass(menu,"fp-active"))api.hideMenu();else api.showMenu(menu)});bean.on(root,"click",".fp-speed-menu a",function(ev){var s=ev.target.getAttribute("data-speed");api.speed(s)});api.on("speed",function(ev,_a,rate){if(speeds.length>1){selectSpeed(rate)}}).on("ready",function(ev,api){removeMenu();if(flowplayer.support.android&&api.engine.engineName=="html5"&&api.video.type=="application/x-mpegurl")return;speeds=api.conf.speeds;if(speeds.length>1){createMenu()}});function removeMenu(){common.find(".fp-speed-menu",root).forEach(common.removeNode);common.find(".fp-speed",root).forEach(common.removeNode)}function round(val){return Math.round(val*100)/100}function createMenu(){controlbar.appendChild(common.createElement("strong",{className:"fp-speed"},api.currentSpeed+"x"));var menu=common.createElement("div",{className:"fp-menu fp-speed-menu",css:{width:"auto"}},"<strong>Speed</strong>");speeds.forEach(function(s){var a=common.createElement("a",{"data-speed":round(s)},round(s)+"x");menu.appendChild(a)});ui.appendChild(menu);selectSpeed(api.currentSpeed);jQuery(root).find(".fp-speed-menu strong").text(fv_flowplayer_translations.speed)}function selectSpeed(rate){common.find(".fp-speed",root)[0].innerHTML=rate+"x";common.find(".fp-speed-menu a",root).forEach(function(el){common.toggleClass(el,"fp-selected",el.getAttribute("data-speed")==rate);common.toggleClass(el,"fp-color",el.getAttribute("data-speed")==rate)})}})};if(typeof module==="object"&&module.exports)module.exports=extension;else if(typeof window.flowplayer==="function")extension(window.flowplayer)})();flowplayer(function(api,root){if(typeof fv_flowplayer_conf.disable_localstorage!="undefined"){return}api.on("speed",function(ev,_a,rate){try{window.localStorage.fv_player_speed=rate}catch(e){}});api.on("ready",function(){if(window.localStorage.fv_player_speed&&jQuery(root).find("strong.fp-speed").is(":visible")){api.speed(parseFloat(window.localStorage.fv_player_speed))}if(jQuery(root).data("volume")==0){api.mute(true,true)}})});flowplayer(function(api,root){root=jQuery(root);var last_tracked=-1;if(!api.conf.fv_stats||!api.conf.fv_stats.enabled&&(!root.data("fv_stats")||root.data("fv_stats")=="no"))return;api.on("ready finish",function(e,api){api.one("progress",function(e,api){if(root.data("fv_stats_data")){try{var player_post_data=root.data("fv_stats_data")}catch(e){return false}if(last_tracked==get_index())return;last_tracked=get_index();jQuery.post(api.conf.fv_stats.url,{blog_id:api.conf.fv_stats.blog_id,video_id:api.video.id?api.video.id:0,player_id:player_post_data.player_id,post_id:player_post_data.post_id,tag:"play"})}})}).on("finish",function(){last_tracked=-1});function get_index(){return api.video.index?api.video.index:0}});flowplayer(function(api,root){var $root=jQuery(root);var $playerDiv=$root.find(".fp-player");var sticky=$root.data("fvsticky");var globalSticky=false;var videoRatio=$root.data("ratio"),is_sticky=false;if(typeof videoRatio=="undefined"){videoRatio=.5625}if(flowplayer.conf.sticky_video==1&&typeof sticky=="undefined"){globalSticky=true}if(globalSticky||sticky){if(flowplayer.support.firstframe){var stickyPlace=flowplayer.conf.sticky_place;var stickyWidth=flowplayer.conf.sticky_width;if(stickyWidth==""){stickyWidth=380}var stickyHeight=stickyWidth*videoRatio;fv_player_sticky_video()}else{return}}function fv_player_sticky_video(){var change=false;var $window=jQuery(window),$flowplayerDiv=$root,top=$flowplayerDiv.offset().top,offset=Math.floor(top+$flowplayerDiv.outerHeight()/2);api.on("ready",function(){change=true});api.on("progress",function(){change=true});api.on("unload",function(){change=false;fv_player_sticky_class_remove();$root.removeClass("is-unSticky")});$window.on("resize",function(){if(!is_big_enough()){if(is_sticky){fv_player_sticky_class_remove()}return}top=$flowplayerDiv.offset().top;offset=Math.floor(top+$flowplayerDiv.outerHeight()/2)}).on("scroll",function(){if(!is_big_enough()){if(is_sticky){fv_player_sticky_class_remove()}return}top=$flowplayerDiv.offset().top;offset=Math.floor(top+$flowplayerDiv.outerHeight()/2);if($window.scrollTop()>offset&&change){if(jQuery("div.flowplayer.is-unSticky").length>0){console.log("unSticky",jQuery("div.flowplayer.is-unSticky").length);return false}else{fv_player_sticky_class_add()}}else{fv_player_sticky_class_remove();change=false}})}function fv_player_sticky_class_add(){if($playerDiv.hasClass("is-sticky-"+stickyPlace)){return}else{$playerDiv.addClass("is-sticky-"+stickyPlace);if($root.find("a.fp-sticky").length==0){$root.find("div.fp-header").prepend('<a class="fp-sticky fp-icon"></a>')}$playerDiv.css("width",stickyWidth);$playerDiv.css("height",stickyHeight);$playerDiv.css("max-height",stickyHeight);is_sticky=true;api.trigger("sticky",[api])}$playerDiv.parent(".flowplayer").addClass("is-stickable")}function fv_player_sticky_class_remove(){$playerDiv.removeClass("is-sticky-"+stickyPlace);$playerDiv.css("width","");$playerDiv.css("height","");$playerDiv.css("max-height","");$playerDiv.parent(".flowplayer").removeClass("is-stickable");if(is_sticky){is_sticky=false;api.trigger("sticky-exit",[api])}}function is_big_enough(){return jQuery(window).innerWidth()>=1020}});jQuery(function($){$(document).on("click","a.fp-sticky",function(){$("div.flowplayer.is-stickable").addClass("is-unSticky");var $playerDiv=$("div.flowplayer.is-stickable").find(".fp-player");$playerDiv.removeClass("is-sticky-right-bottom");$playerDiv.removeClass("is-sticky-left-bottom");$playerDiv.removeClass("is-sticky-right-top");$playerDiv.removeClass("is-sticky-left-top");$playerDiv.css("width","");$playerDiv.css("height","");$playerDiv.css("max-height","");if(is_sticky){is_sticky=false;api.trigger("sticky-exit",[api])}});$(document).on("click","div.flowplayer.is-unSticky",function(){$("div.flowplayer").removeClass("is-unSticky")})});flowplayer(function(api,root){root=jQuery(root);if(typeof fv_flowplayer_conf.disable_localstorage!="undefined"){return}var ls=window.localStorage;api.on("ready",function(e,api,video){if(root.find("strong.fp-cc").is(":visible")){if(ls.fv_player_subtitle&&api.video.subtitles.length){if(ls.fv_player_subtitle==="none"){api.disableSubtitles()}else{api.video.subtitles.forEach(function(item,index){if(item.srclang===ls.fv_player_subtitle){api.loadSubtitles(index)}})}}else{var defaultSubtitle=video.subtitles.filter(function(one){return one["fv_default"]})[0];if(defaultSubtitle){api.loadSubtitles(video.subtitles.indexOf(defaultSubtitle))}}}root.find(".fp-subtitle-menu").on("click",function(e){var subtitle_index=e.target.getAttribute("data-subtitle-index");if(typeof subtitle_index=="string"){try{ls.fv_player_subtitle=subtitle_index>-1?api.video.subtitles[subtitle_index].srclang:"none"}catch(e){}}})})});flowplayer(function(api,root){root=jQuery(root);var currentPoint,check=false;api.bind("cuepoint",function(e,api,cue){check=false;if(cue.subtitle){currentPoint=cue.index}});api.on("ready",function(e,api){root.find(".fp-subtitle-menu strong").text(fv_flowplayer_translations.closed_captions);root.find('.fp-subtitle-menu a[data-subtitle-index="-1"]').text(fv_flowplayer_translations.no_subtitles)});root.on("click",".fp-subtitle-menu a[data-subtitle-index]",function(e){if(jQuery(this).data("subtitle-index")>-1){check=true;api.on("progress",time_check)}});function time_check(e,api,time){if(check){(api.cuepoints||[]).forEach(function(cue,index){var entry=cue.subtitle;if(entry&&currentPoint!=index){if(time>=cue.time&&(!entry.endTime||time<=entry.endTime)){api.trigger("cuepoint",[api,cue])}}})}}});if(typeof flowplayer!=="undefined"&&typeof fv_flowplayer_conf!="undefined"&&fv_flowplayer_conf.video_hash_links){flowplayer(function(api,root){if(jQuery(root).find(".sharing-link").length>0){var abEnd,abStart,hash,sTime,abloop;function update_link(abStartNew,abEndNew){hash=fv_player_get_video_link_hash(api);sTime=","+fv_player_time_hms(api.video.time);if(abStartNew&&abEndNew){abStart=","+fv_player_time_hms_ms(abStartNew+api.get_custom_start());abEnd=","+fv_player_time_hms_ms(abEndNew+api.get_custom_start())}else{abEnd=abloop&&typeof api.get_ab_end()!="undefined"&&api.get_ab_end()?","+fv_player_time_hms_ms(api.get_ab_end()):"";abStart=abloop&&typeof api.get_ab_start()!="undefined"&&api.get_ab_start()?","+fv_player_time_hms_ms(api.get_ab_start()):""}jQuery(".sharing-link",root).attr("href",jQuery(".sharing-link",root).attr("href").replace(/#.*/,"")+"#"+hash+sTime+abStart+abEnd)}api.on("ready",function(e,api,video){if(!api.fv_noUiSlider)return;api.fv_noUiSlider.on("set",function(values){update_link(values[0],values[1])})});api.on("progress",function(e,api){if(!api.video.sources||!api.video.sources[0]){return}update_link()});api.on("abloop",function(e,api,active){abloop=active;if(!api.playing){update_link()}});jQuery(".sharing-link",root).on("click",function(e){fv_player_clipboard(jQuery(this).attr("href"),function(){e.preventDefault();fv_player_notice(root,fv_flowplayer_translations.link_copied,2e3)})})}});jQuery(document).on("click",'a[href*="fvp_"]',function(){var link=jQuery(this);setTimeout(function(){if(link.parents(".fvp-share-bar").length==0)fv_autoplay_exec()})})}flowplayer(function(api,root){root=jQuery(root);var bean=flowplayer.bean;var restore=flowplayer.conf.default_volume;root.on("mousedown touchstart",".fp-volumebtn",function(e){var volumebtn=jQuery(this);if(api.volumeLevel==0){volumebtn.one("click",function(){api.volume(restore);return false})}});root.on("mousedown touchstart mouseup touchend",".fp-volumebar",function(e){if(api.volumeLevel!=0){restore=api.volumeLevel}});api.on("volume",function(e,api){if(root.hasClass("is-mouseover")&&!api.muted){if(api.volumeLevel==0){bean.off(flowplayer.support.touch?root:document,"mousemove.sld touchmove.sld");api.mute(true)}}});var deal_with_muted_start=false;api.one("ready",function(e,api){if(root.hasClass("is-audio"))return;deal_with_muted_start=true});api.on("progress",function(e,api,time){if(deal_with_muted_start&&time>1){deal_with_muted_start=false;var video=jQuery("root").find("video");if(video.length&&!hasAudio(video[0])){return}if(api.muted||api.volumeLevel==0){if(localStorage.muted=="true"||localStorage.volume=="0"){return}var mute_notice=jQuery('<div class="fp-message fp-message-muted"><span class="fp-icon fp-volumebtn-notice"></span> '+fv_flowplayer_translations.click_to_unmute+"</div>");mute_notice.on("click touchstart",function(){api.mute(false);api.volume(1)});root.find(".fp-ui").append(mute_notice);root.addClass("has-fp-message-muted");setTimeout(remove_volume_notice,5e3)}}});api.on("mute volume",function(){if(!api.muted||api.volumeLevel>0){remove_volume_notice()}});function remove_volume_notice(){root.removeClass("has-fp-message-muted");root.find(".fp-message-muted").remove()}function hasAudio(video){return video.mozHasAudio||Boolean(video.webkitAudioDecodedByteCount)||Boolean(video.audioTracks&&video.audioTracks.length)}});if(typeof flowplayer!="undefined"){flowplayer(function(api,root){root=jQuery(root);if(navigator.userAgent.match(/iPhone.* OS [0-6]_/i)){api.one("progress",function(e){if(typeof api.video.subtitles!=="undefined"&&api.video.subtitles.length){fv_player_warning(root,fv_flowplayer_translations.warning_iphone_subs)}})}if(flowplayer.support.android&&flowplayer.support.android.version<5&&(flowplayer.support.android.samsung||flowplayer.support.browser.safari)){fv_player_warning(root,fv_flowplayer_translations.warning_unstable_android,"firefox")}if(/Android 4/.test(navigator.userAgent)&&!/Firefox/.test(navigator.userAgent)){api.on("ready",function(e,api,video){setTimeout(function(){if(video.src&&video.src.match(/fpdl.vimeocdn.com/)&&(video.time==0||video.time==1)){fv_player_warning(root,fv_flowplayer_translations.warning_unstable_android,"firefox");api.on("progress",function(e,api){root.prev().find(".fv-player-warning-firefox").remove()})}},1500)});api.on("error",function(e,api,error){if(error.MEDIA_ERR_NETWORK==2&&error.video.src.match(/fpdl.vimeocdn.com/)){fv_player_warning(root,fv_flowplayer_translations.warning_unstable_android,"firefox")}})}if(/Safari/.test(navigator.userAgent)&&/Version\/5/.test(navigator.userAgent)){api.on("error",function(e,api,error){if(error.video.src.match(/fpdl.vimeocdn.com/)){fv_player_warning(root,fv_flowplayer_translations.warning_old_safari)}})}var sup=flowplayer.support;if(sup.android&&(sup.android.samsung&&parseInt(sup.browser.version)<66||sup.browser.safari)){api.on("error",function(e,api,error){fv_player_warning(root,fv_flowplayer_translations.warning_samsungbrowser,"warning_samsungbrowser")})}});function fv_player_warning(root,warning,classname){var wrapper=jQuery(root).prev(".fv-player-warning-wrapper");if(wrapper.length==0){jQuery(root).before('<div class="fv-player-warning-wrapper">');wrapper=jQuery(root).prev(".fv-player-warning-wrapper")}if(wrapper.find(".fv-player-warning-"+classname).length==0){var latest=jQuery("<p style='display: none' "+(classname?" class='fv-player-warning-"+classname+"'":"")+">"+warning+"</p>");wrapper.append(latest);latest.slideDown()}}}
1
+ if(typeof fv_flowplayer_conf!="undefined"){try{if(typeof window.localStorage=="object"&&typeof window.localStorage.volume!="undefined"){delete fv_flowplayer_conf.volume}}catch(e){}flowplayer.conf=fv_flowplayer_conf;flowplayer.conf.fullscreen=false;flowplayer.conf.chromecast=false;flowplayer.conf.embed=false;flowplayer.conf.share=false;flowplayer.conf.analytics=false;if(typeof fv_flowplayer_conf.disable_localstorage!="undefined"){flowplayer.conf.storage={}}try{flowplayer.conf.key=atob(flowplayer.conf.key)}catch(e){}if(!flowplayer.support.android&&flowplayer.conf.dacast_hlsjs){function FVAbrController(hls){this.hls=hls;this.nextAutoLevel=3}FVAbrController.prototype.nextAutoLevel=function(nextLevel){this.nextAutoLevel=nextLevel};FVAbrController.prototype.destroy=function(){};flowplayer.conf.hlsjs={startLevel:-1,abrController:FVAbrController}}function parseIOSVersion(UA){var e=/iP(ad|hone)(; CPU)? OS (\d+_\d)/.exec(UA);if(e&&e.length>1){return parseFloat(e[e.length-1].replace("_","."),10)}return 0}if(flowplayer.support.iOS&&flowplayer.support.iOS.chrome&&flowplayer.support.iOS.version==0){flowplayer.support.iOS.version=parseIOSVersion(navigator.userAgent)}if(flowplayer.support.iOS&&parseInt(flowplayer.support.iOS.version)>=13||!flowplayer.support.iOS&&flowplayer.support.browser.safari&&parseInt(flowplayer.support.browser.version)>=8){flowplayer.conf.hlsjs.safari=true}flowplayer.support.fvmobile=!!(!flowplayer.support.firstframe||flowplayer.support.iOS||flowplayer.support.android);var fls=flowplayer.support;if(flowplayer.conf.mobile_native_fullscreen&&"ontouchstart"in window&&fls.fvmobile){flowplayer.conf.native_fullscreen=true}if("ontouchstart"in window){if(fls.android&&fls.android.version<4.4&&!(fls.browser.chrome&&fls.browser.version>54)){flowplayer.conf.native_fullscreen=true}if(fls.iOS&&(fv_player_in_iframe()||fls.iOS.version<7)){flowplayer.conf.native_fullscreen=true}}}if(typeof fv_flowplayer_translations!="undefined"){flowplayer.defaults.errors=fv_flowplayer_translations}var fv_player_did_autoplay=false;function fv_player_videos_parse(args,root){try{var videos=JSON.parse(args)}catch(e){return false}var regex=new RegExp("[\\?&]fv_flowplayer_mobile=([^&#]*)");var results=regex.exec(location.search);if((results!=null&&results[1]=="yes"||(jQuery(window).width()<=480||jQuery(window).height()<=480))&&(results==null||results[1]!="no")){var fv_fp_mobile=false;jQuery(videos.sources).each(function(k,v){if(v.mobile){videos.sources[k]=videos.sources[0];videos.sources[0]=v;fv_fp_mobile=true}if(fv_fp_mobile){jQuery(root).after('<p class="fv-flowplayer-mobile-switch">'+fv_flowplayer_translations.mobile_browser_detected_1+' <a href="'+document.URL+'?fv_flowplayer_mobile=no">'+fv_flowplayer_translations.mobile_browser_detected_2+"</a>.</p>")}})}root.trigger("fv_player_videos_parse",videos);return videos}function fv_player_in_iframe(){try{return window.self!==window.top}catch(e){return true}}jQuery(document).ready(function(){var loading_count=0;var loading=setInterval(function(){loading_count++;if(loading_count<1e3&&(window.fv_video_intelligence_conf&&!window.FV_Player_IMA||window.fv_vast_conf&&!window.FV_Player_IMA||window.fv_player_pro&&!window.FV_Flowplayer_Pro&&document.getElementById("fv_player_pro")!=fv_player_pro||window.fv_player_user_playlists&&!fv_player_user_playlists.is_loaded||window.FV_Player_JS_Loader_scripts_total&&window.FV_Player_JS_Loader_scripts_loaded<FV_Player_JS_Loader_scripts_total)){return}clearInterval(loading);fv_player_preload()},10)});function fv_escape_attr(text){var map={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return text.replace(/[&<>"']/g,function(m){return map[m]})}function fv_player_preload(){if(flowplayer.support.touch){jQuery(".fp-playlist-external.fv-playlist-design-2017").addClass("visible-captions")}flowplayer(function(api,root){if(localStorage.flowplayerTestStorage){delete localStorage.flowplayerTestStorage}root=jQuery(root);var fp_player=root.find(".fp-player");var splash_click=false;if(root.hasClass("fixed-controls")){root.find(".fp-controls").on("click",function(e){if(!api.loading&&!api.ready){e.preventDefault();e.stopPropagation();api.load()}})}if(!flowplayer.support.volume&&!flowplayer.support.autoplay){root.find(".fp-volume").hide()}if(root.data("volume")==0&&root.hasClass("no-controlbar")){root.find(".fp-volume").remove()}var playlist=jQuery(".fp-playlist-external[rel="+root.attr("id")+"]");if((!api.conf.playlist||api.conf.playlist.length==0)&&playlist.length&&playlist.find("a[data-item]").length>0){var items=[];playlist.find("a[data-item]").each(function(){if(parsed=fv_player_videos_parse(jQuery(this).attr("data-item"),root)){items.push(parsed)}else{jQuery(this).remove()}});api.conf.playlist=items;api.conf.clip=items[0]}else if(!api.conf.clip){api.conf.clip=fv_player_videos_parse(jQuery(root).attr("data-item"),root)}jQuery("a",playlist).on("click",function(e){e.preventDefault();splash_click=true;var $this=jQuery(this),playlist=jQuery(".fp-playlist-external[rel="+root.attr("id")+"]"),index=jQuery("a",playlist).index(this);$prev=$this.prev("a"),item=$this.data("item");if(location.href.match(/wp-admin/)&&$this.parents(".fv-player-editor-preview").length>0){fv_flowplayer_conf.current_video_to_edit=index;$this.parents(".fv-player-custom-video").find(".edit-video .fv-player-editor-button").trigger("click");return false}if($prev.length&&$this.is(":visible")&&!$prev.is(":visible")){$prev.trigger("click");return false}if(jQuery("#"+$this.parent().attr("rel")).hasClass("dynamic-playlist"))return;var playlist=jQuery(".fp-playlist-external[rel="+root.attr("id")+"]");fv_player_playlist_active(playlist,this);if(api){if(api.error){api.pause();api.error=api.loading=false;root.removeClass("is-error");root.find(".fp-message.fp-shown").remove()}if(!api.video||api.video.index==index)return;api.play(index)}var new_splash=item.splash;if(!new_splash){new_splash=$this.find("img").attr("src")}player_splash(root,fp_player,item,new_splash);var rect=root[0].getBoundingClientRect();if(rect.bottom-100<0){jQuery("html, body").animate({scrollTop:jQuery(root).offset().top-100},300)}});var playlist_external=jQuery("[rel="+root.attr("id")+"]");var playlist_progress=false;var splash_img=root.find(".fp-splash");var splash_text=root.find(".fv-fp-splash-text");function player_splash(root,fp_player,item,new_splash){var splash_img=root.find("img.fp-splash");if(new_splash){if(splash_img.length==0){splash_img=jQuery('<img class="fp-splash" />');fp_player.prepend(splash_img)}splash_img.attr("alt",item.fv_title?fv_escape_attr(item.fv_title):"video");splash_img.attr("src",new_splash)}else if(splash_img.length){splash_img.remove()}}api.bind("load",function(e,api,video){if(!api.conf.playlist.length){return}if(video.type.match(/^audio/)&&!splash_click){var anchor=playlist_external.find("a").eq(video.index);var item=anchor.data("item");var new_splash=item.splash;if(!new_splash){new_splash=anchor.find("img").attr("src")}player_splash(root,fp_player,item,new_splash)}splash_click=false});api.bind("ready",function(e,api,video){setTimeout(function(){if(video.index>-1){if(playlist_external.length>0){var playlist_item=jQuery("a",playlist_external).eq(video.index);fv_player_playlist_active(playlist_external,playlist_item);playlist_progress=playlist_item.find(".fvp-progress")}}},100);splash_img=root.find(".fp-splash");if(!video.is_audio_stream&&!video.type.match(/^audio/)){splash_img.remove();splash_text.remove()}});api.bind("unload",function(){jQuery(".fp-playlist-external .now-playing").remove();jQuery(".fp-playlist-external a").removeClass("is-active");var iframe=fp_player.find("iframe.fp-engine");if(iframe.length){iframe.after(splash_text);iframe.after(splash_img)}else{fp_player.prepend(splash_text);fp_player.prepend(splash_img)}playlist_progress=false});api.bind("progress",function(e,api,time){if(playlist_progress.length){api.playlist_thumbnail_progress(playlist_progress,api.video,time)}});api.bind("error-subtitles",function(){console.log("error-subtitles");fv_player_notice(root,fv_flowplayer_translations[8],2e3)});var playlist=jQuery(root).parent().find("div.fp-playlist-vertical[rel="+jQuery(root).attr("id")+"]");if(playlist.length){function check_size_and_all(args){var property=playlist.hasClass("fp-playlist-only-captions")?"height":"max-height";if(playlist.parents(".fp-playlist-text-wrapper").hasClass("is-fv-narrow")){property="max-height"}playlist.css(property,vertical_playlist_height());if(property=="max-height")playlist.css("height","auto")}check_size_and_all();jQuery(window).on("resize tabsactivate",function(){setTimeout(check_size_and_all,0)})}function vertical_playlist_height(args){var height=root.height();if(height==0)height=root.css("max-height");return height}api.show_status=function(type){var status="";["loading","ready","playing","paused","seeking"].every(function(v,k){if(api[v])status+=" "+v;return true});console.log("FV Player Status ("+type+")",status)};if(!window.fv_player_loaded){window.fv_player_loaded=true;setTimeout(function(){jQuery(document).trigger("fv_player_loaded");var event=new CustomEvent("fv_player_loaded",[]);document.dispatchEvent(event)},100)}setTimeout(function(){root.trigger("fv_player_loaded")},10)});if(window.self!=window.top&&!location.href.match(/fv_player_preview/)){embed_size();jQuery(window.self).resize(embed_size)}function embed_size(){jQuery(".flowplayer.fp-is-embed").each(function(){var root=jQuery(this);if(!root.hasClass("has-chapters")&&!root.hasClass("has-transcript")&&jQuery(".fp-playlist-external[rel="+root.attr("id")+"]").length==0){root.height(jQuery(window).height())}})}if(typeof fv_flowplayer_playlists!="undefined"){for(var i in fv_flowplayer_playlists){if(!fv_flowplayer_playlists.hasOwnProperty(i))continue;jQuery("#"+i).flowplayer({playlist:fv_flowplayer_playlists[i]})}}fv_player_load();fv_autoplay_exec();jQuery(document).ajaxComplete(function(){fv_player_load()});jQuery(window).on("hashchange",fv_autoplay_exec)}function fv_player_load(forced_el){if(forced_el&&forced_el.lenght>1){console.log("FV Player: Can't use fv_player_load with more than a single forced element!")}var load_players=forced_el,forced_api=false;if(!load_players)load_players=jQuery(".flowplayer");load_players.each(function(i,el){var root=jQuery(el);var api=root.data("flowplayer");if(api){if(forced_el)forced_api=api;return}if(forced_el){root.find(".fp-preload, .fvfp_admin_error").remove();if(root.attr("data-item-lazy")){root.attr("data-item",root.attr("data-item-lazy"));root.removeAttr("item-lazy")}else if(playlist=jQuery("[rel="+root.attr("id")+"]")){playlist.find("a[data-item-lazy]").each(function(k,v){v=jQuery(v);v.attr("data-item",v.attr("data-item-lazy"));v.removeAttr("data-item-lazy")})}}var conf=false;if(root.attr("data-item")){conf={clip:fv_player_videos_parse(root.attr("data-item"),root)}}else if(playlist=jQuery("[rel="+root.attr("id")+"]")){if(playlist.find("a[data-item]").length==0)return;var items=[];playlist.find("a[data-item]").each(function(){if(parsed=fv_player_videos_parse(jQuery(this).attr("data-item"),root)){items.push(parsed)}else{jQuery(this).remove()}});conf={playlist:items}}if(conf){conf=flowplayer.extend(conf,root.data());forced_api=flowplayer(root[0],conf);root.data("flowplayer",forced_api)}});jQuery(".fv-playlist-slider-wrapper").each(function(i,el){var items=jQuery(this).find("a");jQuery(this).find(".fp-playlist-external").css("width",items.outerWidth()*items.length)});if(typeof jQuery().tabs!="undefined"){jQuery("body").removeClass("fv_flowplayer_tabs_hide");jQuery(".fv_flowplayer_tabs_content").tabs()}if(forced_el&&forced_api){return forced_api}}function fv_player_playlist_active(playlist,item){if(playlist){jQuery("a",playlist).removeClass("is-active");jQuery(".now-playing").remove()}$playlist=jQuery(playlist);$item=jQuery(item);var scroll_parent=false;$item.addClass("is-active");var is_design_2014=$playlist.hasClass("fv-playlist-design-2014");if((is_design_2014&&$item.find("h4").length==0||!is_design_2014)&&$item.find(".now-playing").length==0)$item.prepend('<strong class="now-playing"><span>'+fv_flowplayer_translations.playlist_current+"</span></strong>");if(!$playlist.parent().find(".flowplayer").length){scroll_parent=true}if(($playlist.hasClass("fp-playlist-vertical")||$playlist.hasClass("fp-playlist-horizontal")&&$playlist.hasClass("is-audio"))&&!fullyVisibleY($item.get(0))){var $el=scroll_parent?$playlist.parent():$playlist;$el.animate({scrollTop:$el.scrollTop()+($item.position().top-$el.position().top)},750)}else if($playlist.hasClass("fp-playlist-horizontal")&&!fullyVisibleX($item.get(0))){var $el=scroll_parent?$playlist.parent():$playlist;$el.animate({scrollLeft:$el.scrollLeft()+($item.position().left-$el.position().left)},750)}function fullyVisibleY(el){var rect=el.getBoundingClientRect(),top=rect.top,height=rect.height,bottom=top+height,el=el.parentNode;do{rect=el.getBoundingClientRect();if(bottom<=rect.bottom===false)return false;if(top<=rect.top)return false;el=el.parentNode}while(el!=document.body);return bottom<=document.documentElement.clientHeight}function fullyVisibleX(el){var rect=el.getBoundingClientRect(),left=rect.left,width=rect.width,right=left+width,el=el.parentNode;do{rect=el.getBoundingClientRect();if(right<=rect.right===false)return false;if(left<=rect.left)return false;el=el.parentNode}while(el!=document.body);return right<=document.documentElement.clientWidth}}var fv_fp_date=new Date;var fv_fp_utime=fv_fp_date.getTime();function fv_parse_sharelink(src){src=src.replace("https?://[^./].","");var prefix="fvp_";if(src.match(/(youtube.com)/)){return prefix+src.match(/(?:v=)([A-Za-z0-9_-]*)/)[1]}else if(src.match(/(vimeo.com)|(youtu.be)/)){return prefix+src.match(/(?:\/)([^/]*$)/)[1]}else{var match=src.match(/(?:\/)([^/]*$)/);if(match){return prefix+match[1].match(/^[^.]*/)[0]}}return prefix+src}function fv_player_get_video_link_hash(api){var hash=fv_parse_sharelink(typeof api.video.sources_original!="undefined"&&typeof api.video.sources_original[0]!="undefined"?api.video.sources_original[0].src:api.video.sources[0].src);if(typeof api.video.id!="undefined"){hash=fv_parse_sharelink(api.video.id.toString())}return hash}function fv_player_time_hms(seconds){if(isNaN(seconds)){return NaN}var sec_num=parseInt(seconds,10);var hours=Math.floor(sec_num/3600);var minutes=Math.floor(sec_num/60)%60;var seconds=sec_num%60;if(hours){hours+="h"}else{hours=""}if(hours&&minutes<10){minutes="0"+minutes+"m"}else if(minutes){minutes+="m"}else{minutes=""}if((hours||minutes)&&seconds<10){seconds="0"+seconds}seconds+="s";var timeString=hours+minutes+seconds;return timeString}function fv_player_time_hms_ms(seconds){if(isNaN(seconds)){return NaN}seconds=parseFloat(seconds).toFixed(3);var miliseconds=(seconds+"").split(".");if(typeof miliseconds[1]!="undefined"&&miliseconds[1]>0){miliseconds=miliseconds[1]+"ms"}else{miliseconds=""}var timeString=fv_player_time_hms(seconds)+miliseconds;return timeString}function fv_player_time_seconds(time,duration){if(!time)return-1;var seconds=0;var match=time.match(/(\d+[a-z]{1,2})/g);match.forEach(function(item){if(item.endsWith("h")){seconds+=3600*parseInt(item)}else if(item.endsWith("m")){seconds+=60*parseInt(item)}else if(item.endsWith("s")&&!item.endsWith("ms")){seconds+=parseInt(item)}else if(item.endsWith("ms")){if(parseInt(item)){seconds+=parseInt(item)/1e3}}});return duration?Math.min(seconds,duration):seconds}function fv_autoplay_init(root,index,time,abStart,abEnd){if(fv_autoplay_exec_in_progress)return;fv_autoplay_exec_in_progress=true;var api=root.data("flowplayer");if(!api)return;var fTime=fv_player_time_seconds(time);abEnd=fv_player_time_seconds(abEnd);abStart=fv_player_time_seconds(abStart);if(root.parent().hasClass("ui-tabs-panel")){var tabId=root.parent().attr("id");jQuery("[aria-controls="+tabId+"] a").trigger("click")}if(!root.find(".fp-player").attr("class").match(/\bis-sticky/)){var offset=jQuery(root).offset().top-(jQuery(window).height()-jQuery(root).height())/2;window.scrollTo(0,offset);api.one("ready",function(){window.scrollTo(0,offset)})}if(root.hasClass("lightboxed")){setTimeout(function(){jQuery("[href=\\#"+root.attr("id")+"]").trigger("click")},0)}if(index){if(fv_player_video_link_autoplay_can(api,parseInt(index))){if(api.ready){fv_player_video_link_seek(api,fTime)}else{api.play(parseInt(index));api.one("ready",function(){fv_player_video_link_seek(api,fTime,abEnd,abStart)})}}else if(flowplayer.support.inlineVideo){api.one(api.playing?"progress":"ready",function(e,api){api.play(parseInt(index));api.one("ready",function(){fv_player_video_link_seek(api,fTime,abEnd,abStart)})});root.find(".fp-splash").attr("src",jQuery("[rel="+root.attr("id")+"] div").eq(index).find("img").attr("src"));if(!fv_player_in_iframe()){fv_player_notice(root,fv_flowplayer_translations[11],"progress")}}}else{if(api.ready){fv_player_video_link_seek(api,fTime)}else{if(fv_player_video_link_autoplay_can(api)){api.load()}else if(!fv_player_in_iframe()){fv_player_notice(root,fv_flowplayer_translations[11],"progress")}api.one("ready",function(){fv_player_video_link_seek(api,fTime,abEnd,abStart)})}}}function fv_player_video_link_seek(api,fTime,abEnd,abStart){fv_autoplay_exec_in_progress=false;var do_seek=setInterval(function(){if(api.loading)return;if(fTime>0||api.video.time>0){if(!!api.custom_seek){api.custom_seek(fTime)}else{api.seek(fTime)}}if(abEnd&&abStart)api.trigger("link-ab",[api,abStart,abEnd]);clearInterval(do_seek)},10)}var fv_autoplay_exec_in_progress=false;function fv_autoplay_exec(){var autoplay=true;if(typeof flowplayer!=="undefined"&&typeof fv_flowplayer_conf!="undefined"&&fv_flowplayer_conf.video_hash_links&&window.location.hash.substring(1).length){var aHash=window.location.hash.match(/\?t=/)?window.location.hash.substring(1).split("?t="):window.location.hash.substring(1).split(",");var hash=aHash[0];var time=aHash[1]===undefined?false:aHash[1];var abStart=aHash[2]===undefined?false:aHash[2];var abEnd=aHash[3]===undefined?false:aHash[3];jQuery(".flowplayer").each(function(){var root=jQuery(this);if(root.hasClass("lightbox-starter")){root=jQuery(root.attr("href"))}var api=root.data("flowplayer");if(!api)return;var playlist=typeof api.conf.playlist!=="undefined"&&api.conf.playlist.length>1?api.conf.playlist:[api.conf.clip];for(var item in playlist){if(!playlist.hasOwnProperty(item))continue;var id=typeof playlist[item].id!=="undefined"?fv_parse_sharelink(playlist[item].id.toString()):false;if(hash===id&&autoplay){console.log("fv_autoplay_exec for "+id,item);fv_autoplay_init(root,parseInt(item),time,abStart,abEnd);autoplay=false;return false}}for(var item in playlist){if(!playlist.hasOwnProperty(item))continue;var src=fv_parse_sharelink(playlist[item].sources[0].src);if(hash===src&&autoplay){console.log("fv_autoplay_exec for "+src,item);fv_autoplay_init(root,parseInt(item),time,abStart,abEnd);autoplay=false;return false}}})}if(autoplay&&flowplayer.support.firstframe){jQuery(".flowplayer[data-fvautoplay]").each(function(){var root=jQuery(this),api=root.data("flowplayer"),autoplay=root.attr("data-fvautoplay");if(!fv_player_did_autoplay&&autoplay){if((flowplayer.support.android||flowplayer.support.iOS)&&api&&api.conf.clip.sources[0].type=="video/youtube"){console.log("FV Player: Autoplay for YouTube not supported on Android and iOS");return}else{fv_player_did_autoplay=true;if(api.conf.playlist.length&&!isNaN(parseFloat(autoplay))&&isFinite(autoplay)){api.play(parseInt(autoplay))}else{api.load()}var play_icon=root.find(".fp-play").addClass("invisible"),control_bar=root.find(".fp-controls").addClass("invisible");api.one("progress",function(){play_icon.removeClass("invisible");control_bar.removeClass("invisible")});if(autoplay=="muted"){api.mute(true,true)}}}})}}function fv_player_video_link_autoplay_can(api,item){var video=item?api.conf.playlist[item]:api.conf.clip;if(video.sources[0].type=="video/youtube"&&(flowplayer.support.iOS||flowplayer.support.android)||fv_player_in_iframe())return false;return flowplayer.support.firstframe}function fv_player_notice(root,message,timeout){var notices=jQuery(".fvfp-notices",root);if(!notices.length){notices=jQuery('<div class="fvfp-notices">');jQuery(".fp-player",root).append(notices)}var notice=jQuery('<div class="fvfp-notice-content">'+message+"</div></div>");notices.append(notice);if(typeof timeout=="string"){var player=jQuery(root).data("flowplayer");player.on(timeout,function(){notice.fadeOut(100,function(){jQuery(this).remove()})})}if(timeout>0){setTimeout(function(){notice.fadeOut(2e3,function(){jQuery(this).remove()})},timeout)}return notice}var fv_player_clipboard=function(text,successCallback,errorCallback){try{fv_player_doCopy(text);successCallback()}catch(e){if(typeof errorCallback!="undefined")errorCallback(e)}};function fv_player_doCopy(text){var textarea=document.createElement("textarea");textarea.value=text;textarea.style.opacity=0;textarea.style.position="absolute";textarea.setAttribute("readonly",true);document.body.appendChild(textarea);var selected=document.getSelection().rangeCount>0?document.getSelection().getRangeAt(0):false;if(navigator.userAgent.match(/ipad|ipod|iphone/i)){var editable=textarea.contentEditable;textarea.contentEditable=true;var range=document.createRange();range.selectNodeContents(textarea);var sel=window.getSelection();sel.removeAllRanges();sel.addRange(range);textarea.setSelectionRange(0,999999);textarea.contentEditable=editable}else{textarea.select()}try{var result=document.execCommand("copy");if(selected){document.getSelection().removeAllRanges();document.getSelection().addRange(selected)}document.body.removeChild(textarea);return result}catch(err){throw new Error("Unsuccessfull")}}flowplayer(function(api,root){root=jQuery(root);if(typeof api.conf.disable_localstorage!="undefined"){return}var hlsjs;flowplayer.engine("hlsjs-lite").plugin(function(params){hlsjs=params.hls;hlsjs.on(Hls.Events.ERROR,function(event,data){if(data.type=="mediaError"&&data.details=="fragParsingError"&&data.fatal==true){hlsjs.destroy();api.trigger("error",[api,{code:3}]);setTimeout(function(){root.removeClass("is-seeking");root.addClass("is-paused")},0)}});if(flowplayer.support.browser.safari){hlsjs.on(Hls.Events.KEY_LOADED,function(event){if(event=="hlsKeyLoaded"){setTimeout(function(){if(api.loading){console.log("FV Player: Safari stuck loading HLS, resuming playback...");api.resume()}},0)}})}var pick_quality=flowplayer.conf.hd_streaming&&!flowplayer.support.fvmobile?720:false;if(jQuery(params.root).data("hd_streaming")==false)pick_quality=false;if(localStorage.FVPlayerHLSQuality)pick_quality=localStorage.FVPlayerHLSQuality;if(pick_quality){hlsjs.on(Hls.Events.MANIFEST_PARSED,function(_,data){var found=false;jQuery.each(data.levels,function(k,v){if(v.height==pick_quality)found=k});if(!localStorage.FVPlayerHLSQuality&&!found){jQuery.each(data.levels,function(k,v){if(v.height>found)found=k})}if(found){console.log("FV Player: Picked "+data.levels[found].height+"p quality");hlsjs.startLevel=found;hlsjs.currentLevel=found}})}});root=jQuery(root);var search=document.location.search;if(localStorage.FVPlayerDashQuality){if(!api.conf.dash)api.conf.dash={};api.conf.dash.initialVideoQuality="restore"}root.on("click",".fp-qsel-menu a",function(){if(api.engine.engineName=="hlsjs-lite"){var quality=jQuery(this).data("quality");if(quality==-1){localStorage.removeItem("FVPlayerHLSQuality")}else{var level=hlsjs.levels[quality];localStorage.FVPlayerHLSQuality=level.height}}});if(localStorage.FVPlayerHLSQuality){api.conf.hlsjs.startLevel=parseInt(localStorage.FVPlayerHLSQuality);api.conf.hlsjs.testBandwidth=false;api.conf.hlsjs.autoLevelEnabled=false}else if(flowplayer.conf.hd_streaming&&!flowplayer.support.fvmobile){api.conf.hlsjs.startLevel=3;api.conf.hlsjs.testBandwidth=false;api.conf.hlsjs.autoLevelEnabled=false}api.bind("quality",function(e,api,quality){if(api.engine.engineName=="dash"){if(quality==-1){localStorage.removeItem("FVPlayerDashQuality")}else if(bitrates[quality]){localStorage.FVPlayerDashQuality=bitrates[quality].height}}});var bitrates=[];var last_quality=-1;api.bind("ready",function(e,api){root.find(".fp-qsel-menu strong").text(fv_flowplayer_translations.quality);if(api.engine.engineName=="dash"){bitrates=api.engine.dash.getBitrateInfoListFor("video");if(localStorage.FVPlayerDashQuality&&api.conf.dash.initialVideoQuality){api.quality(api.conf.dash.initialVideoQuality)}quality_sort()}else if(api.engine.engineName=="hlsjs-lite"){root.addClass("is-loading");api.loading=true;api.one("progress",function(){if(api.loading){root.removeClass("is-loading");api.loading=false}});if(api.video.qualities&&api.video.qualities.length>2){var qswitch=-1;if(localStorage.FVPlayerHLSQuality){jQuery(api.video.qualities).each(function(k,v){if(v.value==localStorage.FVPlayerHLSQuality){qswitch=localStorage.FVPlayerHLSQuality;return false}})}else if(flowplayer.conf.hd_streaming&&!flowplayer.support.fvmobile){jQuery(api.video.qualities).each(function(k,v){var height=parseInt(v.label);if(height>0&&qswitch==-1&&height>=720&&height<=720){qswitch=v.value}})}qswitch=parseInt(qswitch);if(qswitch>-1){root.one("progress",function(){setTimeout(function(){api.quality(qswitch)})})}quality_sort()}}else if(api.video.sources_fvqs&&api.video.sources_fvqs.length>0&&api.video.src.match(/vimeo.*?\.mp4/)){setTimeout(quality_sort,0)}root.find("a[data-quality]").removeClass("is-current")});if(search.match(/dash_debug/)||search.match(/hls_debug/))var debug_log=jQuery('<div class="fv-debug" style="background: gray; color: white; top: 10%; position: absolute; z-index: 1000">').appendTo(root.find(".fp-player"));api.bind("ready progress",quality_process);api.bind("quality",function(){setTimeout(quality_process,0)});function quality_process(){if(api.engine.engineName=="dash"){var stream_info=bitrates[api.engine.dash.getQualityFor("video")];if(stream_info.qualityIndex!=last_quality){last_quality=stream_info.qualityIndex;quality_label(stream_info.qualityIndex,bitrates)}if(search.match(/dash_debug/))quality_debug(stream_info.width,stream_info.height,stream_info.bitrate)}else if(api.engine.engineName=="hlsjs-lite"){if(hlsjs.currentLevel!=last_quality){last_quality=hlsjs.currentLevel;quality_label(hlsjs.currentLevel,hlsjs.levels)}if(search.match(/hls_debug/)){var level=hlsjs.levels[hlsjs.currentLevel];if(level){quality_debug(level.width,level.height,level.bitrate)}}}}function quality_label(index,qualities){if(!qualities[index])return;var height=qualities[index].height,hd_limit=541,lowest=1e5;jQuery(qualities).each(function(k,v){if(v.height>=720&&v.height<1400)hd_limit=720;if(v.height<lowest)lowest=v.height;if(localStorage.FVPlayerHLSQuality==v.height){root.find("a[data-quality]").removeClass("fp-selected fp-color");root.find("a[data-quality="+k+"]").addClass("fp-selected fp-color")}});root.find("a[data-quality]").removeClass("is-current");root.find("a[data-quality="+index+"]").addClass("is-current");var label="SD";if(height>=360&&lowest<height)label="SD";if(height>=hd_limit)label="HD";if(height>=1400)label="4K";root.find(".fp-qsel").html(label)}function quality_debug(w,h,br){debug_log.html("Using "+w+"x"+h+" at "+Math.round(br/1024)+" kbps")}function quality_sort(){var menu=root.find(".fp-qsel-menu");menu.children().each(function(i,a){menu.prepend(a)});menu.children().each(function(i,a){if(/^NaNp/.test(jQuery(a).html())){var bitrate=jQuery(a).html().match(/\((.*?)\)/);if(bitrate&&typeof bitrate[1]!=="undefined"){jQuery(a).html(bitrate[1])}}else{jQuery(a).html(jQuery(a).html().replace(/\(.*?\)/,""))}});menu.prepend(menu.find("a[data-quality=-1]"));menu.prepend(menu.find("strong"))}});flowplayer(function(api,root){root=jQuery(root);var player_id=root.attr("id"),ad=false;if(root.data("end_popup_preview")){jQuery(document).ready(function(){api.trigger("finish",[api])})}function ad_height_check(){var count=0;var ad_height_check=setInterval(function(){var height=ad&&ad.find(".adsbygoogle").height();count++;if(count>20*10||height>0)clearInterval(ad_height_check);if(height>root.height()){ad.addClass("tall-ad")}},50)}function show_ad(){var ad_data=root.attr("data-ad");if(typeof ad_data!="undefined"&&ad_data.length){try{ad_data=JSON.parse(ad_data)}catch(e){return false}if(!ad&&!root.hasClass("is-cva")&&root.width()>=parseInt(ad_data.width)){var html=ad_data.html;html=html.replace("%random%",Math.random());ad=jQuery('<div id="'+player_id+'_ad" class="wpfp_custom_ad">'+html+"</div>");root.find(".fp-player").append(ad);ad_height_check();setTimeout(function(){if(root.find(".wpfp_custom_ad video").length){api.pause()}},500)}}}function show_popup(event){var popup_data=root.attr("data-popup");if(typeof popup_data!="undefined"&&popup_data.length){try{popup_data=JSON.parse(popup_data)}catch(e){return false}if(event=="finish"||popup_data.pause||popup_data.html.match(/fv-player-ppv-purchase-btn-wrapper/)){root.addClass("is-popup-showing");root.find(".fp-player").append('<div id="'+player_id+'_custom_popup" class="wpfp_custom_popup">'+popup_data.html+"</div>")}}}api.bind("ready",function(e,api){if(ad.length==1){ad.remove();ad=false}if(!root.data("ad_show_after")){show_ad()}}).bind("progress",function(e,api,current){if(current>root.data("ad_show_after")){show_ad()}}).bind("finish",function(e,api){if(typeof api.video.index=="undefined"||api.video.index+1==api.conf.playlist.length){show_popup(e.type)}}).bind("pause",function(e,api){show_popup(e.type)}).bind("resume unload seek",function(e,api){if(root.hasClass("is-popup-showing")){root.find(".wpfp_custom_popup").remove();root.removeClass("is-popup-showing")}})});jQuery(document).on("click",".fv_fp_close",function(){var ad=jQuery(this).parents(".wpfp_custom_ad_content"),video=ad.find("video");ad.fadeOut();if(video.length)video[0].pause();return false});jQuery(document).on("focus",".fv_player_popup input[type=text], .fv_player_popup input[type=email], .fv_player_popup textarea",function(){var api=jQuery(this).parents(".flowplayer").data("flowplayer");if(api)api.disable(true)});jQuery(document).on("blur",".fv_player_popup input[type=text], .fv_player_popup input[type=email], .fv_player_popup textarea",function(){var api=jQuery(this).parents(".flowplayer").data("flowplayer");if(api)api.disable(false)});flowplayer(function(api,root){api.on("ready",function(e,api,video){api.one("progress",function(){jQuery(root).find(".fp-airplay").toggle(api.engine.engineName=="html5")})})});flowplayer(function(api,root){var root=jQuery(root),bean=flowplayer.bean,time=0,last=0,timer,event_name;if(typeof ga=="undefined"&&api.conf.fvanalytics&&typeof _gat=="undefined"&&typeof gtag=="undefined"){if(is_ga_4(api)){jQuery.getScript({url:"https://www.googletagmanager.com/gtag/js?id="+api.conf.fvanalytics,cache:true},function(){window.dataLayer=window.dataLayer||[];window.gtag=function(){window.dataLayer.push(arguments)};window.gtag("js",new Date);window.gtag("config",api.conf.fvanalytics)})}else{jQuery.getScript({url:"https://www.google-analytics.com/analytics.js",cache:true},function(){ga("create",api.conf.fvanalytics,"auto")})}}if(!window._paq&&api.conf.matomo_domain&&api.conf.matomo_site_id){var u="//"+api.conf.matomo_domain+"/";var _paq=window._paq=window._paq||[];_paq.push(["setTrackerUrl",u+"matomo.php"]);_paq.push(["setSiteId",api.conf.matomo_site_id]);var d=document,g=d.createElement("script"),s=d.getElementsByTagName("script")[0];g.type="text/javascript";g.async=true;g.src=u+"matomo.js";s.parentNode.insertBefore(g,s)}api.bind("progress",function(e,api,current){fv_track(e,api,current)}).bind("finish ready ",function(e,api){for(var j in fv_ga_events){if(!fv_ga_events.hasOwnProperty(j))continue;root.removeData("fv_track_"+fv_ga_events[j])}}).bind("error",function(e,api,error){setTimeout(function(){if(!api.error)return;var video=typeof api.video!="undefined"&&typeof api.video.src!="undefined"?api.video:false;if(!video&&typeof api.conf.clip!="undefined"&&typeof api.conf.clip.sources!="undefined"&&typeof api.conf.clip.sources[0]!="undefined"&&typeof api.conf.clip.sources[0].src!="undefined")video=api.conf.clip.sources[0];var name=fv_player_track_name(root,video);if(name&&!name.match(/\/\/vimeo.com\/\d/)){if(is_ga_4(api)){}else{fv_player_track(api,false,"Video "+(root.hasClass("is-cva")?"Ad ":"")+"error",error.message,name)}}},100)});api.bind("load unload",fv_track_seconds_played).bind("progress",function(e,api){if(!api.seeking){time+=last?+new Date-last:0;last=+new Date}if(!timer){timer=setTimeout(function(){timer=null;if(!is_ga_4(api)){fv_player_track(api,false,"Flowplayer heartbeat",api.engine.engineName+"/"+api.video.type,"Heartbeat",0)}},10*60*1e3)}}).bind("pause",function(){last=0});api.bind("shutdown",function(){bean.off(window,"unload",fv_track_seconds_played)});bean.on(window,"unload",fv_track_seconds_played);var fv_ga_events=is_ga_4(api)?["Play","25 Percent Played","50 Percent Played","75 Percent Played","100 Percent Played"]:["start","first quartile","second quartile","third quartile","complete"];function fv_track_seconds_played(e,api_not_needed,video){video=video||api.video;if(e.type==="load"){event_name=fv_player_track_name(root,video)}if(time){fv_player_track(api,false,"Video / Seconds played",api.engine.engineName+"/"+api.video.type,event_name,Math.round(time/1e3));time=0;if(timer){clearTimeout(timer);timer=null}}}function fv_track(e,api,data){var video=api.video,dur=video.duration,i=0;var name=fv_player_track_name(root,video);if(dur){if(data>19*dur/20)i=4;else if(data>3*dur/4)i=3;else if(data>dur/2)i=2;else if(data>dur/4)i=1}if(api.live)i=0;if(root.data("fv_track_"+fv_ga_events[i]))return;for(var j in fv_ga_events){if(!fv_ga_events.hasOwnProperty(j))continue;if(j==i)break;if(!root.data("fv_track_"+fv_ga_events[j]))return}root.trigger("fv_track_"+fv_ga_events[i].replace(/ /,"_"),[api,name]);root.data("fv_track_"+fv_ga_events[i],true);fv_player_track(api,false,"Video "+(root.hasClass("is-cva")?"Ad ":"")+fv_ga_events[i],api.engine.engineName+"/"+video.type,name)}api.get_time_played=function(){return time/1e3}});function is_ga_4(api){if(typeof api.conf.fvanalytics!="undefined"&&api.conf.fvanalytics&&api.conf.fvanalytics.startsWith("G-"))return true;return false}function fv_player_track(api,ga_id,event,engineType,name,value){if(!ga_id)ga_id=flowplayer.conf.fvanalytics;if(typeof engineType=="undefined")engineType="Unknown engine";if(/fv_player_track_debug/.test(window.location.href))console.log("FV Player Track: "+event+" - "+engineType+" '"+name+"'",value);if(typeof gtag!="undefined"){if(is_ga_4(api)){gtag("event",event,{video_current_time:api.video.time,video_provider:engineType,video_duration:api.video.duration,value:value?value:1})}else{gtag("event",event,{event_category:engineType,event_label:name,value:value?value:1})}}else if(ga_id&&typeof ga!="undefined"){ga("create",ga_id,"auto",name,{allowLinker:true});ga("require","linker");if(value){ga("send","event",event,engineType,name,value)}else{ga("send","event",event,engineType,name)}}else if(ga_id&&typeof _gat!="undefined"){var tracker=_gat._getTracker(ga_id);if(typeof tracker._setAllowLinker=="undefined"){return}tracker._setAllowLinker(true);if(value){tracker._trackEvent(event,engineType,name,value)}else{tracker._trackEvent(event,engineType,name)}}if(flowplayer.conf.matomo_domain&&flowplayer.conf.matomo_site_id&&typeof _paq!="undefined"){if(value){_paq.push(["trackEvent",event,engineType,name,value])}else{_paq.push(["trackEvent",event,engineType,name])}}}function fv_player_track_name(root,video){var name=root.attr("title");if(!name&&typeof video.fv_title!="undefined")name=video.fv_title;if(!name&&typeof video.title!="undefined")name=video.title;if(!name&&typeof video.src!="undefined"){name=video.src.split("/").slice(-1)[0].replace(/\.(\w{3,4})(\?.*)?$/i,"");if(video.type.match(/mpegurl/))name=video.src.split("/").slice(-2)[0].replace(/\.(\w{3,4})(\?.*)?$/i,"")+"/"+name}return name}flowplayer(function(api,root){root=jQuery(root);var player=root.find(".fp-player"),had_no_volume=root.hasClass("no-volume"),had_fp_mute=root.hasClass("fp-mute"),had_fp_full=root.hasClass("fp-full"),buttons_count=0;function check_size(){var width=player.width()||root.width(),video_index=api.video.index?api.video.index:0;if(width>900){jQuery(".fp-subtitle",root).addClass("is-wide")}else{jQuery(".fp-subtitle",root).removeClass("is-wide")}root.toggleClass("is-tiny",width<400);root.toggleClass("is-small",width<600&&width>=400);var too_narrow=width<480+buttons_count*35;if(typeof api.fv_timeline_chapters_data!="undefined"&&typeof api.fv_timeline_chapters_data[video_index]!="undefined"){too_narrow=true}if(!had_fp_full){root.toggleClass("fp-full",root.hasClass("has-abloop")||too_narrow)}var size="";if(width<400)size="is-tiny";else if(width<600&&width>=400)size="is-small";root.trigger("fv-player-size",[size]);var el=player;if(root.parent().hasClass("fp-playlist-vertical-wrapper")||root.parent().hasClass("fp-playlist-text-wrapper"))el=root.parent();if(el.width()<=560){el.addClass("is-fv-narrow")}else{el.removeClass("is-fv-narrow")}if(width<=320){root.addClass("no-volume fp-mute")}else{if(!had_no_volume)root.removeClass("no-volume");if(!had_fp_mute)root.removeClass("fp-mute")}}check_size();jQuery(window).on("resize",check_size);api.on("ready fullscreen fullscreen-exit sticky sticky-exit",function(e){setTimeout(function(){buttons_count=root.find(".fp-controls > strong:visible").length+root.find(".fp-controls > .fp-icon:visible").length;check_size()},0)});api.on("unload pause finish error",function(){if(typeof checker!=="undefined")clearInterval(checker)})});jQuery(window).on("resize tabsactivate",function(){jQuery(".fp-playlist-external").each(function(){var playlist=jQuery(this);if(playlist.parent().width()>=900)playlist.addClass("is-wide");else playlist.removeClass("is-wide")})}).trigger("resize");flowplayer(function(api,root){api.bind("ready",function(){if(/Chrome/.test(navigator.userAgent)&&parseFloat(/Chrome\/(\d\d)/.exec(navigator.userAgent)[1],10)>54){if(api.video.subtitles){jQuery(root).addClass("chrome55fix-subtitles")}else{jQuery(root).addClass("chrome55fix")}}});root=jQuery(root);var image_src=root.css("background-image");if(image_src){image_src=image_src.replace(/url\((['"])?(.*?)\1\)/gi,"$2").split(",");if(!image_src||!image_src[0].match(/^(https?:)?\/\//))return;var image=new Image;image.src=image_src[0];var image_ratio=image.height/image.width;var player_ratio=root.height()/root.width();var ratio_diff=Math.abs(player_ratio-image_ratio);if(ratio_diff<.05){root.css("background-size","cover")}}});(function($){$(window).on("resize",function(){var iframe=$("iframe[id][src][height][width]");iframe.each(function(){if($(this).attr("id").match(/(fv_vimeo_)|(fv_ytplayer_)/)&&$(this).width()<=$(this).attr("width"))$(this).height($(this).width()*$(this).attr("height")/$(this).attr("width"))});var wistia=jQuery(".wistia_embed");wistia.each(function(){$(this).height($(this).width()*$(this).data("ratio"))})}).trigger("resize")})(jQuery);jQuery(document).on("tabsactivate",".fv_flowplayer_tabs_content",function(event,ui){var oldPlayer=jQuery(ui.oldPanel).find(".flowplayer").data("flowplayer");if(typeof oldPlayer!="undefined"){oldPlayer.pause()}var objPlayer=jQuery(".flowplayer",ui.newPanel);var api=objPlayer.data("flowplayer");api.load()});flowplayer(function(api,root){root=jQuery(root);var bean=flowplayer.bean;if(root.hasClass("is-audio")){bean.off(root[0],"mouseenter");bean.off(root[0],"mouseleave");root.removeClass("is-mouseout");root.addClass("fixed-controls").addClass("is-mouseover");api.on("error",function(e,api,error){jQuery(".fp-message",root).html(jQuery(".fp-message",root).html().replace(/video/,"audio"))});root.on("click",function(e){if(!api.ready){e.preventDefault();e.stopPropagation();api.load()}})}});flowplayer(function(api,root){if(!api.conf.fv_chromecast)return;if(!window["__onGCastApiAvailable"]){jQuery.getScript({url:"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js",cache:true});window["__onGCastApiAvailable"]=function(loaded){if(!loaded)return;initialize()}}var conf=api.conf.chromecast||{},session,timer,trigger,bean=flowplayer.bean,common=flowplayer.common,waiting_for_seek=false;function initialize(){var applicationId,sessionRequest,apiConfig;applicationId=conf.applicationId||chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID;sessionRequest=new chrome.cast.SessionRequest(applicationId);apiConfig=new chrome.cast.ApiConfig(sessionRequest,sessionListener,receiverListener);chrome.cast.initialize(apiConfig,onInitSuccess,onError)}function sessionListener(){}function receiverListener(ev){console.log("FV Player: Chromecast listener",ev);if(ev!==chrome.cast.ReceiverAvailability.AVAILABLE)return;flowplayer.conf.chromecast_available=true}function onInitSuccess(){}function onError(){console.log("chromecast onError")}function createUIElements(){var btnContainer=common.find(".fp-header",root)[0];if(!btnContainer)return;common.find(".fp-chromecast",btnContainer).forEach(common.removeNode);common.find(".fp-chromecast-engine",root).forEach(common.removeNode);trigger=common.createElement("a",{class:"fp-chromecast fp-icon",title:"Play on Cast device"});btnContainer.appendChild(trigger);var chromeCastEngine=common.createElement("div",{class:"fp-chromecast-engine"}),chromeCastStatus=common.createElement("p",{class:"fp-chromecast-engine-status"}),chromeCastIcon=common.createElement("p",{class:"fp-chromecast-engine-icon"});chromeCastEngine.appendChild(chromeCastIcon);chromeCastEngine.appendChild(chromeCastStatus);var engine=common.find(".fp-engine",root)[0];if(!engine)common.prepend(common.find(".fp-player",root)[0]||root,chromeCastEngine);else engine.parentNode.insertBefore(chromeCastEngine,engine)}function destroy(){clearInterval(timer);timer=null;api.release();common.toggleClass(root,"is-chromecast",false);common.toggleClass(trigger,"fp-active",false)}function get_media(){var media=false;var sources=api.video.sources_fvqs||api.video.sources;for(var i in sources){var type=sources[i].type;if(type=="video/mp4"||type=="video/fv-mp4"||type=="application/dash+xml"){media=sources[i];break}}if(!media){for(var i in sources){if(sources[i].type=="application/x-mpegurl"){media=sources[i];break}}}if(api.video.fvhkey&&!api.conf.hls_cast)return false;if(media){var top_quality=false,mp4_qualities=["fullhd","hd","md","sd"];for(var quality in mp4_qualities){var re=new RegExp("-"+mp4_qualities[quality]);for(var i in api.video.sources_fvqs){var source=api.video.sources_fvqs[i];if(source.src.match(re)&&source.type=="video/mp4"){top_quality=source;break}}if(top_quality){media=top_quality;break}}}return media}function load_media(){var media=get_media();if(!media){return false}var cast_subtitles=[];if(api.video.subtitles){api.video.subtitles.forEach(function(v,k){if(v.src.match(/\.srt/)){console.log("FV Player: Chromecast doesn't support SRT subtitles")}var subtitles=new chrome.cast.media.Track(k,chrome.cast.media.TrackType.TEXT);subtitles.trackContentId=v.src;subtitles.trackContentType="text/vtt";subtitles.subtype=chrome.cast.media.TextTrackType.SUBTITLES;subtitles.name=v.label;subtitles.language=v.srclang+"-"+k,subtitles.customData=null;cast_subtitles.push(subtitles)})}var mediaInfo=new chrome.cast.media.MediaInfo(media.src,media.type);mediaInfo.tracks=cast_subtitles;var request=new chrome.cast.media.LoadRequest(mediaInfo);if(!api.live){request.currentTime=api.video.time}clearInterval(timer);timer=false;session.loadMedia(request,onMediaDiscovered,function onMediaError(e){console.log("onMediaError",e)})}function onMediaDiscovered(chromecast){switch_tracks(chromecast);chromecast.addUpdateListener(function(alive){if(!session)return;timer=timer||setInterval(function(){api.trigger("progress",[api,chromecast.getEstimatedTime()]);chromecast.activeTrackIds.forEach(function(track_id){jQuery.each(chromecast.media.tracks,function(k,v){if(v.trackId==track_id&&v.type=="AUDIO"){var found=hilight_audio_track("data-audio",v.language);if(!found){hilight_audio_track("data-lang",v.language)}return false}})})},500);if(alive){common.toggleClass(root,"is-chromecast",true);common.toggleClass(trigger,"fp-active",true);api.hijack({pause:function(){console.log("hijacked pause!");chromecast.pause()},resume:function(){if(api.finished){clearInterval(timer);timer=null;api.release();load_media();return}chromecast.play()},seek:function(time){var req=new chrome.cast.media.SeekRequest;req.currentTime=time;chromecast.seek(req)}})}var playerState=chromecast.playerState;if(api.paused&&playerState===chrome.cast.media.PlayerState.PLAYING)api.trigger("resume",[api]);if(api.playing&&playerState===chrome.cast.media.PlayerState.PAUSED)api.trigger("pause",[api]);if(api.seeking&&playerState===chrome.cast.media.PlayerState.BUFFERING){waiting_for_seek=true}if(api.seeking&&playerState===chrome.cast.media.PlayerState.PLAYING&&waiting_for_seek){waiting_for_seek=false;api.trigger("seek",[api])}if(playerState==chrome.cast.media.PlayerState.IDLE&&chromecast.idleReason==chrome.cast.media.IdleReason.FINISHED){api.trigger("finish",[api])}common.toggleClass(root,"is-loading",playerState===chrome.cast.media.PlayerState.BUFFERING)})}api.bind("ready",function(e,api,video){if(session){if(get_media()){api.one("progress",function(e,api){api.release();api.pause();api.mute(false,true);load_media()});api.mute(true,true)}else{session.stop();session=null;destroy();jQuery(trigger).hide()}return}if(!flowplayer.conf.chromecast_available)return;if(get_media()){createUIElements();jQuery(trigger).show()}else{FV_Flowplayer_Pro.log("FV Player: Can't find media source suitable for Chromecast!");jQuery(trigger).hide()}});bean.on(root,"click",".fp-chromecast",function(ev){ev.preventDefault();if(session){api.trigger("pause",[api]);if(session.media[0].media){var seek=session.media[0].getEstimatedTime();setTimeout(function(){api.seek(seek)},0)}session.stop();session=null;destroy();return}if(api.playing)api.pause();chrome.cast.requestSession(function(s){jQuery(root).addClass("is-loading");session=s;var receiverName=session.receiver.friendlyName;common.html(common.find(".fp-chromecast-engine-status",root)[0],"Playing on device "+receiverName);load_media()},function(err){console.error("requestSession error",err)})});bean.on(root,"click",".fv-fp-hls-menu [data-audio], .fp-subtitle-menu [data-subtitle-index]",function(){if(session&&session.media[0].media){switch_tracks(session.media[0]);return false}});jQuery(window).on("unload",function(){if(session){session.stop()}});function hilight_audio_track(attr,chromecast_language){var audio_tracks_menu=jQuery(root).find(".fv-fp-hls-menu a"),found=false;audio_tracks_menu.each(function(k,el){if(jQuery(el).attr(attr)===chromecast_language){jQuery(el).addClass("fp-selected");found=true}else{jQuery(el).removeClass("fp-selected")}});return found}function switch_tracks(chromecast){console.log(chromecast.media.tracks);var audio=jQuery(root).find(".fv-fp-hls-menu [data-audio].fp-selected").data("audio"),audio_lang=jQuery(root).find(".fv-fp-hls-menu [data-audio].fp-selected").data("lang"),subtitle_index=jQuery(root).find(".fp-subtitle-menu [data-subtitle-index].fp-selected").data("subtitle-index"),subtitles=subtitle_index>-1?api.video.subtitles[subtitle_index].srclang:false;var audio_found=false,subtitles_found=false,tracks_selected=[];jQuery.each(chromecast.media.tracks,function(k,v){if(v.language==audio&&v.type=="AUDIO"){audio_found=v}if(v.language==subtitles+"-"+subtitle_index&&v.type=="TEXT"){subtitles_found=v}});if(!audio_found){jQuery.each(chromecast.media.tracks,function(k,v){if(v.language==audio_lang&&v.type=="AUDIO"){audio_found=v;return false}})}var debug_log="";if(audio_found){tracks_selected.push(audio_found.trackId);debug_log+=audio_found.language+" audio"}if(subtitles_found){tracks_selected.push(subtitles_found.trackId);if(debug_log)debug_log+=" ";debug_log+=subtitles_found.language+" subtitles"}if(tracks_selected){var request=new chrome.cast.media.EditTracksInfoRequest(tracks_selected);chromecast.editTracksInfo(request,function(){console.log("FV Player: Chromecast "+debug_log+" loaded")},function(){console.log("FV Player: Chromecast "+debug_log+" failed")})}}});jQuery(document).on("mfpClose",function(){if(typeof jQuery(".flowplayer").data("flowplayer")!="undefined")jQuery(".flowplayer").data("flowplayer").unload()});jQuery(document).on("click",".vc_tta-tab a",function(){var api=jQuery(".flowplayer.is-playing").data("flowplayer");if(api)api.pause()});flowplayer(function(api,root){root=jQuery(root);api.bind("ready",function(){setTimeout(function(){var video=jQuery("video",root);if(video.length>0){video.prop("autoplay",false)}},100);root.find("video.fp-engine").addClass("intrinsic-ignore")})});jQuery(".flowplayer").on("ready",function(e,api){if(/BB10/.test(navigator.userAgent)){api.fullscreen()}});var fv_flowplayer_safety_resize_arr=Array();function fv_flowplayer_safety_resize(){var fv_flowplayer_safety_resize_init=false;jQuery(".flowplayer").each(function(){if(!jQuery(this).is(":visible")||jQuery(this).hasClass("lightboxed")||jQuery(this).hasClass("lightbox-starter")||jQuery(this).hasClass("is-audio"))return;if(jQuery(this).width()<30||jQuery(this).height()<20){fv_flowplayer_safety_resize_init=true;var el=jQuery(this);while(jQuery(el).width()<30||jQuery(el).width()==jQuery(this).width()){if(jQuery(el).parent().length==0)break;el=jQuery(el).parent()}jQuery(this).width(jQuery(el).width());jQuery(this).height(parseInt(jQuery(this).width()*jQuery(this).attr("data-ratio")));fv_flowplayer_safety_resize_arr[jQuery(this).attr("id")]=el}});if(fv_flowplayer_safety_resize_init){jQuery(window).resize(function(){jQuery(".flowplayer").each(function(){if(jQuery(this).hasClass("lightboxed")||jQuery(this).hasClass("lightbox-starter"))return;if(fv_flowplayer_safety_resize_arr[jQuery(this).attr("id")]){jQuery(this).width(fv_flowplayer_safety_resize_arr[jQuery(this).attr("id")].width());jQuery(this).height(parseInt(jQuery(this).width()*jQuery(this).attr("data-ratio")))}})})}}if(typeof flowplayer.conf.safety_resize!="undefined"&&flowplayer.conf.safety_resize){jQuery(document).ready(function(){setTimeout(function(){fv_flowplayer_safety_resize()},10)})}var isIE11=!!navigator.userAgent.match(/Trident.*rv[ :]*11\./);if(isIE11){jQuery(document).ready(function(){jQuery(".fp-waiting").hide()});flowplayer(function(api,root){api.bind("load",function(e){jQuery(e.currentTarget).find(".fp-waiting").show()}).bind("beforeseek",function(e){jQuery(e.currentTarget).find(".fp-waiting").show()}).bind("progress",function(e){jQuery(e.currentTarget).find(".fp-waiting").hide()}).bind("seek",function(e){jQuery(e.currentTarget).find(".fp-waiting").hide()}).bind("fullscreen",function(e){jQuery("#wpadminbar").hide()}).bind("fullscreen-exit",function(e){jQuery("#wpadminbar").show()})})}if(flowplayer.support.browser&&flowplayer.support.browser.msie&&parseInt(flowplayer.support.browser.version,10)<9){jQuery(".flowplayer").each(function(){jQuery(this).css("width",jQuery(this).css("max-width"));jQuery(this).css("height",jQuery(this).css("max-height"))})}if(location.href.match(/elementor-preview=/)){console.log("FV Player: Elementor editor is active");setInterval(fv_player_load,1e3)}else if(location.href.match(/brizy-edit-iframe/)){console.log("FV Player: Brizy editor is active");setInterval(fv_player_load,1e3)}if(window.DELEGATE_NAMES){flowplayer(function(api,root){fv_player_notice(root,fv_flowplayer_translations.chrome_extension_disable_html5_autoplay)})}flowplayer(function(api,root){flowplayer.bean.off(root,"contextmenu")});if(location.href.match(/elementor-preview=/)){console.log("FV Player: Elementor editor is active");setInterval(fv_player_load,1e3)}flowplayer(function(player,root){root=jQuery(root);if(typeof root.data("fv-embed")=="undefined"||!root.data("fv-embed")||root.data("fv-embed")=="false")return;player.embedCode=function(){var video=player.video;var width=root.width();var height=root.height();height+=2;if(root.hasClass("has-chapters")||root.hasClass("has-transcript")){height+=300}if(jQuery(".fp-playlist-external[rel="+root.attr("id")+"]").length>0){height+=150+20}var link=root.data("fv-embed")+"#"+fv_player_get_video_link_hash(player);return'<iframe src="'+link+'" allowfullscreen width="'+width+'" height="'+height+'" frameborder="0" style="max-width:100%"></iframe>'}});jQuery(document).on("click",".flowplayer .embed-code-toggle",function(){var root=jQuery(this).closest(".flowplayer");if(typeof fv_player_editor_conf!="undefined"){fv_player_notice(root,fv_player_editor_translations.embed_notice,2e3);return false}var button=jQuery(this);var player=button.parents(".flowplayer");var api=player.data("flowplayer");if(typeof api.embedCode=="function"){player.find(".embed-code textarea").val(api.embedCode())}fv_player_clipboard(player.find(".embed-code textarea").val(),function(){fv_player_notice(player,fv_flowplayer_translations.embed_copied,2e3)},function(){button.parents(".fvp-share-bar").find(".embed-code").toggle();button.parents(".fvp-share-bar").toggleClass("visible")});return false});flowplayer(function(player,root){if(jQuery(root).data("fullscreen")==false){return}player.one("ready",function(e,api,video){if(jQuery(root).find(".fp-fullscreen").length==0){jQuery(root).find(".fp-header").append('<a class="fp-fullscreen fp-icon"></a>')}});var FS_ENTER="fullscreen",FS_EXIT="fullscreen-exit",FS_SUPPORT=flowplayer.support.fullscreen,win=window,scrollX,scrollY,bean=flowplayer.bean;player.fullscreen=function(flag){if(player.disabled)return;var video=common.find("video.fp-engine",root)[0];if(flowplayer.conf.native_fullscreen&&video&&flowplayer.support.iOS){player.trigger(FS_ENTER,[player]);bean.on(document,"webkitfullscreenchange.nativefullscreen",function(){if(document.webkitFullscreenElement!==video)return;bean.off(document,".nativefullscreen");bean.on(document,"webkitfullscreenchange.nativefullscreen",function(){if(document.webkitFullscreenElement)return;bean.off(document,".nativefullscreen");player.trigger(FS_EXIT,[player])})});video.webkitEnterFullScreen();bean.one(video,"webkitendfullscreen",function(){bean.off(document,"fullscreenchange.nativefullscreen");player.trigger(FS_EXIT,[player]);common.prop(video,"controls",true);common.prop(video,"controls",false)});return}var wrapper=jQuery(root).find(".fp-player")[0];if(flag===undefined)flag=!player.isFullscreen;if(flag){scrollY=win.scrollY;scrollX=win.scrollX}if(FS_SUPPORT){if(flag){["requestFullScreen","webkitRequestFullScreen","mozRequestFullScreen","msRequestFullscreen"].forEach(function(fName){if(typeof wrapper[fName]==="function"){wrapper[fName]({navigationUI:"hide"});if(fName==="webkitRequestFullScreen"&&!document.webkitFullscreenElement){wrapper[fName]()}}})}else{["exitFullscreen","webkitCancelFullScreen","mozCancelFullScreen","msExitFullscreen"].forEach(function(fName){if(typeof document[fName]==="function"){document[fName]()}})}}else{player.trigger(flag?FS_ENTER:FS_EXIT,[player])}return player};var lastClick,common=flowplayer.common;player.on("mousedown.fs",function(){if(+new Date-lastClick<150&&player.ready)player.fullscreen();lastClick=+new Date});player.on(FS_ENTER,function(){common.addClass(root,"is-fullscreen");common.toggleClass(root,"fp-minimal-fullscreen",common.hasClass(root,"fp-minimal"));common.removeClass(root,"fp-minimal");if(!FS_SUPPORT)common.css(root,"position","fixed");player.isFullscreen=true}).on(FS_EXIT,function(){var oldOpacity;common.toggleClass(root,"fp-minimal",common.hasClass(root,"fp-minimal-fullscreen"));common.removeClass(root,"fp-minimal-fullscreen");if(!FS_SUPPORT&&player.engine==="html5"){oldOpacity=root.css("opacity")||"";common.css(root,"opacity",0)}if(!FS_SUPPORT)common.css(root,"position","");common.removeClass(root,"is-fullscreen");if(!FS_SUPPORT&&player.engine==="html5")setTimeout(function(){root.css("opacity",oldOpacity)});player.isFullscreen=false;if(player.engine.engineName!="fvyoutube"){win.scrollTo(scrollX,scrollY)}}).on("unload",function(){if(player.isFullscreen)player.fullscreen()});player.on("shutdown",function(){FULL_PLAYER=null;common.removeNode(wrapper)})});flowplayer(function(api,root){root=jQuery(root);if(flowplayer.conf.wpadmin||jQuery(root).hasClass("is-audio"))return;var playlist=jQuery(".fp-playlist-external[rel="+root.attr("id")+"]"),playlist_with_fullscreen=playlist.hasClass("fp-playlist-season")||playlist.hasClass("fp-playlist-polaroid");fsforce=root.data("fsforce")==true;if(root.data("fullscreen")==false){return}if(flowplayer.conf.mobile_force_fullscreen&&flowplayer.support.fvmobile||!flowplayer.support.fullscreen&&fsforce||playlist_with_fullscreen){if(!flowplayer.support.fullscreen){api.bind("ready",function(){if(api.video.vr)return;api.fullscreen(true)})}root.on("click",function(){if(!api.ready||api.paused)api.fullscreen(true)});jQuery("[rel="+root.attr("id")+"] a").on("click",function(e){if(!api.isFullscreen){api.fullscreen();api.resume()}});api.on("resume",function(){if(api.video.vr)return;if(!api.isFullscreen)api.fullscreen()});api.on("finish",function(){if(api.conf.playlist.length==0||api.conf.playlist.length-1==api.video.index)api.fullscreen(false)}).on("fullscreen",function(a,api){root.addClass("forced-fullscreen")}).on("fullscreen-exit",function(a,api){api.pause();root.removeClass("forced-fullscreen")})}else if(fsforce){var position,unload=root.find(".fp-unload"),is_closing=false;api.isFakeFullscreen=false;unload.show();root.on("click",function(e){if(!api.ready&&e.target!=unload[0])api.fakeFullscreen(true)});unload.on("click",function(e){if(api.ready){api.fullscreen(false)}else if(api.loading){is_closing=true;api.one("resume",function(e){is_closing=false;api.pause()})}api.fakeFullscreen(false);return false});jQuery("[rel="+root.attr("id")+"] a").on("click",function(e){if(!api.isFakeFullscreen){api.fakeFullscreen();api.resume()}});api.on("resume",function(){if(!is_closing&&!api.isFakeFullscreen)api.fakeFullscreen()}).on("finish",function(){if(api.conf.playlist.length==0||api.conf.playlist.length-1==api.video.index)api.fakeFullscreen(false)}).on("fullscreen",function(a,api){root.removeClass("fake-fullscreen")}).on("fullscreen-exit",function(a,api){if(api.isFakeFullscreen)api.fakeFullscreen(true,true)}).on("unload",function(a,api){});api.fakeFullscreen=function(flag,force){if(!force&&(api.isFakeFullscreen==flag||api.disabled))return;if(position===undefined)position=root.css("position");if(flag===undefined)flag=!api.isFakeFullscreen;api.isFakeFullscreen=flag;api.trigger(flag?"fakefullscreen":"fakefullscreen-exit",[api]);root.toggleClass("is-fullscreen fake-fullscreen forced-fullscreen",flag);if(flag){root.css("position","fixed")}else{root.css("position",position)}}}if(flowplayer.support.android&&flowplayer.conf.mobile_landscape_fullscreen&&window.screen&&window.screen.orientation){api.on("fullscreen",function(a,api){if(typeof api.video.width!="undefined"&&typeof api.video.height!="undefined"&&(api.video.width!=0&&api.video.height!=0&&api.video.width<api.video.height)){screen.orientation.lock("portrait-primary")}else{screen.orientation.lock("landscape-primary")}})}});flowplayer(function(api,root){root=jQuery(root);var hlsjs,player,audioUXGroup,audioGroups,hls_audio_button,hls_audio_menu,mse=window.MediaSource||window.WebKitMediaSource;flowplayer.engine("hlsjs-lite").plugin(function(params){hlsjs=params.hls});api.bind("ready",function(e,api){removeAudioMenu();if(hlsjs&&api.video.type=="application/x-mpegurl"){parseAudioTracksHlsJs(hlsjs);createAudioMenu()}});api.one("progress",function(){if(api.engine.engineName=="html5"&&api.video.type=="application/x-mpegurl"){parseAudioTracksSafari();createAudioMenu()}});function getVideoTagAudioTracks(){var video=root.find("video");if(video.length&&video[0].audioTracks){return video[0].audioTracks}return[]}function hilightAudioTrack(audioTrack){if(!audioTrack.name)audioTrack.name=audioTrack.label;root.find(".fv-fp-hls-menu a").each(function(k,el){jQuery(el).toggleClass("fp-selected",jQuery(el).attr("data-audio")===audioTrack.name)})}function createAudioMenu(){if(!audioUXGroup||audioUXGroup.length<2){return}hls_audio_button=jQuery('<strong class="fv-fp-hls">'+fv_flowplayer_translations.audio_button+"</strong>");hls_audio_menu=jQuery('<div class="fp-menu fv-fp-hls-menu"></div>').insertAfter(root.find(".fp-controls"));hls_audio_menu.append("<strong>"+fv_flowplayer_translations.audio_menu+"</strong>");audioUXGroup.forEach(function(audioTrack){hls_audio_menu.append('<a data-audio="'+audioTrack.name+'" data-lang="'+audioTrack.lang+'">'+audioTrack.name+"</a>")});hls_audio_button.insertAfter(root.find(".fp-controls .fp-volume")).on("click",function(e){e.preventDefault();e.stopPropagation();if(hls_audio_menu.hasClass("fp-active")){api.hideMenu(hls_audio_menu[0])}else{root.click();api.showMenu(hls_audio_menu[0])}});jQuery("a",hls_audio_menu).on("click",function(e){var adata=e.target.getAttribute("data-audio");if(hlsjs){var gid=hlsjs.audioTracks[hlsjs.audioTrack].groupId;var atrack=hlsjs.audioTracks.filter(function(at){return at.groupId===gid&&(at.name===adata||at.lang===adata)})[0];hlsjs.audioTrack=atrack.id;hilightAudioTrack(atrack)}else{var tracks=getVideoTagAudioTracks();for(var i in tracks){if(!tracks.hasOwnProperty(i))continue;if(tracks[i].label==adata){tracks[i].enabled=true;hilightAudioTrack(tracks[i])}}}});if(hlsjs){hilightAudioTrack(hlsjs.audioTracks[hlsjs.audioTrack])}else{var tracks=getVideoTagAudioTracks();for(var i in tracks){if(!tracks.hasOwnProperty(i))continue;if(tracks[i].enabled){hilightAudioTrack(tracks[i])}}}}function removeAudioMenu(){jQuery(hls_audio_menu).remove();jQuery(hls_audio_button).remove()}function parseAudioTracksHlsJs(data){audioGroups=[];audioUXGroup=[];data.levels.forEach(function(level){var agroup=level.attrs.AUDIO;if(agroup&&audioGroups.indexOf(agroup)<0){audioGroups.push(agroup)}if(audioGroups.length){audioUXGroup=data.audioTracks.filter(function(audioTrack){return audioTrack.groupId===audioGroups[0]})}})}function parseAudioTracksSafari(){audioGroups=[];audioUXGroup=[];var tracks=getVideoTagAudioTracks();for(var i in tracks){if(!tracks.hasOwnProperty(i))continue;audioUXGroup.push({id:tracks[i].id,name:tracks[i].label})}}});flowplayer(function(api,root){var store_engine_pos=-1;var store_engine=false;api.on("error",function(e,api,err){if(err.code!=4||api.engine.engineName!="hlsjs")return;console.log("FV Player: HLSJS failed to play the video, switching to Flash HLS");api.error=api.loading=false;jQuery(root).removeClass("is-error");jQuery(flowplayer.engines).each(function(k,v){if(flowplayer.engines[k].engineName=="hlsjs"){store_engine_pos=k;store_engine=flowplayer.engines[k];delete flowplayer.engines[k]}});var index=typeof api.video.index!="undefined"?api.video.index:0;var video=index>0?api.conf.playlist[index].sources:api.conf.clip.sources;video.index=index;api.load({sources:video});api.bind("unload error",function(){flowplayer.engines[store_engine_pos]=store_engine})})});flowplayer(function(api,root){var initialDelay=30,continueDelay=10,useDelay=initialDelay,retryLabel=fv_flowplayer_translations.live_stream_retry,timer;api.clearLiveStreamCountdown=function(){if(timer){clearInterval(timer);api.error=api.loading=false;jQuery(root).removeClass("is-error");jQuery(root).find(".fp-message.fp-shown").remove();api.unload()}};api.conf.flashls={manifestloadmaxretry:2};api.on("ready",function(){useDelay=initialDelay;retryLabel=fv_flowplayer_translations.live_stream_retry}).on("progress",function(){useDelay=continueDelay;retryLabel=fv_flowplayer_translations.live_stream_continue;clearInterval(timer)});api.on("error",function(e,api,err){setTimeout(function(){if(!api.conf.clip.live&&!api.conf.live&&!(err.video&&err.video.src.match(/\/\/vimeo.com\/event\//)))return;var delay=useDelay;if(api.conf.clip.streaming_time){delay=api.conf.clip.streaming_time-Math.floor(Date.now()/1e3)}else if(api.conf.clip.live_starts_in){delay=api.conf.clip.live_starts_in}var startLabel=fv_flowplayer_translations.live_stream_starting.replace(/%d/,secondsToDhms(delay));retryLabel=retryLabel.replace(/%d/,secondsToDhms(delay));var message=api.conf.clip.live_starts_in?startLabel:retryLabel;clearInterval(timer);if(err.code===1||err.code===2||err.code===4){root.className+=" is-offline";if(flowplayer.support.flashVideo){api.one("flashdisabled",function(){root.querySelector(".fp-flash-disabled").style.display="none"})}var messageElement=root.querySelector(".fp-ui .fp-message");messageElement.innerHTML=message;var reload_delay=delay>300?300:delay;timer=setInterval(function(){reload_delay-=1;delay-=1;if(reload_delay>0&&messageElement){messageElement.querySelector("span").innerHTML=secondsToDhms(delay)}else{clearInterval(timer);if(!api.error){return}api.error=api.loading=false;messageElement=root.querySelector(".fp-ui .fp-message");if(messageElement){root.querySelector(".fp-ui").removeChild(messageElement)}root.className=root.className.replace(/\bis-(error|offline)\b/g,"");api.load()}},1e3)}},1)});function secondsToDhms(seconds){seconds=Number(seconds);var d=Math.floor(seconds/(3600*24));var h=Math.floor(seconds%(3600*24)/3600);var m=Math.floor(seconds%3600/60);var s=Math.floor(seconds%60);var t=fv_flowplayer_translations;var output=d>0?d==1?t.duration_1_day.replace(/%s/,d):t.duration_n_days.replace(/%s/,d):"";if(output&&h>0)output+=", ";output+=h>0?h==1?t.duration_1_hour.replace(/%s/,h):t.duration_n_hours.replace(/%s/,h):"";if(output&&m>0)output+=", ";output+=m>0?m==1?t.duration_1_minute.replace(/%s/,m):t.duration_n_minutes.replace(/%s/,m):"";if(output&&s>0)output+=t.and;output+=s>0?s==1?t.duration_1_second.replace(/%s/,s):t.duration_n_seconds.replace(/%s/,s):"";return output}});flowplayer(function(api,root){root=jQuery(root);var hlsjs;flowplayer.engine("hlsjs-lite").plugin(function(params){hlsjs=params.hls});api.on("ready",function(e,api){if(hlsjs&&api.conf.playlist.length&&api.engine.engineName!="hlsjs-lite"){hlsjs.destroy()}})});flowplayer(function(api,root){if(!flowplayer.support.browser.safari&&!flowplayer.support.iOS)return;root=jQuery(root);var video_tag=false,did_start_playing=false,are_waiting_already=0;api.on("ready",function(e,api,video){are_waiting_already=0;did_start_playing=false;if(api.engine.engineName=="html5"&&video.src.match(/\?/)){video_tag=root.find("video");if(!video_tag.data("fv-ios-recovery")){video_tag.on("waiting",wait_for_stalled);video_tag.data("fv-ios-recovery",true)}api.one("progress",function(){did_start_playing=true})}});api.bind("beforeseek",wait_for_stalled);function debug(e){console.log("FV Player: iOS video element: "+e.type)}function wait_for_stalled(){if(!did_start_playing){return}if(video_tag&&api.engine.engineName=="html5"){are_waiting_already++;if(are_waiting_already>1){if(are_waiting_already>3){console.log("FV Player: iOS video element needs a push, triggering 'stalled'");video_tag.trigger("stalled")}return}console.log("FV Player: iOS video element will trigger error after 'stalled' arrives");video_tag.one("stalled",function(){var time=api.video.time;if(api.video.type.match(/video\//)){console.log("FV Player: Running check of video file...");var test_video=document.createElement("video");test_video.src=api.video.src;test_video.onloadedmetadata=function(){are_waiting_already=0;console.log("FV Player: Video link works")};test_video.onerror=function(){console.log("FV Player: Video link issue!");if(are_waiting_already>0){api.trigger("error",[api,{code:4,video:api.video}])}};return}setTimeout(function(){console.log(api.video.time,time);if(api.video.time!=time){console.log("FV Player: iOS video element continues playing, no need for error");return}if(api.paused){console.log("FV Player: iOS video element paused, no need for error");return}api.trigger("error",[api,{code:4,video:api.video}])},5e3)})}}});!function(e){var n=!1;if("function"==typeof define&&define.amd&&(define(e),n=!0),"object"==typeof exports&&(module.exports=e(),n=!0),!n){var o=window.Cookies,t=window.Cookies=e();t.noConflict=function(){return window.Cookies=o,t}}}(function(){function e(){for(var e=0,n={};e<arguments.length;e++){var o=arguments[e];for(var t in o)n[t]=o[t]}return n}function n(o){function t(n,r,i){var c;if("undefined"!=typeof document){if(arguments.length>1){if("number"==typeof(i=e({path:"/"},t.defaults,i)).expires){var a=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*i.expires),i.expires=a}i.expires=i.expires?i.expires.toUTCString():"";try{c=JSON.stringify(r),/^[\{\[]/.test(c)&&(r=c)}catch(e){}r=o.write?o.write(r,n):encodeURIComponent(r+"").replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),n=(n=(n=encodeURIComponent(n+"")).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape);var s="";for(var f in i)i[f]&&(s+="; "+f,!0!==i[f]&&(s+="="+i[f]));return document.cookie=n+"="+r+s}n||(c={});for(var p=document.cookie?document.cookie.split("; "):[],d=/(%[0-9A-Z]{2})+/g,u=0;u<p.length;u++){var l=p[u].split("="),C=l.slice(1).join("=");this.json||'"'!==C.charAt(0)||(C=C.slice(1,-1));try{var m=l[0].replace(d,decodeURIComponent);if(C=o.read?o.read(C,m):o(C,m)||C.replace(d,decodeURIComponent),this.json)try{C=JSON.parse(C)}catch(e){}if(n===m){c=C;break}n||(c[m]=C)}catch(e){}}return c}}return t.set=t,t.get=function(e){return t.call(t,e)},t.getJSON=function(){return t.apply({json:!0},[].slice.call(arguments))},t.defaults={},t.remove=function(n,o){t(n,"",e(o,{expires:-1}))},t.withConverter=n,t}return n(function(){})});flowplayer.bean.off(document,"keydown.fp");flowplayer(function(api,root){var bean=flowplayer.bean;if(!api.conf.keyboard)return;bean.on(root,"mouseenter mouseleave",function(e){fv_player_focused=!api.disabled&&e.type=="mouseover"?api:0;if(fv_player_focused)fv_player_focusedRoot=root});api.bind("ready",function(e,api,video){if(video.subtitles&&video.subtitles.length>0){var help=jQuery(root).find(".fp-help").html();help+='<div class="fp-help-section fp-help-subtitles"><p><em>c</em>cycle through subtitles</p></div>';jQuery(root).find(".fp-help").html(help)}else{jQuery(root).find(".fp-help-subtitles").remove()}})});flowplayer.bean.on(document,"keydown.fp",function(e){if(typeof fv_player_focused=="undefined")return;var api=fv_player_focused,focusedRoot=api?fv_player_focusedRoot:false,common=flowplayer.common;var el=api&&!api.disabled?api:0,metaKeyPressed=e.ctrlKey||e.metaKey||e.altKey,key=e.which,conf=el&&el.conf;if(common.hasClass(focusedRoot,"no-controlbar")||common.hasClass(focusedRoot,"is-cva"))return;if(!el||!conf.keyboard||el.disabled)return;if([63,187,191].indexOf(key)!=-1){common.toggleClass(focusedRoot,"is-help");return false}if(key==27&&common.hasClass(focusedRoot,"is-help")){common.toggleClass(focusedRoot,"is-help");return false}if(!metaKeyPressed&&el.ready){e.preventDefault();if(e.shiftKey){if(key==39)el.speed(true);else if(key==37)el.speed(false);else if(key==78)el.next();else if(key==80)el.prev();return}if(key<58&&key>47)return el.seekTo(key-48);switch(key){case 38:case 75:el.volume(el.volumeLevel+.15);break;case 40:case 74:el.volume(el.volumeLevel-.15);break;case 39:case 76:el.seeking=true;el.seek(api.video.time+5);break;case 37:case 72:el.seeking=true;el.seek(api.video.time-5);break;case 190:el.seekTo();break;case 32:el.toggle();break;case 70:if(conf.fullscreen)el.fullscreen();break;case 77:el.mute();break;case 81:el.unload();break;case 67:if(!api.video.subtitles||api.video.subtitles.length==0)break;var current_subtitles=jQuery(focusedRoot).find(".fp-dropdown li.active[data-subtitle-index]").data("subtitle-index");if(typeof current_subtitles=="undefined")current_subtitles=-1;current_subtitles++;if(current_subtitles>api.video.subtitles.length-1){current_subtitles=-1}api.trigger("fv-subtitles-switched");if(current_subtitles>-1){el.loadSubtitles(current_subtitles);fv_player_notice(focusedRoot,fv_flowplayer_translations.subtitles_switched+" "+api.video.subtitles[current_subtitles].label,"fv-subtitles-switched")}else{el.disableSubtitles();fv_player_notice(focusedRoot,fv_flowplayer_translations.subtitles_disabled,"fv-subtitles-switched")}break}}});flowplayer(function(api,root){api.bind("load",function(e,api,data){var player=jQuery(e.currentTarget);if(player.data("live")){var live_check=setTimeout(function(){player.find(".fp-ui").append('<div class="fp-message">'+fv_flowplayer_translations.live_stream_failed+"</div>");player.addClass("is-error")},1e4);jQuery(e.currentTarget).data("live_check",live_check)}}).bind("ready",function(e,api,data){clearInterval(jQuery(e.currentTarget).data("live_check"))}).bind("error",function(e,api,data){var player=jQuery(e.currentTarget);if(player.data("live")){player.find(".fp-message").html(fv_flowplayer_translations.live_stream_failed_2)}})});(function($){flowplayer(function(api,root){if(jQuery(root).hasClass("is-cva"))return;$(document).on("submit","#"+jQuery(root).attr("id")+" .mailchimp-form",function(e){e.preventDefault();$(".mailchimp-response",root).remove();$("input[type=submit]",root).attr("disabled","disabled").addClass("fv-form-loading");var data={action:"fv_wp_flowplayer_email_signup"};$("[name]",this).each(function(){data[this.name]=$(this).val()});$.post(fv_player.ajaxurl,data,function(response){response=JSON.parse(response);$('<div class="mailchimp-response"></div>').insertAfter(".mailchimp-form",root);if(response.text.match(/already subscribed/)){response.status="ERROR"}if(response.status==="OK"){$(".mailchimp-form input[type=text],.mailchimp-form input[type=email]",root).val("");$(".mailchimp-response",root).removeClass("is-fv-error").html(response.text);setTimeout(function(){$(".wpfp_custom_popup",root).fadeOut()},2e3)}else{$(".mailchimp-response",root).addClass("is-fv-error").html(response.text)}$("input[type=submit]",root).removeAttr("disabled").removeClass("fv-form-loading")})})})})(jQuery);function fv_flowplayer_mobile_switch(id){var regex=new RegExp("[\\?&]fv_flowplayer_mobile=([^&#]*)");var results=regex.exec(location.search);if((results!=null&&results[1]=="yes"||(jQuery(window).width()<=480||jQuery(window).height()<=480))&&(results==null||results[1]!="no")){var fv_fp_mobile=false;jQuery("#wpfp_"+id+" video source").each(function(){if(jQuery(this).attr("id")!="wpfp_"+id+"_mobile"){fv_fp_mobile=true;jQuery(this).remove()}});if(fv_fp_mobile){jQuery("#wpfp_"+id).after('<p class="fv-flowplayer-mobile-switch">'+fv_flowplayer_translations.mobile_browser_detected_1+' <a href="'+document.URL+'?fv_flowplayer_mobile=no">'+fv_flowplayer_translations.mobile_browser_detected_2+"</a>.</p>")}}}if(typeof fv_flowplayer_mobile_switch_array!="undefined"){for(var i in fv_flowplayer_mobile_switch_array){if(!fv_flowplayer_mobile_switch_array.hasOwnProperty(i))continue;fv_flowplayer_mobile_switch(i)}}flowplayer(function(api,root){if(!flowplayer.support.touch)return;jQuery.fn.fv_single_double_click=function(single_click_callback,double_click_callback,timeout){return this.each(function(){var clicks=0,self=this;jQuery(this).on("click",function(event){clicks++;if(clicks==1){setTimeout(function(){if(clicks==1){single_click_callback.call(self,event)}else{double_click_callback.call(self,event)}clicks=0},timeout||300)}})})};root=jQuery(root);var left=jQuery('<div class="fv-fp-tap-left"><span>-10s</span></div>'),right=jQuery('<div class="fv-fp-tap-right"><span>+10s</span></div>');left.fv_single_double_click(function(){api.toggle()},function(e){maybe_seek(e,left,api.ready?api.video.time-10:false)});right.fv_single_double_click(function(){api.toggle()},function(e){maybe_seek(e,right,api.ready?api.video.time+10:false)});root.find(".fp-ui").append(left).append(right);function maybe_seek(e,el,time){if(api.ready){api.seek(time);animation(el)}else{api.toggle()}e.preventDefault()}function animation(el){el.addClass("is-active");setTimeout(function(){el.removeClass("is-active")},500)}});flowplayer(function(api,root){root=jQuery(root);var instance_id=root.data("flowplayer-instance-id");flowplayer.audible_instance=-1;api.one("load",function(){setTimeout(function(){api.conf.splash=false},0)});api.on("ready",function(){var is_muted=root.data("volume")==0;if(!is_muted){flowplayer.audible_instance=instance_id}jQuery(".flowplayer[data-flowplayer-instance-id]").each(function(){var player=jQuery(this).data("flowplayer");var current_instance_id=jQuery(this).data("flowplayer-instance-id");if(flowplayer.audible_instance==-1||current_instance_id==flowplayer.audible_instance||current_instance_id==instance_id)return;if(player){if(player.ready){if(api.conf.multiple_playback){if(!is_muted){player.mute(true,true)}}else if(player.playing){player.pause()}}else{player.clearLiveStreamCountdown();player.unload()}}})}).on("mute",function(e,api,muted){if(!muted&&flowplayer.audible_instance!=instance_id){flowplayer(flowplayer.audible_instance).mute(true,true);flowplayer.audible_instance=instance_id}}).on("resume",function(){if(!api.conf.multiple_playback){jQuery(".flowplayer[data-flowplayer-instance-id]").each(function(){if(instance_id==jQuery(this).data("flowplayer-instance-id"))return;var player=jQuery(this).data("flowplayer");if(player&&player.playing){player.pause()}})}})});function fv_flowplayer_browser_ff_m4v(hash){if(flowplayer.support.browser&&flowplayer.support.browser.mozilla&&navigator.appVersion.indexOf("Win")!=-1){jQuery("#wpfp_"+hash).attr("data-engine","flash")}}if(typeof fv_flowplayer_browser_ff_m4v_array!="undefined"){for(var i in fv_flowplayer_browser_ff_m4v_array){if(!fv_flowplayer_browser_ff_m4v_array.hasOwnProperty(i))continue;fv_flowplayer_browser_ff_m4v(i)}}function fv_flowplayer_browser_chrome_fail(hash,sAttributes,sVideo,bAutobuffer){jQuery("#wpfp_"+hash).bind("error",function(e,api,error){if(/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())&&error!=null&&(error.code==3||error.code==4||error.code==5)){api.unload();jQuery("#wpfp_"+hash).attr("id","bad_wpfp_"+hash);jQuery("#bad_wpfp_"+hash).after('<div id="wpfp_'+hash+'" '+sAttributes+' data-engine="flash"></div>');jQuery("#wpfp_"+hash).flowplayer({playlist:[[{mp4:sVideo}]]});if(bAutobuffer){jQuery("#wpfp_"+hash).bind("ready",function(e,api){api.play()})}else{jQuery("#wpfp_"+hash).flowplayer().play(0)}jQuery("#bad_wpfp_"+hash).remove()}})}if(typeof fv_flowplayer_browser_chrome_fail_array!="undefined"){for(var i in fv_flowplayer_browser_chrome_fail_array){if(!fv_flowplayer_browser_chrome_fail_array.hasOwnProperty(i))continue;fv_flowplayer_browser_chrome_fail(i,fv_flowplayer_browser_chrome_fail_array[i]["attrs"],fv_flowplayer_browser_chrome_fail_array[i]["mp4"],fv_flowplayer_browser_chrome_fail_array[i]["auto_buffer"])}}function fv_flowplayer_browser_ie(hash){if(flowplayer.support.browser&&flowplayer.support.browser.msie&&parseInt(flowplayer.support.browser.version,10)>=9||!!navigator.userAgent.match(/Trident.*rv[ :]*11\./)){jQuery("#wpfp_"+hash).attr("data-engine","flash")}}if(typeof fv_flowplayer_browser_ie_array!="undefined"){for(var i in fv_flowplayer_browser_ie_array){if(!fv_flowplayer_browser_ie_array.hasOwnProperty(i))continue;fv_flowplayer_browser_ie(i)}}function fv_flowplayer_browser_chrome_mp4(hash){var match=window.navigator.appVersion.match(/Chrome\/(\d+)\./);if(match!=null){var chrome_ver=parseInt(match[1],10);if(/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())&&chrome_ver<28&&navigator.appVersion.indexOf("Win")!=-1||/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())&&chrome_ver<27&&navigator.appVersion.indexOf("Linux")!=-1&&navigator.userAgent.toLowerCase().indexOf("android")==-1){jQuery("#wpfp_"+hash).attr("data-engine","flash")}}}if(navigator.platform.indexOf("iPhone")!=-1||navigator.platform.indexOf("iPod")!=-1||navigator.platform.indexOf("iPad")!=-1||navigator.userAgent.toLowerCase().indexOf("android")!=-1){flowplayer(function(api,root){api.bind("error",function(e,api,error){if(error.code==10){jQuery(e.target).find(".fp-message").html(fv_flowplayer_translations.unsupported_format)}})})}jQuery(document).ready(function(){if(navigator.platform.indexOf("iPhone")!=-1||navigator.platform.indexOf("iPod")!=-1||navigator.platform.indexOf("iPad")!=-1){jQuery(window).trigger("load")}jQuery(".flowplayer").on("mouseleave",function(){jQuery(this).find(".fvp-share-bar").removeClass("visible");jQuery(this).find(".embed-code").hide()})});if(typeof flowplayer!=="undefined"){flowplayer(function(api,root){root=jQuery(root);var notice=false,hlsjs;flowplayer.engine("hlsjs-lite").plugin(function(params){hlsjs=params.hls});var playlist=api.conf.playlist.length?api.conf.playlist:[api.conf.clip];if(playlist[0]&&playlist[0].pending_encoding){show_notice(playlist[0])}api.on("load",function(e,api,video){if(video.pending_encoding){show_notice(video);if(hlsjs){hlsjs.destroy()}return false}remove_notice()});function show_notice(video){remove_notice();var title="Video is being processed",message="Please return later to see the actual video in this player.";if(video.pending_encoding_error){title="Video unavailable";message="There was an error in the video encoding."}else if(video.pending_encoding_progress){message+="<br /><br />("+video.pending_encoding_progress+" done)"}notice=jQuery('<div class="fv-player-encoder-video-processing-modal"><div><h2>'+title+"</h2><p>"+message+"</p></div></div");root.append(notice)}function remove_notice(){if(notice){notice.remove()}}})}if(!Date.now){Date.now=function(){return(new Date).getTime()}}(function($){var sendPositionsEvery=60,ajaxCall=null,maxCookieSize=2500,localStorageEnabled=null,cookiePositionsKeyName="video_positions",cookiePlaylistsKeyName="player_playlist_item",tempPositionCookieKeyName="video_positions_tmp",tempPlaylistsCookieKeyName="player_playlist_item_tmp",tempSawCookieKeyName="video_saw_tmp",playPositions=[],playlistIndexes=[],sawVideo=[],getSerialized=function(data){var serialized=JSON.stringify(data),dataSize=getTextByteSize(serialized);if(dataSize>maxCookieSize){while(dataSize>maxCookieSize){for(var i in data){if(!data.hasOwnProperty(i))continue;delete data[i];serialized=JSON.stringify(data);dataSize=getTextByteSize(serialized);break}}}return serialized},getVideoId=function(video){if(video.id){return video.id}var out=typeof video.sources_original!="undefined"&&typeof video.sources_original[0]!="undefined"?video.sources_original[0].src:video.sources[0].src;if(typeof video.sources_original=="undefined"||typeof video.sources_original[0]=="undefined"){out=removeAWSSignatures(out)}return out},getTextByteSize=function(txt){return encodeURIComponent(txt).length},getCookieKey=function(key){return localStorageEnabled?localStorage.getItem(key):Cookies.get(key)},setCookieKey=function(key,value){return localStorageEnabled?localStorage.setItem(key,value):Cookies.set(key,value)},removeCookieKey=function(key){if(localStorageEnabled){localStorage.removeItem(key)}{Cookies.remove(key)}},removeVideoPosition=function(e,api){if(api.video.sources){var video_id=getVideoId(api.video);playPositions[video_id]=0;sawVideo[video_id]=1}},removeAWSSignatures=function(videoURL){return videoURL.replace(/(X-Amz-Algorithm=[^&]+&?)/gm,"").replace(/(X-Amz-Credential=[^&]+&?)/gm,"").replace(/(X-Amz-Date=[^&]+&?)/gm,"").replace(/(X-Amz-Expires=[^&]+&?)/gm,"").replace(/(X-Amz-SignedHeaders=[^&]+&?)/gm,"").replace(/(X-Amz-Signature=[^&]+&?)/gm,"")},sendVideoPositions=function(async,callback){var beaconSupported="sendBeacon"in navigator;if(async!==true){async=false}if(!callback||typeof callback=="undefined"){callback=function(){}}postDataPositions=[];postDataPlaylists=[];for(var video_name in playPositions){if(!playPositions.hasOwnProperty(video_name))continue;postDataPositions.push({name:video_name,position:playPositions[video_name],saw:typeof sawVideo[video_name]!="undefined"?sawVideo[video_name]:false})}for(var player_id in playlistIndexes){if(!playlistIndexes.hasOwnProperty(player_id))continue;postDataPlaylists.push({player:player_id,item:playlistIndexes[player_id]})}if(!postDataPlaylists.length){removeCookieKey(tempPlaylistsCookieKeyName)}if(!postDataPositions.length){removeCookieKey(tempPositionCookieKeyName);removeCookieKey(tempSawCookieKeyName);return}if(flowplayer.conf.is_logged_in=="1"){if(beaconSupported){try{var temp_position_data={},temp_saw_data={},temp_playlist_data={};for(var i in postDataPositions){if(!postDataPositions.hasOwnProperty(i))continue;temp_position_data[postDataPositions[i].name]=postDataPositions[i].position;temp_saw_data[postDataPositions[i].name]=postDataPositions[i].saw}for(var i in postDataPlaylists){if(!postDataPlaylists.hasOwnProperty(i))continue;temp_playlist_data[postDataPlaylists[i].player]=postDataPlaylists[i].item}setCookieKey(tempPositionCookieKeyName,getSerialized(temp_position_data));setCookieKey(tempSawCookieKeyName,getSerialized(temp_saw_data));setCookieKey(tempPlaylistsCookieKeyName,getSerialized(temp_playlist_data))}catch(e){return}var fd=new FormData;fd.append("action","fv_wp_flowplayer_video_position_save");fd.append("videoTimes",encodeURIComponent(JSON.stringify(postDataPositions)));fd.append("playlistItems",encodeURIComponent(JSON.stringify(postDataPlaylists)));navigator.sendBeacon(fv_player.ajaxurl,fd);return false}else{return jQuery.ajax({type:"POST",async:async,url:fv_player.ajaxurl,complete:callback,data:{action:"fv_wp_flowplayer_video_position_save",videoTimes:postDataPositions,playlistItems:postDataPlaylists}})}}else{try{var data_positions=getCookieKey(cookiePositionsKeyName);var data_playlist_item=getCookieKey(cookiePlaylistsKeyName);if(data_positions&&typeof data_positions!=="undefined"){data_positions=JSON.parse(data_positions)}else{data_positions={}}if(data_playlist_item&&typeof data_playlist_item!=="undefined"){data_playlist_item=JSON.parse(data_playlist_item)}else{data_playlist_item={}}for(var i in postDataPositions){if(!postDataPositions.hasOwnProperty(i))continue;data_positions[postDataPositions[i].name]=postDataPositions[i].position}for(var i in postDataPlaylists){if(!postDataPlaylists.hasOwnProperty(i))continue;data_playlist_item[postDataPlaylists[i].player]=postDataPlaylists[i].item}var serialized_positions=JSON.stringify(data_positions),serialized_playlist_items=JSON.stringify(data_playlist_item),dataSize_postions=getTextByteSize(serialized_positions),dataSize_playlist_items=getTextByteSize(serialized_playlist_items);if(dataSize_postions>maxCookieSize){while(dataSize_postions>maxCookieSize){for(var i in data_positions){if(!data_positions.hasOwnProperty(i))continue;delete data_positions[i];serialized_positions=JSON.stringify(data_positions);dataSize_postions=getTextByteSize(serialized_positions);break}}}if(dataSize_playlist_items>maxCookieSize){while(dataSize_playlist_items>maxCookieSize){for(var i in data_positions){if(!data_playlist_item.hasOwnProperty(i))continue;delete data_playlist_item[i];serialized_playlist_items=JSON.stringify(data_playlist_item);dataSize_playlist_items=getTextByteSize(serialized_positions);break}}}setCookieKey(cookiePositionsKeyName,serialized_positions);setCookieKey(cookiePlaylistsKeyName,serialized_playlist_items)}catch(e){return}}return false};flowplayer(function(api,root){if(typeof api.conf.disable_localstorage!="undefined"){return}var $root=jQuery(root),enabled=flowplayer.conf.video_position_save_enable&&$root.data("save-position")!="false"||$root.data("save-position"),progressEventsCount=0,player_id=$root.data("player-id")?$root.data("player-id"):false,item_changed=false,seekIntoPosition=function(e,api){if(api.video&&api.video.live)return;var video_id=getVideoId(api.video),position=api.video.position;if(flowplayer.conf.is_logged_in!="1"){var data=getCookieKey(cookiePositionsKeyName);if(data&&typeof data!=="undefined"){try{data=JSON.parse(data);if(data[video_id]){position=data[video_id]}}catch(e){return}}}if(!!api.get_custom_end&&api.get_custom_end()<position){position=false}if(!!api.get_custom_start&&api.get_custom_start()>0){if(position<api.get_custom_start()){position=false}}api.bind("progress",storeVideoPosition);if(position){seek(position)}},storeVideoPosition=function(e,api){if(api.live){return}if(api.video.sources){var video_id=getVideoId(api.video),position=Math.round(api.video.time);playPositions[video_id]=position;if(api.conf.playlist.length>0){if(player_id)playlistIndexes[player_id]=api.video.index}if(progressEventsCount++>=sendPositionsEvery&&flowplayer.conf.closingPage){if(ajaxCall){ajaxCall.abort()}ajaxCall=sendVideoPositions(true,function(){ajaxCall=null});progressEventsCount=0}}},forceSavePosition=function(e,api){var inPlaylist=false;for(var i in api.conf.playlist){if(!api.conf.playlist.hasOwnProperty(i))continue;inPlaylist=true;break}if(inPlaylist&&!flowplayer.conf.closingPage){progressEventsCount=sendPositionsEvery+1;storeVideoPosition(e,api);sendVideoPositions()}},seek=function(position){if(!!api.custom_seek){api.custom_seek(position);return}var seek_count=0;var do_seek=setInterval(function(){if(++seek_count>20)clearInterval(do_seek);if(api.loading)return;api.seek(parseInt(position));clearInterval(do_seek)},10)},processTempData=function(temp_data_name,video_id){var data=getCookieKey(temp_data_name),output=false;if(data&&typeof data!=="undefined"){try{data=JSON.parse(data);if(typeof data[video_id]!="undefined"){output=data[video_id];delete data[video_id];var stillHasData=false;for(var i in data){if(!data.hasOwnProperty(i))continue;stillHasData=true;break}if(stillHasData){setCookieKey(temp_data_name,JSON.stringify(data))}else{removeCookieKey(temp_data_name)}}return output}catch(e){}}},restorePlaylistItem=function(e,api){if(typeof api=="undefined"||api.conf.playlist.length==0)return;var item_index=-1;if(player_id){if(flowplayer.conf.is_logged_in!="1"){var data=getCookieKey(cookiePlaylistsKeyName);if(data&&typeof data!=="undefined"){try{data=JSON.parse(data);if(data[player_id]){item_index=data[player_id]}}catch(e){return}}}else if(flowplayer.conf.is_logged_in=="1"){item_index=api.conf.playlist.length>0?processTempData(tempPlaylistsCookieKeyName,player_id):false}}if(item_index>=0&&!item_changed){api.play(item_index);item_changed=true}};if(!enabled)return;if(getCookieKey(tempPlaylistsCookieKeyName)){$root.removeData("playlist_start")}api.bind("finish",removeVideoPosition);api.one("progress",seekIntoPosition);api.bind("unload",function(){item_changed=false;api.one("ready",restorePlaylistItem)});api.one("ready",restorePlaylistItem);jQuery(".fp-ui",root).on("click",function(){restorePlaylistItem()});api.playlist_thumbnail_progress=function(el,video,position){if(!!api.get_custom_start&&api.get_custom_start(video)>0){position-=api.get_custom_start(video);if(position<0)position=0}var duration=video.duration;if(!!api.get_custom_duration&&api.get_custom_duration()>0){duration=api.get_custom_duration()}if(!duration){duration=el.data("duration")}if(!duration)return;var progress=100*position/duration;el.css("width",progress+"%")};if(flowplayer.conf.is_logged_in=="1"){var playlist=api.conf.playlist.length>0?api.conf.playlist:[api.conf.clip],playlist_external=jQuery("[rel="+jQuery(root).attr("id")+"]");for(var i in playlist){if(!playlist.hasOwnProperty(i))continue;var video_id=getVideoId(playlist[i]),position=processTempData(tempPositionCookieKeyName,video_id),saw=processTempData(tempSawCookieKeyName,video_id);if(position){if(api.conf.playlist.length){api.conf.playlist[i].sources[0].position=position;var playlist_progress=jQuery("a",playlist_external).eq(i).find(".fvp-progress");if(playlist_progress.length){api.playlist_thumbnail_progress(playlist_progress,api.conf.playlist[i],position)}}else{api.conf.clip.sources[0].position=position}}if(saw){if(api.conf.playlist.length){api.conf.playlist[i].sources[0].saw=true}else{api.conf.clip.sources[0].saw=true}}}}api.bind("finish",function(e,api){if(api.conf.playlist.length){api.conf.playlist[api.video.index].sources[0].saw=true}else{api.conf.clip.sources[0].saw=true}})});jQuery(window).on("beforeunload pagehide",function(){if(!flowplayer.conf.closingPage){flowplayer.conf.closingPage=true;sendVideoPositions()}});if(typeof fv_flowplayer_conf.disable_localstorage!="undefined"){localStorageEnabled=false}if(localStorageEnabled!==null){return localStorageEnabled}localStorageEnabled=true;try{localStorage.setItem("t","t");if(localStorage.getItem("t")!=="t"){localStorageEnabled=false}localStorage.removeItem("t")}catch(e){localStorageEnabled=false}})(jQuery);flowplayer(function(api,root){root=jQuery(root);if(api.conf.playlist.length==0)return;var real_videos=0;jQuery(api.conf.playlist).each(function(k,v){if(typeof v.click=="undefined"){real_videos++}});if(real_videos<2)return;var playlist=jQuery(".fp-playlist-external[rel="+root.attr("id")+"]");var playlist_button=jQuery('<strong class="fv-fp-list">Item 1.</strong>'),playlist_button_name=jQuery('<strong class="fv-fp-list-name">Item 1.</strong>'),playlist_menu=jQuery('<div class="fp-menu fv-fp-list-menu"></div>').insertAfter(root.find(".fp-controls"));var i=0,item_index=[],track_item=[];jQuery(api.conf.playlist).each(function(k,v){if(typeof v.click=="undefined"){var title=parse_title(playlist.find("h4").eq(i));playlist_menu.append('<a data-index="'+k+'">'+(i+1)+". "+title+"</a>");track_item[k]=title;item_index.push(k);i++}});function playlist_button_click(e){e.preventDefault();e.stopPropagation();if(playlist_menu.hasClass("fp-active")){api.hideMenu(playlist_menu[0])}else{root.trigger("click");api.showMenu(playlist_menu[0])}}playlist_button.insertAfter(root.find(".fp-controls .fp-volume")).on("click",playlist_button_click);playlist_button_name.insertAfter(playlist_button).on("click",playlist_button_click);jQuery("a",playlist_menu).on("click",function(){if(typeof api.conf.playlist[jQuery(this).data("index")-1]!="undefined"&&typeof api.conf.playlist[jQuery(this).data("index")-1].click!="undefined"){api.play(jQuery(this).data("index")-1)}else{api.play(jQuery(this).data("index"))}});api.on("ready",function(e,api,video){playlist_menu.find("a").removeClass("fp-selected");var thumb=playlist_menu.find("a[data-index="+video.index+"]");thumb.addClass("fp-selected");var label=fv_flowplayer_translations.playlist_item_no;label=label.replace(/%d/,item_index.indexOf(video.index)+1);label=label.replace(/%s/,parse_title(thumb.find("h4")));playlist_button.html(label);playlist_button_name.html(item_index.indexOf(video.index)+1+". "+track_item[video.index])});function parse_title(el){var tmp=el.clone();tmp.find("i.dur").remove();return tmp.text()}});flowplayer(function(api,root){root=jQuery(root);var playlist=api.conf.playlist,videoIndex;api.bind("load",function(e,api,video){videoIndex=video.index});api.bind("error",function(e,api,error){setTimeout(function(){if(playlist.length>0&&api.error==true){videoIndex=api.video.index;if(api.conf.video_checker=="1"&&playlist[videoIndex].video_checker&&playlist[videoIndex].video_checker.length>0){console.log("FV Player: Video checker message present, stopping auto-advance to next playlist item");return false}api.error=api.loading=false;root.removeClass("is-error");root.find(".fp-message.fp-shown").remove();videoIndex++;if(videoIndex>playlist.length-1){videoIndex=0}console.log("FV Player: Playlist item failure, auto-advancing to "+(videoIndex+1)+". item");api.play(videoIndex)}},1e3)})});flowplayer(function(api,root){root=jQuery(root);var original_prev,original_next,random_seed;if(!root.data("button-no-picture")&&!root.data("button-repeat")&&!root.data("button-rewind"))return;api.bind("ready",function(e,api){if(typeof original_next=="undefined"&&typeof original_prev=="undefined"){original_next=api.next;original_prev=api.prev}if(!api.video.type.match(/^audio/)&&root.data("button-no-picture")&&root.find(".fv-fp-no-picture").length==0){var button_no_picture=jQuery('<span class="fv-fp-no-picture"><svg viewBox="0 0 90 80" width="18px" height="18px" class="fvp-icon fvp-nopicture"><use xlink:href="#fvp-nopicture"></use></svg></span>');button_no_picture.insertAfter(root.find(".fp-controls .fp-volume")).on("click",function(e){e.preventDefault();e.stopPropagation();jQuery(".fp-engine",root).slideToggle(20);jQuery(this).toggleClass("is-active fp-color-fill")})}if(root.data("button-repeat")){if(api.conf.playlist.length>0&&root.find(".fv-fp-playlist").length==0){var t=fv_flowplayer_translations,playlist_button=jQuery('<strong class="fv-fp-playlist mode-normal"> <svg viewBox="0 0 80.333 80" width="18px" height="18px" class="fvp-icon fvp-replay-list"><title>'+t.playlist_replay_all+'</title><use xlink:href="#fvp-replay-list"></use></svg> <svg viewBox="0 0 80.333 71" width="18px" height="18px" class="fvp-icon fvp-shuffle"><title>'+t.playlist_shuffle+'</title><use xlink:href="#fvp-shuffle"></use></svg> <svg viewBox="0 0 80.333 71" width="18px" height="18px" class="fvp-icon fvp-replay-track"><title>'+t.playlist_replay_video+'</title><use xlink:href="#fvp-replay-track"></use></svg> <span id="fvp-playlist-play" title="'+t.playlist_play_all+'">'+t.playlist_play_all_button+"</span> </strong>"),playlist_menu=jQuery('<div class="fp-menu fv-fp-playlist-menu"> <a data-action="repeat_playlist"><svg viewBox="0 0 80.333 80" width="18px" height="18px" class="fvp-icon fvp-replay-list"><title>'+t.playlist_replay_all+'</title><use xlink:href="#fvp-replay-list"></use></svg> <span class="screen-reader-text">'+t.playlist_replay_all+'</span></a> <a data-action="shuffle_playlist"><svg viewBox="0 0 80.333 71" width="18px" height="18px" class="fvp-icon fvp-shuffle"><title>'+t.playlist_shuffle+'</title><use xlink:href="#fvp-shuffle"></use></svg> <span class="screen-reader-text">'+t.playlist_shuffle+'</span></a> <a data-action="repeat_track"><svg viewBox="0 0 80.333 71" width="18px" height="18px" class="fvp-icon fvp-replay-track"><title>'+t.playlist_replay_video+'</title><use xlink:href="#fvp-replay-track"></use></svg> <span class="screen-reader-text">'+t.playlist_replay_video+'</span></a> <a class="fp-selected" data-action="normal"><span id="fvp-playlist-play" title="'+t.playlist_play_all+'">'+t.playlist_play_all_button+"</span></a> </div>").insertAfter(root.find(".fp-controls"));api.conf.playlist_shuffle=api.conf.track_repeat=false;random_seed=randomize();var should_advance=api.conf.advance;playlist_button.insertAfter(root.find(".fp-controls .fp-volume")).on("click",function(e){e.preventDefault();e.stopPropagation();if(playlist_menu.css("right")!=="auto"){playlist_menu.css({right:"auto",left:playlist_button.position().left+"px"})}if(playlist_menu.hasClass("fp-active")){api.hideMenu(playlist_menu[0])}else{root.trigger("click");api.showMenu(playlist_menu[0])}});jQuery("a",playlist_menu).on("click",function(){jQuery(this).siblings("a").removeClass("fp-selected");jQuery(this).addClass("fp-selected");playlist_button.removeClass("mode-normal mode-repeat-track mode-repeat-playlist mode-shuffle-playlist");var action=jQuery(this).data("action");if(action=="repeat_playlist"){playlist_button.addClass("mode-repeat-playlist");api.conf.loop=true;api.conf.advance=true;api.video.loop=api.conf.track_repeat=false;api.conf.playlist_shuffle=false}else if(action=="shuffle_playlist"){playlist_button.addClass("mode-shuffle-playlist");api.conf.loop=true;api.conf.advance=true;api.conf.playlist_shuffle=true}else if(action=="repeat_track"){playlist_button.addClass("mode-repeat-track");api.conf.track_repeat=api.video.loop=true;api.conf.loop=api.conf.playlist_shuffle=false}else if(action=="normal"){playlist_button.addClass("mode-normal");api.conf.track_repeat=api.video.loop=false;api.conf.loop=api.conf.playlist_shuffle=false}if(api.conf.playlist_shuffle){api.next=function(){api.play(random_seed.pop());if(random_seed.length==0)random_seed=randomize()};api.prev=function(){api.play(random_seed.shift());if(random_seed.length==0)random_seed=randomize()}}else{api.next=original_next;api.prev=original_prev}});if(api.conf.loop){jQuery("a[data-action=repeat_playlist]",playlist_menu).trigger("click")}api.on("progress",function(){api.video.loop=api.conf.track_repeat});api.on("finish.pl",function(e,api){console.log("playlist_repeat",api.conf.loop,"advance",api.conf.advance,"video.loop",api.video.loop);if(api.conf.playlist_shuffle){api.play(random_seed.pop());if(random_seed.length==0)random_seed=randomize()}})}else if(root.find(".fv-fp-track-repeat").length==0&&api.conf.playlist.length==0){var button_track_repeat=jQuery('<strong class="fv-fp-track-repeat"><svg viewBox="0 0 80.333 71" width="18px" height="18px" class="fvp-icon fvp-replay-track"><use xlink:href="#fvp-replay-track"></use></svg></strong>');button_track_repeat.insertAfter(root.find(".fp-controls .fp-volume")).on("click",function(e){e.preventDefault();e.stopPropagation();jQuery(this).toggleClass("is-active fp-color-fill",api.video.loop);if(api.video.loop){api.video.loop=false}else{api.video.loop=true}});if(api.conf.loop){button_track_repeat.addClass("is-active fp-color-fill")}}}if(root.data("button-rewind")){if(root.find(".fv-fp-rewind").length==0){var button_rewind=jQuery('<span class="fv-fp-rewind"><svg viewBox="0 0 24 24" width="21px" height="21px" class="fvp-icon fvp-rewind"><use xlink:href="#fvp-rewind"></use></svg></span>');button_rewind.insertBefore(root.find(".fp-controls .fp-playbtn")).on("click",function(e){e.preventDefault();e.stopPropagation();api.seek(api.video.time-10)});button_rewind.toggle(!api.video.live)}if(root.find(".fv-fp-forward").length==0){var button_forward=jQuery('<span class="fv-fp-forward"><svg viewBox="0 0 24 24" width="21px" height="21px" class="fvp-icon fvp-forward"><use xlink:href="#fvp-forward"></use></svg></span>');button_forward.insertAfter(root.find(".fp-controls .fp-playbtn")).on("click",function(e){e.preventDefault();e.stopPropagation();api.seek(api.video.time+10)});button_forward.toggle(!api.video.live)}}}).bind("unload",function(){root.find(".fv-fp-no-picture").remove();root.find(".fv-fp-playlist").remove();root.find(".fv-fp-track-repeat").remove()});function array_shuffle(a){var j,x,i;for(i=a.length;i;i--){j=Math.floor(Math.random()*i);x=a[i-1];a[i-1]=a[j];a[j]=x}return a}function randomize(random_seed){random_seed=[];jQuery(api.conf.playlist).each(function(k,v){random_seed.push(k)});random_seed=array_shuffle(random_seed);console.log("FV Player Randomizer random seed:",random_seed);return random_seed}});flowplayer(function(api,root){var $root=jQuery(root),start_index=$root.data("playlist_start");if(typeof start_index=="undefined")return;function start_position_changer(){if($root.data("position_changed")!==1&&api.conf.playlist.length){start_index--;api.play(start_index);$root.data("position_changed",1)}}api.bind("unload",function(){start_index=$root.data("playlist_start");$root.removeData("position_changed");api.one("ready",start_position_changer)});api.one("ready",start_position_changer);jQuery(".fp-ui",root).on("click",function(){start_position_changer();$root.data("position_changed",1)})});document.addEventListener("custombox:overlay:close",function(e){console.log("FV Player: Custombox/Popup anything ligtbox closed");var $players=jQuery(this).find(".flowplayer");if($players.length==0)return;console.log("FV Player: Custombox/Popup anything ligtbox contains a player");$players.each(function(index,player){var api=jQuery(player).data("flowplayer");if(typeof api!="undefined"){if(api.playing){console.log("FV Player: Custombox/Popup anything ligtbox video pause");api.pause()}else if(api.loading){api.one("ready",function(){console.log("FV Player: Custombox/Popup anything ligtbox video unload");api.unload()})}}})});flowplayer(function(api,root){api.bind("finish",function(){var finished_at=api.video.time;if(api.video.loop){api.one("pause",function(){if(finished_at<=api.video.time){api.resume()}})}})});function fv_flowplayer_amazon_s3(hash,time){jQuery("#wpfp_"+hash).bind("error",function(e,api,error){var fv_fp_date=new Date;if(error.code==4&&fv_fp_date.getTime()>fv_fp_utime+parseInt(time)){jQuery(e.target).find(".fp-message").delay(500).queue(function(n){jQuery(this).html(fv_flowplayer_translations.video_expired);n()})}})}flowplayer(function(api,root){root=jQuery(root);root.find(".fp-logo").removeAttr("href");if(root.hasClass("no-controlbar")){var timelineApi=api.sliders.timeline;timelineApi.disable(true);api.bind("ready",function(){timelineApi.disable(true)})}jQuery(".fvfp_admin_error",root).remove();root.find(".fp-logo, .fp-header").on("click",function(e){if(e.target!==this)return;root.find(".fp-ui").trigger("click")});jQuery(".fvp-share-bar .sharing-facebook",root).append('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="#fff"><title>Facebook</title><path d="M11.9 5.2l-2.6 0 0-1.6c0-0.7 0.3-0.7 0.7-0.7 0.3 0 1.6 0 1.6 0l0-2.9 -2.3 0c-2.6 0-3.3 2-3.3 3.3l0 2 -1.6 0 0 2.9 1.6 0c0 3.6 0 7.8 0 7.8l3.3 0c0 0 0-4.2 0-7.8l2.3 0 0.3-2.9Z"/></svg>');jQuery(".fvp-share-bar .sharing-twitter",root).append('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="#fff"><title>Twitter</title><path d="M16 3.1c-0.6 0.3-1.2 0.4-1.9 0.5 0.7-0.4 1.2-1 1.4-1.8 -0.6 0.4-1.3 0.6-2.1 0.8 -0.6-0.6-1.4-1-2.4-1 -2 0.1-3.2 1.6-3.2 4 -2.7-0.1-5.1-1.4-6.7-3.4 -0.9 1.4 0.2 3.8 1 4.4 -0.5 0-1-0.1-1.5-0.4l0 0.1c0 1.6 1.1 2.9 2.6 3.2 -0.7 0.2-1.3 0.1-1.5 0.1 0.4 1.3 1.6 2.2 3 2.3 -1.6 1.7-4.6 1.4-4.8 1.3 1.4 0.9 3.2 1.4 5 1.4 6 0 9.3-5 9.3-9.3 0-0.1 0-0.3 0-0.4 0.6-0.4 1.2-1 1.6-1.7Z"/></svg>');jQuery(".fvp-share-bar .sharing-email",root).append('<svg xmlns="http://www.w3.org/2000/svg" height="16" viewBox="0 0 16 16" width="16" fill="#fff"><title>Email</title><path d="M8 10c0 0 0 0-1 0L0 6v7c0 1 0 1 1 1h14c1 0 1 0 1-1V6L9 10C9 10 8 10 8 10zM15 2H1C0 2 0 2 0 3v1l8 4 8-4V3C16 2 16 2 15 2z"/></svg>');jQuery(".fp-header",root).prepend(jQuery(".fvp-share-bar",root));if(api.conf.playlist.length){var show=true;var playlist=api.conf.playlist;if(playlist.length==2){if(typeof playlist[0].click!="undefined"&&typeof playlist[1].click=="undefined"){show=false}if(typeof playlist[0].click=="undefined"&&typeof playlist[1].click!="undefined"){show=false}}else if(playlist.length==3){if(typeof playlist[0].click!="undefined"&&typeof playlist[1].click=="undefined"&&typeof playlist[2].click!="undefined"){show=false}}if(show){var prev=jQuery('<a class="fp-icon fv-fp-prevbtn"></a>');var next=jQuery('<a class="fp-icon fv-fp-nextbtn"></a>');root.find(".fp-controls .fp-playbtn").before(prev).after(next);prev.on("click",function(){api.trigger("prev",[api]);api.prev()});next.on("click",function(){api.trigger("next",[api]);api.next()})}}if(typeof fv_player_editor_conf!="undefined"){root.on("click",".fvp-sharing > li",function(e){e.preventDefault();fv_player_notice(root,fv_player_editor_translations.link_notice,2e3);return false})}api.bind("pause resume finish unload ready",function(e,api){root.addClass("no-brand")});api.one("ready",function(){root.find(".fp-fullscreen").clone().appendTo(root.find(".fp-controls"))});api.on("ready",function(e,api,video){setTimeout(function(){jQuery(".fvp-share-bar",root).show();jQuery(".fv-player-buttons-wrap",root).appendTo(jQuery(".fv-player-buttons-wrap",root).parent().find(".fp-ui"))},100)});api.bind("finish",function(){var url=root.data("fv_redirect");if(url&&(typeof api.video.is_last=="undefined"||api.video.is_last)){location.href=url}});if(flowplayer.support.iOS&&flowplayer.support.iOS.version==11){api.bind("error",function(e,api,error){if(error.code==4)root.find(".fp-engine").hide()})}jQuery(document).on("contextmenu",".flowplayer",function(e){e.preventDefault()});api.one("ready",function(e,api,video){root.find(".fp-chromecast").insertAfter(root.find(".fp-header .fp-fullscreen"))});root.find(".fp-waiting").html('<div class="fp-preload"><b></b><b></b><b></b><b></b></div>');var id=root.attr("id"),alternative=!flowplayer.conf.native_fullscreen&&flowplayer.conf.mobile_alternative_fullscreen,events_enter="fakefullscreen",events_exit="fakefullscreen-exit";if(!flowplayer.support.fullscreen){events_enter+=" fullscreen";events_exit+=" fullscreen-exit"}api.bind(events_enter,function(e,api){jQuery("#wpadminbar, .nc_wrapper").hide();if(alternative||e.type=="fakefullscreen"){if(api.video.type=="video/youtube")return;root.before('<span data-fv-placeholder="'+id+'"></span>');root.appendTo("body")}});api.bind(events_exit,function(e,api,video){jQuery("#wpadminbar, .nc_wrapper").show();if(alternative||e.type=="fakefullscreen-exit"){jQuery("span[data-fv-placeholder="+id+"]").replaceWith(root)}})});(function(){var extension=function(flowplayer){flowplayer(function(api,root){if(!jQuery(root).data("speedb"))return;var support=flowplayer.support;if(!support.video||!support.inlineVideo)return;var common=flowplayer.common,bean=flowplayer.bean,ui=common.find(".fp-ui",root)[0],controlbar=common.find(".fp-controls",ui)[0],speeds=api.conf.speeds;bean.on(root,"click",".fp-speed",function(){var menu=common.find(".fp-speed-menu",root)[0];if(common.hasClass(menu,"fp-active"))api.hideMenu();else api.showMenu(menu)});bean.on(root,"click",".fp-speed-menu a",function(ev){var s=ev.target.getAttribute("data-speed");api.speed(s)});api.on("speed",function(ev,_a,rate){if(speeds.length>1){selectSpeed(rate)}}).on("ready",function(ev,api){removeMenu();if(flowplayer.support.android&&api.engine.engineName=="html5"&&api.video.type=="application/x-mpegurl")return;speeds=api.conf.speeds;if(speeds.length>1){createMenu()}});function removeMenu(){common.find(".fp-speed-menu",root).forEach(common.removeNode);common.find(".fp-speed",root).forEach(common.removeNode)}function round(val){return Math.round(val*100)/100}function createMenu(){controlbar.appendChild(common.createElement("strong",{className:"fp-speed"},api.currentSpeed+"x"));var menu=common.createElement("div",{className:"fp-menu fp-speed-menu",css:{width:"auto"}},"<strong>Speed</strong>");speeds.forEach(function(s){var a=common.createElement("a",{"data-speed":round(s)},round(s)+"x");menu.appendChild(a)});ui.appendChild(menu);selectSpeed(api.currentSpeed);jQuery(root).find(".fp-speed-menu strong").text(fv_flowplayer_translations.speed)}function selectSpeed(rate){common.find(".fp-speed",root)[0].innerHTML=rate+"x";common.find(".fp-speed-menu a",root).forEach(function(el){common.toggleClass(el,"fp-selected",el.getAttribute("data-speed")==rate);common.toggleClass(el,"fp-color",el.getAttribute("data-speed")==rate)})}})};if(typeof module==="object"&&module.exports)module.exports=extension;else if(typeof window.flowplayer==="function")extension(window.flowplayer)})();flowplayer(function(api,root){if(typeof fv_flowplayer_conf.disable_localstorage!="undefined"){return}api.on("speed",function(ev,_a,rate){try{window.localStorage.fv_player_speed=rate}catch(e){}});api.on("ready",function(){if(window.localStorage.fv_player_speed&&jQuery(root).find("strong.fp-speed").is(":visible")){api.speed(parseFloat(window.localStorage.fv_player_speed))}if(jQuery(root).data("volume")==0){api.mute(true,true)}})});flowplayer(function(api,root){root=jQuery(root);var last_tracked=-1;if(!api.conf.fv_stats||!api.conf.fv_stats.enabled&&(!root.data("fv_stats")||root.data("fv_stats")=="no"))return;api.on("ready finish",function(e,api){api.one("progress",function(e,api){if(root.data("fv_stats_data")){try{var player_post_data=root.data("fv_stats_data")}catch(e){return false}if(last_tracked==get_index())return;last_tracked=get_index();jQuery.post(api.conf.fv_stats.url,{blog_id:api.conf.fv_stats.blog_id,video_id:api.video.id?api.video.id:0,player_id:player_post_data.player_id,post_id:player_post_data.post_id,tag:"play"})}})}).on("finish",function(){last_tracked=-1});function get_index(){return api.video.index?api.video.index:0}});flowplayer(function(api,root){var $root=jQuery(root);var $playerDiv=$root.find(".fp-player");var sticky=$root.data("fvsticky");var globalSticky=false;var videoRatio=$root.data("ratio"),is_sticky=false;if(typeof videoRatio=="undefined"){videoRatio=.5625}if(flowplayer.conf.sticky_video==1&&typeof sticky=="undefined"){globalSticky=true}if(globalSticky||sticky){if(flowplayer.support.firstframe){var stickyPlace=flowplayer.conf.sticky_place;var stickyWidth=flowplayer.conf.sticky_width;if(stickyWidth==""){stickyWidth=380}var stickyHeight=stickyWidth*videoRatio;fv_player_sticky_video()}else{return}}function fv_player_sticky_video(){var change=false;var $window=jQuery(window),$flowplayerDiv=$root,top=$flowplayerDiv.offset().top,offset=Math.floor(top+$flowplayerDiv.outerHeight()/2);api.on("ready",function(){change=true});api.on("progress",function(){change=true});api.on("unload",function(){change=false;fv_player_sticky_class_remove();$root.removeClass("is-unSticky")});$window.on("resize",function(){if(!is_big_enough()){if(is_sticky){fv_player_sticky_class_remove()}return}top=$flowplayerDiv.offset().top;offset=Math.floor(top+$flowplayerDiv.outerHeight()/2)}).on("scroll",function(){if(!is_big_enough()){if(is_sticky){fv_player_sticky_class_remove()}return}top=$flowplayerDiv.offset().top;offset=Math.floor(top+$flowplayerDiv.outerHeight()/2);if($window.scrollTop()>offset&&change){if(jQuery("div.flowplayer.is-unSticky").length>0){console.log("unSticky",jQuery("div.flowplayer.is-unSticky").length);return false}else{fv_player_sticky_class_add()}}else{fv_player_sticky_class_remove();change=false}})}function fv_player_sticky_class_add(){if($playerDiv.hasClass("is-sticky-"+stickyPlace)){return}else{$playerDiv.addClass("is-sticky-"+stickyPlace);if($root.find("a.fp-sticky").length==0){$root.find("div.fp-header").prepend('<a class="fp-sticky fp-icon"></a>')}$playerDiv.css("width",stickyWidth);$playerDiv.css("height",stickyHeight);$playerDiv.css("max-height",stickyHeight);is_sticky=true;api.trigger("sticky",[api])}$playerDiv.parent(".flowplayer").addClass("is-stickable")}function fv_player_sticky_class_remove(){$playerDiv.removeClass("is-sticky-"+stickyPlace);$playerDiv.css("width","");$playerDiv.css("height","");$playerDiv.css("max-height","");$playerDiv.parent(".flowplayer").removeClass("is-stickable");if(is_sticky){is_sticky=false;api.trigger("sticky-exit",[api])}}function is_big_enough(){return jQuery(window).innerWidth()>=1020}});jQuery(function($){$(document).on("click","a.fp-sticky",function(){$("div.flowplayer.is-stickable").addClass("is-unSticky");var $playerDiv=$("div.flowplayer.is-stickable").find(".fp-player");$playerDiv.removeClass("is-sticky-right-bottom");$playerDiv.removeClass("is-sticky-left-bottom");$playerDiv.removeClass("is-sticky-right-top");$playerDiv.removeClass("is-sticky-left-top");$playerDiv.css("width","");$playerDiv.css("height","");$playerDiv.css("max-height","");if(is_sticky){is_sticky=false;api.trigger("sticky-exit",[api])}});$(document).on("click","div.flowplayer.is-unSticky",function(){$("div.flowplayer").removeClass("is-unSticky")})});flowplayer(function(api,root){root=jQuery(root);if(typeof fv_flowplayer_conf.disable_localstorage!="undefined"){return}var ls=window.localStorage;api.on("ready",function(e,api,video){if(root.find("strong.fp-cc").is(":visible")){if(ls.fv_player_subtitle&&api.video.subtitles.length){if(ls.fv_player_subtitle==="none"){api.disableSubtitles()}else{api.video.subtitles.forEach(function(item,index){if(item.srclang===ls.fv_player_subtitle){api.loadSubtitles(index)}})}}else{var defaultSubtitle=video.subtitles.filter(function(one){return one["fv_default"]})[0];if(defaultSubtitle){api.loadSubtitles(video.subtitles.indexOf(defaultSubtitle))}}}root.find(".fp-subtitle-menu").on("click",function(e){var subtitle_index=e.target.getAttribute("data-subtitle-index");if(typeof subtitle_index=="string"){try{ls.fv_player_subtitle=subtitle_index>-1?api.video.subtitles[subtitle_index].srclang:"none"}catch(e){}}})})});flowplayer(function(api,root){root=jQuery(root);var currentPoint,check=false;api.bind("cuepoint",function(e,api,cue){check=false;if(cue.subtitle){currentPoint=cue.index}});api.on("ready",function(e,api){root.find(".fp-subtitle-menu strong").text(fv_flowplayer_translations.closed_captions);root.find('.fp-subtitle-menu a[data-subtitle-index="-1"]').text(fv_flowplayer_translations.no_subtitles)});root.on("click",".fp-subtitle-menu a[data-subtitle-index]",function(e){if(jQuery(this).data("subtitle-index")>-1){check=true;api.on("progress",time_check)}});function time_check(e,api,time){if(check){(api.cuepoints||[]).forEach(function(cue,index){var entry=cue.subtitle;if(entry&&currentPoint!=index){if(time>=cue.time&&(!entry.endTime||time<=entry.endTime)){api.trigger("cuepoint",[api,cue])}}})}}});if(typeof flowplayer!=="undefined"&&typeof fv_flowplayer_conf!="undefined"&&fv_flowplayer_conf.video_hash_links){flowplayer(function(api,root){if(jQuery(root).find(".sharing-link").length>0){var abEnd,abStart,hash,sTime,abloop;function update_link(abStartNew,abEndNew){hash=fv_player_get_video_link_hash(api);sTime=","+fv_player_time_hms(api.video.time);if(abStartNew&&abEndNew){abStart=","+fv_player_time_hms_ms(abStartNew+api.get_custom_start());abEnd=","+fv_player_time_hms_ms(abEndNew+api.get_custom_start())}else{abEnd=abloop&&typeof api.get_ab_end()!="undefined"&&api.get_ab_end()?","+fv_player_time_hms_ms(api.get_ab_end()):"";abStart=abloop&&typeof api.get_ab_start()!="undefined"&&api.get_ab_start()?","+fv_player_time_hms_ms(api.get_ab_start()):""}jQuery(".sharing-link",root).attr("href",jQuery(".sharing-link",root).attr("href").replace(/#.*/,"")+"#"+hash+sTime+abStart+abEnd)}api.on("ready",function(e,api,video){if(!api.fv_noUiSlider)return;api.fv_noUiSlider.on("set",function(values){update_link(values[0],values[1])})});api.on("progress",function(e,api){if(!api.video.sources||!api.video.sources[0]){return}update_link()});api.on("abloop",function(e,api,active){abloop=active;if(!api.playing){update_link()}});jQuery(".sharing-link",root).on("click",function(e){fv_player_clipboard(jQuery(this).attr("href"),function(){e.preventDefault();fv_player_notice(root,fv_flowplayer_translations.link_copied,2e3)})})}});jQuery(document).on("click",'a[href*="fvp_"]',function(){var link=jQuery(this);setTimeout(function(){if(link.parents(".fvp-share-bar").length==0)fv_autoplay_exec()})})}flowplayer(function(api,root){root=jQuery(root);var bean=flowplayer.bean;var restore=flowplayer.conf.default_volume;root.on("mousedown touchstart",".fp-volumebtn",function(e){var volumebtn=jQuery(this);if(api.volumeLevel==0){volumebtn.one("click",function(){api.volume(restore);return false})}});root.on("mousedown touchstart mouseup touchend",".fp-volumebar",function(e){if(api.volumeLevel!=0){restore=api.volumeLevel}});api.on("volume",function(e,api){if(root.hasClass("is-mouseover")&&!api.muted){if(api.volumeLevel==0){bean.off(flowplayer.support.touch?root:document,"mousemove.sld touchmove.sld");api.mute(true)}}});var deal_with_muted_start=false;api.one("ready",function(e,api){if(root.hasClass("is-audio"))return;deal_with_muted_start=true});api.on("progress",function(e,api,time){if(deal_with_muted_start&&time>1){deal_with_muted_start=false;var video=jQuery("root").find("video");if(video.length&&!hasAudio(video[0])){return}if(api.muted||api.volumeLevel==0){if(localStorage.muted=="true"||localStorage.volume=="0"){return}var mute_notice=jQuery('<div class="fp-message fp-message-muted"><span class="fp-icon fp-volumebtn-notice"></span> '+fv_flowplayer_translations.click_to_unmute+"</div>");mute_notice.on("click touchstart",function(){api.mute(false);api.volume(1)});root.find(".fp-ui").append(mute_notice);root.addClass("has-fp-message-muted");setTimeout(remove_volume_notice,5e3)}}});api.on("mute volume",function(){if(!api.muted||api.volumeLevel>0){remove_volume_notice()}});function remove_volume_notice(){root.removeClass("has-fp-message-muted");root.find(".fp-message-muted").remove()}function hasAudio(video){return video.mozHasAudio||Boolean(video.webkitAudioDecodedByteCount)||Boolean(video.audioTracks&&video.audioTracks.length)}});if(typeof flowplayer!="undefined"){flowplayer(function(api,root){root=jQuery(root);if(navigator.userAgent.match(/iPhone.* OS [0-6]_/i)){api.one("progress",function(e){if(typeof api.video.subtitles!=="undefined"&&api.video.subtitles.length){fv_player_warning(root,fv_flowplayer_translations.warning_iphone_subs)}})}if(flowplayer.support.android&&flowplayer.support.android.version<5&&(flowplayer.support.android.samsung||flowplayer.support.browser.safari)){fv_player_warning(root,fv_flowplayer_translations.warning_unstable_android,"firefox")}if(/Android 4/.test(navigator.userAgent)&&!/Firefox/.test(navigator.userAgent)){api.on("ready",function(e,api,video){setTimeout(function(){if(video.src&&video.src.match(/fpdl.vimeocdn.com/)&&(video.time==0||video.time==1)){fv_player_warning(root,fv_flowplayer_translations.warning_unstable_android,"firefox");api.on("progress",function(e,api){root.prev().find(".fv-player-warning-firefox").remove()})}},1500)});api.on("error",function(e,api,error){if(error.MEDIA_ERR_NETWORK==2&&error.video.src.match(/fpdl.vimeocdn.com/)){fv_player_warning(root,fv_flowplayer_translations.warning_unstable_android,"firefox")}})}if(/Safari/.test(navigator.userAgent)&&/Version\/5/.test(navigator.userAgent)){api.on("error",function(e,api,error){if(error.video.src.match(/fpdl.vimeocdn.com/)){fv_player_warning(root,fv_flowplayer_translations.warning_old_safari)}})}var sup=flowplayer.support;if(sup.android&&(sup.android.samsung&&parseInt(sup.browser.version)<66||sup.browser.safari)){api.on("error",function(e,api,error){fv_player_warning(root,fv_flowplayer_translations.warning_samsungbrowser,"warning_samsungbrowser")})}});function fv_player_warning(root,warning,classname){var wrapper=jQuery(root).prev(".fv-player-warning-wrapper");if(wrapper.length==0){jQuery(root).before('<div class="fv-player-warning-wrapper">');wrapper=jQuery(root).prev(".fv-player-warning-wrapper")}if(wrapper.find(".fv-player-warning-"+classname).length==0){var latest=jQuery("<p style='display: none' "+(classname?" class='fv-player-warning-"+classname+"'":"")+">"+warning+"</p>");wrapper.append(latest);latest.slideDown()}}}
flowplayer/modules/pending-encoding.module.js CHANGED
@@ -13,7 +13,7 @@ if( typeof(flowplayer) !== "undefined" ) {
13
 
14
  // Do we need to show the notice right away?
15
  var playlist = api.conf.playlist.length ? api.conf.playlist : [ api.conf.clip ];
16
- if( playlist[0].pending_encoding) {
17
  show_notice(playlist[0]);
18
  }
19
 
13
 
14
  // Do we need to show the notice right away?
15
  var playlist = api.conf.playlist.length ? api.conf.playlist : [ api.conf.clip ];
16
+ if( playlist[0] && playlist[0].pending_encoding) {
17
  show_notice(playlist[0]);
18
  }
19
 
js/bunny_stream-admin.js ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function($) {
2
+ var $expert_ui = $('#fv-player-coconut-expert-ui'),
3
+ $expert_submit = $expert_ui.find('[type=submit]'),
4
+ $expert_source = $expert_ui.find('#fv_player_coconut_expert_source'),
5
+ $expert_target = $expert_ui.find('#fv_player_coconut_expert_target'),
6
+ $expert_encryption = $expert_ui.find('[name=fv_player_coconut_expert_encryption]'),
7
+ $expert_trailer = $expert_ui.find('[name=fv_player_coconut_expert_trailer]'),
8
+ $expert_nonce = $expert_ui.find('[name=fv_player_coconut_nonce]');
9
+
10
+ jQuery( document ).on( 'heartbeat-send', function ( event, data ) {
11
+ if ( typeof(coconut_pending_jobs) != 'undefined' && coconut_pending_jobs.length > 0 ) {
12
+ data.coconut_pending = coconut_pending_jobs;
13
+ }
14
+ });
15
+
16
+ // HeartBeat update row
17
+ $(document).on( 'heartbeat-tick', function ( event, data ) {
18
+ var rows = data.coconut;
19
+
20
+ if(typeof rows === 'object' && rows !== null) {
21
+ for (var key in rows) {
22
+ if (rows.hasOwnProperty(key)) {
23
+ var table_row = $('a[data-id="'+key+'"]').closest('tr'); // find row
24
+ if (table_row.length == 0 ) {
25
+ $( rows[key] ).prependTo( $( "#the-list" ) ); // if no row then add new
26
+ } else{
27
+ table_row.replaceWith(rows[key]); // replace with new data
28
+ }
29
+ }
30
+ }
31
+ }
32
+
33
+ // update pending jobs
34
+ if( typeof data.coconut_still_pending == 'undefined' ) {
35
+ coconut_pending_jobs = [];
36
+ } else {
37
+ coconut_pending_jobs = data.coconut_still_pending;
38
+ }
39
+ });
40
+
41
+ // Delete completed or failed job
42
+ $(document).on('click', '.job-delete', function(e) {
43
+ var
44
+ $e = $(this),
45
+ args = {
46
+ action: 'fv_player_coconut_delete_job',
47
+ nonce: $e.data('nonce'),
48
+ id_row: $e.data('id')
49
+ };
50
+
51
+ // console.log(args);
52
+
53
+ if ( confirm('Do you want to delete this job? Files will have to be removed manually from:' + $(this).data('message')) ) {
54
+ $.post(ajaxurl, args, function(data) {
55
+ if( data.error ) {
56
+ alert(data.error);
57
+ } else {
58
+ $e.parents('tr:first').remove();
59
+ alert(data.success);
60
+ }
61
+ });
62
+ }
63
+
64
+ return false;
65
+
66
+ });
67
+
68
+ function sanitize_target_path(path) {
69
+ path = path.split('/');
70
+ var filename = path[path.length - 1];
71
+
72
+ // remove file extension
73
+ if( filename.match(/\./) ) {
74
+ filename = filename.split('.').slice(0, -1).join('.')
75
+ }
76
+
77
+ // allow only safe characters
78
+ filename = filename.replace(/[^A-Za-z0-9\-]/gm, '-');
79
+ filename = filename.replace(/-{2,}/gm, '-');
80
+ filename = filename.replace(/^-|-$/gm, '');
81
+
82
+ // we're done
83
+ path[path.length - 1] = filename;
84
+ return path.join('/');
85
+ }
86
+
87
+ $expert_target.on('blur', function() {
88
+ this.value = sanitize_target_path( this.value );
89
+ });
90
+
91
+ $expert_target.on('keyup mouseup', function() {
92
+ this.value = this.value.replace(/[^A-Za-z0-9\-]/gm, '-');
93
+ });
94
+
95
+ $expert_ui.on( 'submit', function() {
96
+ $expert_submit.prop('disabled',true);
97
+
98
+ var args = {
99
+ action: 'fv_player_coconut_submit',
100
+ nonce: $expert_nonce.val(),
101
+ source: $expert_source.val(),
102
+ encryption: $expert_encryption.prop('checked') ? 1 : 0,
103
+ trailer: $expert_trailer.prop('checked') ? 1 : 0,
104
+ category_id: $('#fv_player_encoding_categorychecklist input:checked').val(),
105
+ target: $expert_target.val()
106
+ };
107
+
108
+ $.post(ajaxurl, args, function(data){
109
+ $expert_submit.prop('disabled',false);
110
+
111
+ if( data.error ) {
112
+ alert(data.error);
113
+ } else {
114
+ var html = $('#the-list', data.html).html();
115
+ if( !coconut_pending_jobs.includes(String(data.id)) ) { // add new job if not in array
116
+ coconut_pending_jobs.push(String(data.id));
117
+ console.log('Pending jobs', coconut_pending_jobs);
118
+ }
119
+ $('#the-list').prepend(html);
120
+ }
121
+ });
122
+
123
+ return false;
124
+
125
+ });
126
+
127
+ // TODO: This should be done properly, not hardcoded for DigitalOcean Spaces
128
+ var fv_player_uploader;
129
+
130
+ $('#wpbody-content').on('click', '.fv-player-bunny_stream-add', function(e) {
131
+
132
+ $( document ).one( "click", ".media-button-select", function(event) {
133
+ var
134
+ $e = jQuery('#__assets_browser .selected'),
135
+ filenameDiv = ($e.get(0).tagName == 'TR' ? $e.find('td:first') : $e.find('.filename div'));
136
+
137
+ if (filenameDiv.length && filenameDiv.data('link')) {
138
+ $expert_source.val( filenameDiv.data('link') );
139
+
140
+ var path = filenameDiv.data('link').split('/');
141
+ $expert_target.val( sanitize_target_path( path[path.length - 1] ) );
142
+ $expert_ui.show();
143
+ }
144
+ });
145
+
146
+ //If the uploader object has already been created, reopen the dialog
147
+ if (fv_player_uploader) {
148
+ fv_player_uploader.open();
149
+ return;
150
+ }
151
+
152
+ //Extend the wp.media object
153
+ fv_player_uploader = wp.media.frames.file_frame = wp.media({
154
+ title: 'Add Video',
155
+ button: {
156
+ text: 'Choose'
157
+ },
158
+ multiple: false
159
+ });
160
+
161
+ fv_player_uploader.on('open', function() {
162
+ $( document ).trigger( "mediaBrowserOpen" );
163
+ jQuery('.media-router .media-menu-item').eq(0).click();
164
+ //jQuery('.media-frame-title h1').text(fv_flowplayer_uploader_button.text());
165
+ });
166
+
167
+ //When a file is selected, grab the URL and set it as the text field's value
168
+ /*fv_flowplayer_uploader.on('select', function() {
169
+ attachment = fv_flowplayer_uploader.state().get('selection').first().toJSON();
170
+ console.log(attachment);
171
+ $('#fv_player_coconut_expert_source').val(attachment.url);
172
+ $expert_ui.show();
173
+ });*/
174
+
175
+ fv_player_uploader.open();
176
+
177
+ return false;
178
+ });
179
+
180
+ });
181
+
182
+ ( function($) {
183
+ var open = false;
184
+ $(document).on('click', '.hover-wrap > a', function() {
185
+ if( open ) open.hide();
186
+
187
+ open = $(this).next();
188
+ open.show();
189
+ return false;
190
+ });
191
+
192
+ $(document).on('click', function(e) {
193
+ if( open.length ) {
194
+ if( $(e.target).closest('.hover-details').length ) {
195
+ return;
196
+ }
197
+ open.hide();
198
+ }
199
+ });
200
+ } )(jQuery);
201
+
202
+ ( function($) {
203
+ /*
204
+ Encoding category adding
205
+ */
206
+
207
+ // when adding new categories...
208
+ $(document).on('click', '#fv_player_encoding_category-add-submit', function(e) {
209
+ // uncheck anything previously selected
210
+ $('#fv_player_encoding_categorychecklist input[type=checkbox]').prop('checked',false);
211
+ // remove the message to add some category
212
+ $('#fv-player-coconut-category-nag').remove();
213
+ });
214
+
215
+ // make sure only one category stays selected
216
+ $(document).on('click', '#fv_player_encoding_categorychecklist input[type=checkbox]', function(e) {
217
+ $('#fv_player_encoding_categorychecklist input[type=checkbox]').prop('checked',false);
218
+ $(this).prop('checked','checked');
219
+ });
220
+
221
+ // When the media Library is open go to Bunny Stream browser directly
222
+ // But make sure you are on the right screen - FV Player -> Bunny Stream Jobs
223
+ if( location.href.match(/page=fv_player_bunny_stream/) ) {
224
+ $(document).on("mediaBrowserOpen", function () {
225
+ var bunny_stream_browser_link = false;
226
+
227
+ // let FV Player's fv_flowplayer_media_browser_add_tab do its job
228
+ // TODO: Should use a proper event
229
+ var bunny_stream_browser_finder = setInterval( function() {
230
+ bunny_stream_browser_link = $('#fv_player_bunny_stream_browser_media_tab');
231
+ if( bunny_stream_browser_link.length ) {
232
+ clearInterval(bunny_stream_browser_finder);
233
+
234
+ var height = $('.media-frame-router').height();
235
+ $('.media-frame-router').hide();
236
+
237
+ // the list of files uses absolute positioning
238
+ // so when we remove the tabs we move it up a bit
239
+ var original_height = parseInt( $('.media-frame-content').css('top') );
240
+ if( original_height > 80 ) {
241
+ $('.media-frame-content').css('top', parseInt($('.media-frame-content').css('top')) - height );
242
+ }
243
+
244
+ // Open DigitalOcean Spaces browser
245
+ setTimeout(function() {
246
+ if( !bunny_stream_browser_link.hasClass('active') ) {
247
+ bunny_stream_browser_link.click();
248
+ }
249
+ }, 500);
250
+ }
251
+
252
+ }, 5 );
253
+
254
+ // Give up after a while
255
+ setTimeout( function() {
256
+ clearInterval(bunny_stream_browser_finder);
257
+ }, 2000 );
258
+
259
+ // Hide the Choose button because the videos are uploaded with drag&drop
260
+ $('.media-toolbar-primary').html('<button type="button" class="button media-button button-primary button-large" disabled="">Pick your video in FV Player directly</button>');
261
+
262
+ });
263
+
264
+ }
265
+ } )(jQuery);
js/bunny_stream-browser.js ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function($) {
2
+ var firstLoad = true;
3
+
4
+ function fv_player_bunny_stream_browser_load_assets() {
5
+ var
6
+ $this = jQuery(this),
7
+ $media_frame_content = jQuery('.media-frame-content:visible'),
8
+ $overlay_div = jQuery('#fv-player-shortcode-editor-preview-spinner').clone().css({
9
+ 'height' : '100%'
10
+ }),
11
+ page = 1,
12
+ ajax_data = {
13
+ action: "load_bunny_stream_jobs",
14
+ cookie: encodeURIComponent(document.cookie),
15
+ page: page
16
+ },
17
+ appending = false,
18
+ allLoaded = false;
19
+
20
+ if( window.fv_flowplayer_browser_get_function ) {
21
+ fv_flowplayer_browser_get_function[ 'fv_player_bunny_stream_browser_media_tab' ] = fv_player_bunny_stream_browser_load_assets;
22
+ }
23
+
24
+ $this.addClass('active').siblings().removeClass('active')
25
+
26
+ function loadMoreFunction(force) {
27
+ if ((!appending && !allLoaded) || force === true) {
28
+ appending = true;
29
+ // reset allLoaded if we're forcing a load after API error
30
+ if (force === true) {
31
+ allLoaded = false;
32
+ }
33
+ page++;
34
+ getBunnyStreamData();
35
+ }
36
+ return false;
37
+ }
38
+
39
+ function getBunnyStreamData() {
40
+ // check if we have search data to include
41
+ var searchVal = $('#media-search-input').val();
42
+
43
+ // show overlay if we're not appending, otherwise append the overlay and then remove it
44
+ if (firstLoad) {
45
+ $media_frame_content.html($overlay_div);
46
+ } else {
47
+ jQuery('#overlay-loader-li div').html($overlay_div);
48
+ }
49
+
50
+ if (searchVal) {
51
+ ajax_data['search'] = searchVal;
52
+ } else {
53
+ delete(ajax_data['search']);
54
+ }
55
+
56
+ ajax_data['page'] = page;
57
+ ajax_data['appending'] = (appending ? 1 : 0);
58
+ ajax_data['firstLoad'] = (firstLoad ? 1 : 0);
59
+
60
+ jQuery.post(ajaxurl, ajax_data, function(ret) {
61
+ // don't overwrite the page if we've shown the browser for the first time already
62
+ // ... instead, we'll be either clearing and rewriting the UL or appending data to it
63
+ if (firstLoad) {
64
+ var renderOptions = {};
65
+
66
+ // add errors, if any
67
+ if (ret.err) {
68
+ renderOptions['errorMsg'] = ret.err;
69
+ }
70
+
71
+ $media_frame_content.html( renderBrowserPlaceholderHTML(renderOptions) );
72
+ } else if (!appending && !allLoaded) {
73
+ // clear the UL if we're not appending
74
+ jQuery('#__assets_browser').find('li').remove();
75
+ }
76
+
77
+ // if our result didn't return any items, there's been an error
78
+ // and we don't need to bother with any display logic below
79
+ if (!ret.items.items) {
80
+ return;
81
+ }
82
+
83
+ var
84
+ $ul = jQuery('#__assets_browser'),
85
+ havePendingItems = false;
86
+
87
+ firstLoad = false;
88
+
89
+ // if we didn't get any items back and we're auto-loading data for infinite scroll,
90
+ // set allLoaded to true, so we don't try to load any more data
91
+ if (!ret.items.items.length && appending) {
92
+ jQuery('#overlay-loader-li').remove();
93
+
94
+ // if we got an error, re-add the Load More button
95
+ if (ret.err) {
96
+ fv_flowplayer_browser_add_load_more_button($ul, function() { loadMoreFunction(true); });
97
+ }
98
+
99
+ appending = false;
100
+ allLoaded = true;
101
+ return;
102
+ }
103
+
104
+ // remove temporary loading LI if we're not displaying the full browser for the first time
105
+ if (!firstLoad) {
106
+ jQuery('#overlay-loader-li').remove();
107
+ }
108
+
109
+ fv_flowplayer_browser_browse( ret.items, {
110
+ noFileName: true,
111
+ append: appending,
112
+ extraAttachmentClass: 'fullsize',
113
+ ajaxSearchCallback: function() {
114
+ allLoaded = false;
115
+ appending = false;
116
+ page = 1;
117
+ getBunnyStreamData();
118
+ },
119
+ loadMoreButtonAction: (ret.is_last_page ? false : loadMoreFunction)
120
+ } );
121
+
122
+ // if we have any items returned in a processing state, auto-refresh the Coconut tab every 30 seconds
123
+ if ( ret.items && ret.items.items ) {
124
+ for ( var item of ret.items.items ) {
125
+ if ( item.extra && item.extra.encoding_job_status && item.extra.encoding_job_status == 'processing' ) {
126
+ havePendingItems = true;
127
+ }
128
+ }
129
+ }
130
+
131
+ if ( havePendingItems ) {
132
+ setTimeout( function() {
133
+ // only reload tab if the tab is actually still visible and active
134
+ var $tab = $( '#fv_player_bunny_stream_browser_media_tab' );
135
+ if ( $tab.is(':visible') && $tab.hasClass('active') )
136
+ fv_player_bunny_stream_browser_load_assets();
137
+ }, 30000 );
138
+ }
139
+
140
+ appending = false;
141
+ } );
142
+ }
143
+
144
+ getBunnyStreamData();
145
+ return false;
146
+ };
147
+
148
+ $( document ).on( "mediaBrowserOpen", function(event) {
149
+ var tabId = 'fv_player_bunny_stream_browser_media_tab';
150
+
151
+ // make sure we'll add .m3u8 files with the same name as our encoded file into the list of elements to lookup splash images in
152
+ if( window.fv_flowplayer_browser_splash_file_lookup_rules ) {
153
+ fv_flowplayer_browser_splash_file_lookup_rules[ tabId ] = { 'include' : ['\.(m3u8)$'] };
154
+ }
155
+ fv_flowplayer_media_browser_add_tab( tabId, 'Bunny Stream', fv_player_bunny_stream_browser_load_assets, null, function() {
156
+ firstLoad = true;
157
+ }).addClass('upload_supported');
158
+ });
159
+ });
js/bunny_stream-shortcode-editor.js ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+ var field = 'fv_wp_flowplayer_field_encoding_job_id',
3
+ meta_key = 'encoding_job_id';
4
+
5
+ // TODO: The above is all you should ever need!
6
+
7
+ ('use strict');
8
+ $(document).on('fv_flowplayer_video_meta_save', function(event, data, element_data_index, element) {
9
+ //console.log(element.id,field);
10
+ if (element.id != field) {
11
+ return;
12
+ }
13
+
14
+ if (!data['video_meta']['video']) {
15
+ data['video_meta']['video'] = {};
16
+ }
17
+
18
+ if (!data['video_meta']['video'][element_data_index]) {
19
+ data['video_meta']['video'][element_data_index] = {};
20
+ }
21
+
22
+ // handle hslkey metadata for each video
23
+ fv_flowplayer_insertUpdateOrDeleteVideoMeta({
24
+ data: data,
25
+ meta_section: 'video',
26
+ meta_key: meta_key,
27
+ meta_index: element_data_index,
28
+ element: element
29
+ });
30
+ });
31
+
32
+ $(document).on('fv_flowplayer_video_meta_load', function(event, element_meta_index, metadata, $video_data_tab) {
33
+ var meta_found = false;
34
+
35
+ if (metadata) {
36
+ for (var i in metadata) {
37
+ if (metadata[i].meta_key == meta_key) {
38
+ if (metadata[i].meta_value) {
39
+ meta_found = true;
40
+ }
41
+
42
+ $video_data_tab.find('#'+field)
43
+ .val(metadata[i].meta_value)
44
+ .attr('data-id', metadata[i].id);
45
+ }
46
+ }
47
+ }
48
+ });
49
+
50
+ $(document).on('fv_flowplayer_shortcode_parse', function() {
51
+ $('#'+field).val('');
52
+ } );
53
+
54
+
55
+ }(jQuery));
js/bunny_stream-upload.js ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function($) {
2
+ var
3
+ $doc = $( document ),
4
+ $uploadButton,
5
+ $uploadInput,
6
+ $cancelButton,
7
+ $progressDiv,
8
+ $progressBar,
9
+ $progressBarNumber,
10
+ $progressBarDiv,
11
+ file_select_input_name = 'fv-player-bunny_stream-upload-file-select',
12
+ file_select_input_class = 'fv-player-bunny_stream-upload-file-select',
13
+ upload_success_message = 'Upload successful',
14
+ upload_button_class = 'fv-player-bunny_stream-browser-upload',
15
+ file_upload_xhr = null;
16
+
17
+ function recreate_file_input( input_name, input_class_name ) {
18
+ if ( $uploadInput.length ) {
19
+ $uploadInput.remove();
20
+ }
21
+
22
+ $uploadButton.after('<input type="file" accept=".mp4,.mov,.web,.flv,.avi,.vmw,.avchd,.swf,.mkv,.webm.,mpeg,.mpg" class="fv-player-bunny_stream-upload-file-input ' + input_class_name + '" name="' + input_name + '" />');
23
+
24
+ $uploadInput = $('.media-toolbar-secondary > #' + upload_button_class + '-wrap .' + input_class_name);
25
+ $uploadInput.change(function() {
26
+ upload( $uploadInput[0].files[0] );
27
+ });
28
+ }
29
+
30
+ function getReadableFileSizeString(fileSizeInBytes) {
31
+ var i = -1;
32
+ var byteUnits = [ ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB' ];
33
+ do {
34
+ fileSizeInBytes = fileSizeInBytes / 1024;
35
+ i++;
36
+ } while (fileSizeInBytes > 1024);
37
+
38
+ return Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i];
39
+ }
40
+
41
+ function calculate_progress( totalSize, uploadedSize ) {
42
+ var progress = parseInt(uploadedSize / totalSize * 100, 10);
43
+ $progressBar.css(
44
+ 'width',
45
+ progress + '%'
46
+ );
47
+
48
+ $progressDiv.text('Uploading...');
49
+ $progressBarNumber.html( getReadableFileSizeString(uploadedSize) + " / "+getReadableFileSizeString(totalSize) ).css({'margin-left' : -$progressBarNumber.width()/2});
50
+ }
51
+
52
+ function ajax_file_upload( file, video_guid ) {
53
+ $progressDiv.text("Uploading...");
54
+ $progressBarDiv.show();
55
+
56
+ file_upload_xhr = $.ajax({
57
+ "async": true,
58
+ "crossDomain": true,
59
+ "url": "https://video.bunnycdn.com/library/" + fv_player_bunny_stream_upload_settings.lib_id + "/videos/" + video_guid,
60
+ "method": "PUT",
61
+ "headers": {
62
+ "AccessKey": fv_player_bunny_stream_upload_settings.api_key,
63
+ },
64
+ data: file,
65
+ cache: false,
66
+ contentType: false,
67
+ processData: false,
68
+ // Custom XMLHttpRequest
69
+ xhr: function () {
70
+ var myXhr = $.ajaxSettings.xhr();
71
+ if ( myXhr.upload ) {
72
+ // For handling the progress of the upload
73
+ myXhr.upload.addEventListener('progress', function (e) {
74
+ if ( e.lengthComputable ) {
75
+ calculate_progress( e.total, e.loaded );
76
+ }
77
+ }, false);
78
+ }
79
+
80
+ return myXhr;
81
+ },
82
+ })
83
+ .fail(function( jqXHR, textStatus, errorThrown ) {
84
+ $progressDiv.text("Upload failed with server error.");
85
+ $progressBarDiv.hide();
86
+ console.log( jqXHR, textStatus, errorThrown );
87
+ })
88
+ .done( function( response ) {
89
+ if ( response && typeof( response ) == 'object' && response.success ) {
90
+ // everything worked out fine, file is uploaded
91
+ // reload Bunny Stream tab
92
+ $('#fv_player_bunny_stream_browser_media_tab').click();
93
+ $progressDiv.text( upload_success_message );
94
+ } else {
95
+ $progressDiv.text( "Upload failed with server error: " + ( response && typeof( response ) == 'object' && response.message ? response.message : response ) );
96
+ $progressBarDiv.hide();
97
+ console.log( response );
98
+ }
99
+
100
+ file_upload_xhr = null;
101
+ $uploadButton.add( $cancelButton ).toggle();
102
+ recreate_file_input( file_select_input_name, file_select_input_class );
103
+ });
104
+ }
105
+
106
+ function upload( file ) {
107
+ if ( !file || typeof( file ) == 'undefined' ) {
108
+ return;
109
+ }
110
+
111
+ $uploadButton.add( $cancelButton ).toggle();
112
+ $progressDiv.text('');
113
+
114
+ // create the file info on server and ready it for upload
115
+ $.post( ajaxurl, {
116
+ action: 'fv_player_bunny_stream_submit',
117
+ nonce: fv_player_bunny_stream_upload_settings.job_submit_nonce,
118
+ source: file.name,
119
+ target: file.name,
120
+ no_source_verify: 1,
121
+ ignore_duplicates: 1,
122
+ }).done( function( data ) {
123
+ // check that we have the correct output
124
+ if ( data.result && !data.error && data.result.status != 'error' ) {
125
+ // start the upload process
126
+ ajax_file_upload( file, data.result.result.guid );
127
+ } else {
128
+ $progressDiv.text( "Upload failed with server error: " + (data.error ? data.error : data.result.result.exception ) );
129
+ $progressBarDiv.hide();
130
+ console.log( data.error ? data.error : data.result.result.exception );
131
+ }
132
+ }).fail( function( jqXHR, textStatus, errorThrown ) {
133
+ $progressDiv.text( "Upload failed with server error: " + textStatus );
134
+ $progressBarDiv.hide();
135
+ console.log( jqXHR, textStatus, errorThrown );
136
+ });
137
+
138
+ $progressDiv.text("Preparing upload...");
139
+ }
140
+
141
+ $doc.on("mediaBrowserOpen", function (event) {
142
+ var
143
+ upload_button_text = 'Upload to Bunny Stream',
144
+ cancel_button_class = 'fv-player-bunny_stream-browser-upload-cancel',
145
+ upload_progress_class = 'fv-player-bunny_stream-browser-upload-progress',
146
+ upload_progress_bar_enclosure_class = 'fv-player-bunny_stream-progress',
147
+ upload_progress_bar_class = 'fv-player-bunny_stream-progress-bar',
148
+ upload_progress_bar_number_class = 'fv-player-bunny_stream-progress-number';
149
+
150
+ // add the upload button to the media library modal
151
+ if ( !$('.' + upload_button_class).length ) {
152
+ if ( !$('.media-toolbar-secondary > #' + upload_button_class + '-wrap').length ) {
153
+ $('.media-toolbar-secondary').append('<div id="' + upload_button_class + '-wrap" class="upload_buttons" style="display: none" data-tab-id="fv_player_bunny_stream_browser_media_tab"></div>');
154
+ }
155
+
156
+ var $uploadDiv = $('.media-toolbar-secondary > #' + upload_button_class + '-wrap');
157
+
158
+ var upload_interface = '<div class="fv-player-bunny_stream-upload-buttons fv-player-upload-buttons">'
159
+ upload_interface += '<button type="button" class="button media-button button-primary button-large ' + upload_button_class + '">' + upload_button_text + '</button>';
160
+ upload_interface += '<button type="button" class="button media-button button-primary button-large fv-player-bunny_stream-upload-cancel-btn ' + cancel_button_class + '" style="display: none">Cancel Upload</button>';
161
+ upload_interface += '</div>';
162
+
163
+ upload_interface += '<div class="fv-player-bunny_stream-upload-wrap fv-player-upload-wrap">';
164
+ upload_interface += '<div class="fv-player-bunny_stream-upload-progress ' + upload_progress_class +' fv-player-upload-progress"></div>';
165
+ upload_interface += '<div class="fv-player-bunny_stream-upload-progress-enclosure ' + upload_progress_bar_enclosure_class + ' fv-player-upload-progress-enclosure"><div class="fv-player-bunny_stream-upload-progress-bar ' + upload_progress_bar_class + ' fv-player-upload-progress-bar"></div><div class="fv-player-bunny_stream-upload-progress-number ' + upload_progress_bar_number_class + ' fv-player-upload-progress-number"></div></div>';
166
+ upload_interface += '</div>';
167
+
168
+ $('.media-toolbar-secondary > #' + upload_button_class + '-wrap').append( upload_interface);
169
+
170
+ $uploadButton = $uploadDiv.find('.' + upload_button_class);
171
+ $uploadInput = $uploadDiv.find('.' + file_select_input_class);
172
+ $cancelButton = $uploadDiv.find('.' + cancel_button_class);
173
+ $progressDiv = $uploadDiv.find('.' + upload_progress_class);
174
+ $progressBarDiv = $uploadDiv.find('.' + upload_progress_bar_enclosure_class);
175
+ $progressBar = $uploadDiv.find('.' + upload_progress_bar_class);
176
+ $progressBarNumber = $uploadDiv.find('.' + upload_progress_bar_number_class);
177
+
178
+ $progressBar.css('width',"0px");
179
+ $progressBarNumber.text("");
180
+
181
+ recreate_file_input( file_select_input_name, file_select_input_class );
182
+
183
+ $uploadButton.click(function() {
184
+ $uploadInput.click();
185
+ });
186
+
187
+ $cancelButton.click(function() {
188
+ if ( file_upload_xhr ) {
189
+ file_upload_xhr.abort();
190
+ }
191
+ $uploadButton.add( $cancelButton ).toggle();
192
+ recreate_file_input( file_select_input_name, file_select_input_class );
193
+ $progressDiv.html('Upload cancelled.');
194
+ $progressBarDiv.hide();
195
+ });
196
+
197
+ // listen to the drop event on this browser's files area and the media toolbar
198
+ $doc.on('media_browser_drop_event', function( e, tab_id, files ) {
199
+ // check that we've dropped onto our own browser tab
200
+ if ( tab_id == 'fv_player_bunny_stream_browser_media_tab' ) {
201
+ upload( files[0] );
202
+ }
203
+ });
204
+ }
205
+ });
206
+ });
js/media-library-browser-base.js CHANGED
@@ -370,9 +370,15 @@ function fv_flowplayer_media_browser_disable_drag_drop( disable ) {
370
  var
371
  overlay = jQuery('.media-frame-uploader')
372
  overlay_content = jQuery('.media-modal .uploader-window'),
 
373
  drop_targets = jQuery('[id^=__wp-uploader-id-'),
374
  upload_supported = fv_player_get_active_tab().hasClass( 'upload_supported' );
375
 
 
 
 
 
 
376
  if( disable ) {
377
  drop_targets.off('drop', fv_flowplayer_media_browser_disable_drag_drop_worker );
378
  drop_targets.on('drop', fv_flowplayer_media_browser_disable_drag_drop_worker );
@@ -383,6 +389,8 @@ function fv_flowplayer_media_browser_disable_drag_drop( disable ) {
383
  overlay.css('opacity', 1 );
384
  }
385
 
 
 
386
  } else {
387
  drop_targets.off('drop', fv_flowplayer_media_browser_disable_drag_drop_worker );
388
 
@@ -401,6 +409,8 @@ function fv_flowplayer_media_browser_disable_drag_drop( disable ) {
401
  'opacity' : 1,
402
  });
403
  }
 
 
404
  }
405
  }
406
 
@@ -613,7 +623,9 @@ jQuery( function($) {
613
  .trigger('keyup') // this changes the HLS key field visibility in FV Player Pro
614
  .trigger('change'); // this check the video duration etc.
615
 
616
- if( splash && $url_input.attr('id').match(/^fv_wp_flowplayer_field_src/) ) {
 
 
617
  var splash_input = $url_input.parents('table').find('#fv_wp_flowplayer_field_splash');
618
  if( splash_input.val() == '' ) {
619
  splash_input.val(splash);
@@ -624,6 +636,7 @@ jQuery( function($) {
624
  var hlskey_field = $url_input.closest('table').find('#fv_wp_flowplayer_hlskey');
625
  if( extra && extra.hlskey ) {
626
  hlskey_field.val(extra.hlskey);
 
627
  } else {
628
  hlskey_field.val('');
629
  }
@@ -653,6 +666,14 @@ jQuery( function($) {
653
  audio_checkbox.prop( "checked", false );
654
  }
655
  }
 
 
 
 
 
 
 
 
656
 
657
  $popup_close_btn.click();
658
 
370
  var
371
  overlay = jQuery('.media-frame-uploader')
372
  overlay_content = jQuery('.media-modal .uploader-window'),
373
+ overlay_title = overlay_content.find('.uploader-editor-title'),
374
  drop_targets = jQuery('[id^=__wp-uploader-id-'),
375
  upload_supported = fv_player_get_active_tab().hasClass( 'upload_supported' );
376
 
377
+ var original_title = overlay_title.data('original-overlay-title');
378
+ if( !original_title ) {
379
+ overlay_title.data('original-overlay-title', overlay_title.text() );
380
+ }
381
+
382
  if( disable ) {
383
  drop_targets.off('drop', fv_flowplayer_media_browser_disable_drag_drop_worker );
384
  drop_targets.on('drop', fv_flowplayer_media_browser_disable_drag_drop_worker );
389
  overlay.css('opacity', 1 );
390
  }
391
 
392
+ overlay_title.html( original_title + ' to ' + jQuery('.media-router:visible button.active').text() );
393
+
394
  } else {
395
  drop_targets.off('drop', fv_flowplayer_media_browser_disable_drag_drop_worker );
396
 
409
  'opacity' : 1,
410
  });
411
  }
412
+
413
+ overlay_title.html( original_title );
414
  }
415
  }
416
 
623
  .trigger('keyup') // this changes the HLS key field visibility in FV Player Pro
624
  .trigger('change'); // this check the video duration etc.
625
 
626
+ var are_we_picking_the_video = $url_input.attr('id') && $url_input.attr('id').match(/^fv_wp_flowplayer_field_src/);
627
+
628
+ if( splash && are_we_picking_the_video ) {
629
  var splash_input = $url_input.parents('table').find('#fv_wp_flowplayer_field_splash');
630
  if( splash_input.val() == '' ) {
631
  splash_input.val(splash);
636
  var hlskey_field = $url_input.closest('table').find('#fv_wp_flowplayer_hlskey');
637
  if( extra && extra.hlskey ) {
638
  hlskey_field.val(extra.hlskey);
639
+ hlskey_field.closest('tr').show();
640
  } else {
641
  hlskey_field.val('');
642
  }
666
  audio_checkbox.prop( "checked", false );
667
  }
668
  }
669
+
670
+ if( extra && extra.title ) {
671
+ var title_input = $url_input.parents('table').find('#fv_wp_flowplayer_field_caption');
672
+ if( title_input.val() == '' ) {
673
+ title_input.val(extra.title);
674
+ title_input.closest('tr').show();
675
+ }
676
+ }
677
 
678
  $popup_close_btn.click();
679
 
js/shortcode-editor.js CHANGED
@@ -26,6 +26,9 @@ jQuery(function() {
26
  // data to save in Ajax
27
  ajax_save_this_please = false,
28
 
 
 
 
29
  current_player_db_id = -1,
30
  current_video_to_edit = -1,
31
 
@@ -203,7 +206,6 @@ jQuery(function() {
203
  el_preview_target = $('#fv-player-shortcode-editor-preview-target');
204
 
205
  var
206
- previous = false,
207
  next = false,
208
  overlay_close_waiting_for_save = false,
209
  loading = true,
@@ -282,7 +284,7 @@ jQuery(function() {
282
  overlay.find('textarea').val( $('<div/>').text(json_export_data).html() );
283
 
284
  jQuery('[name=fv_player_copy_to_clipboard]').select();
285
- }).error(function() {
286
  overlay_show('message', 'An unexpected error has occurred. Please try again.');
287
  });
288
 
@@ -360,7 +362,7 @@ jQuery(function() {
360
 
361
  $element_td.find('span, a:not(.fv-player-remove-confirm)').show();
362
  }
363
- }).error(function() {
364
  $spinner.remove();
365
 
366
  $element.html('Error');
@@ -394,7 +396,7 @@ jQuery(function() {
394
  $('#the-list tr:first').before(jQuery(response).find('#the-list tr:first'));
395
  $spinner.remove();
396
  $element.show();
397
- }).error(function() {
398
  $spinner.remove();
399
  $element.show();
400
  });
@@ -402,7 +404,7 @@ jQuery(function() {
402
  $spinner.remove();
403
  $element.html('Error');
404
  }
405
- }).error(function() {
406
  $spinner
407
  $element.html('Error');
408
  });
@@ -414,7 +416,7 @@ jQuery(function() {
414
  /*
415
  * NAV TABS
416
  */
417
- $('.fv-player-tabs-header a').click( function(e) {
418
  e.preventDefault();
419
  $('.fv-player-tabs-header a').removeClass('nav-tab-active');
420
  $(this).addClass('nav-tab-active')
@@ -447,7 +449,7 @@ jQuery(function() {
447
  * Playlist view thumbnail toggle
448
  */
449
  var list_style_toggles = $('#fv-player-list-thumb-toggle > a');
450
- list_style_toggles.click(function(){
451
  var button = $(this);
452
  if( button.hasClass('disabled') ) return;
453
 
@@ -643,24 +645,8 @@ jQuery(function() {
643
  * End of playlist Actions
644
  */
645
 
646
- jQuery('#fv_wp_flowplayer_field_end_actions').change(function(){
647
- var value = jQuery(this).val();
648
- jQuery('.fv_player_actions_end-toggle').hide().find('[name]').val('');
649
- switch(value){
650
- case 'redirect':
651
- jQuery('#fv_wp_flowplayer_field_' + value).parents('tr').show();
652
- break;
653
- case 'popup':
654
- jQuery('#fv_wp_flowplayer_field_' + value).parents('tr').show();
655
- jQuery('#fv_wp_flowplayer_field_' + value + '_id').parents('tr').show();
656
- break;
657
- case 'email_list':
658
- jQuery('#fv_wp_flowplayer_field_' + value).parents('tr').show();
659
- break;
660
- default:
661
- break;
662
- }
663
- });
664
 
665
  /*
666
  * Preview iframe dialog resize
@@ -675,7 +661,7 @@ jQuery(function() {
675
  */
676
 
677
  // TODO: Check
678
- jQuery('#fv_wp_flowplayer_field_share').change(function(){
679
  var value = jQuery(this).val();
680
 
681
  switch(value){
@@ -755,18 +741,18 @@ jQuery(function() {
755
  return;
756
  }
757
 
758
- if( previous && JSON.stringify(ajax_data) == JSON.stringify(previous) ) {
759
- console.log('Not really!');
760
  return;
761
  }
762
 
763
  if( is_saving ) {
764
- console.log('Still saving!');
765
  next = ajax_data;
766
  return;
767
  }
768
 
769
- previous = ajax_data;
770
 
771
  ajax(ajax_data);
772
 
@@ -827,7 +813,9 @@ jQuery(function() {
827
  }
828
  });
829
 
830
- if( next ) {console.log('There is more to do...');
 
 
831
  ajax(next);
832
  next = false;
833
  } else {
@@ -870,7 +858,7 @@ jQuery(function() {
870
  error(e);
871
  }
872
 
873
- }, 'json' ).error( function() {
874
  $('.fv-player-save-error').show();
875
 
876
  el_spinner.hide();
@@ -1151,13 +1139,31 @@ jQuery(function() {
1151
  }
1152
  }
1153
  }
1154
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1155
  $element.removeData('fv_player_video_data_ajax');
1156
  $element.removeData('fv_player_video_data_ajax_retry_count');
1157
 
1158
  // remove spinners
1159
  $('.fv-player-shortcode-editor-small-spinner').remove();
1160
- }).error(function () {
1161
  fv_player_editor.meta_data_load_finished();
1162
  // remove element AJAX data
1163
  $element.removeData('fv_player_video_data_ajax');
@@ -1403,7 +1409,7 @@ jQuery(function() {
1403
 
1404
  overlay.find('select').html( dropdown.join('') );
1405
 
1406
- }).error(function () {
1407
  overlay_show('message', 'An unexpected error has occurred. Please try again.');
1408
 
1409
  });
@@ -1448,6 +1454,9 @@ jQuery(function() {
1448
  clearInterval(refreshTask);
1449
  $this.removeData('fv_player_video_auto_refresh_task');
1450
  }*/
 
 
 
1451
  });
1452
 
1453
  jQuery('#fv_wp_flowplayer_field_player_name').show();
@@ -2171,24 +2180,7 @@ jQuery(function() {
2171
 
2172
  // special processing for end video actions
2173
  if (real_key == 'fv_wp_flowplayer_field_end_action_value') {
2174
- var end_of_playlist_action = jQuery('#fv_wp_flowplayer_field_end_actions').val();
2175
-
2176
- // to actually show the value, we need to trigger a change event on the end_actions dropdown itself
2177
- jQuery('#fv_wp_flowplayer_field_end_actions').trigger('change');
2178
-
2179
- switch (end_of_playlist_action) {
2180
- case 'redirect':
2181
- jQuery('#fv_wp_flowplayer_field_redirect').val(value);
2182
- break;
2183
- case 'popup':
2184
- jQuery('#fv_wp_flowplayer_field_popup_id').val(value);
2185
- break;
2186
-
2187
- case 'email_list':
2188
- jQuery('#fv_wp_flowplayer_field_email_list').val(value);
2189
- break;
2190
- }
2191
-
2192
  return;
2193
  } else if (['fv_wp_flowplayer_field_email_list', 'fv_wp_flowplayer_field_popup_id', 'fv_wp_flowplayer_field_redirect'].indexOf(real_key) > -1) {
2194
  // ignore the original fields, if we still use old DB values
@@ -2217,9 +2209,9 @@ jQuery(function() {
2217
  }
2218
  } else if ($element.get(0).nodeName == 'INPUT' && $element.get(0).type.toLowerCase() == 'checkbox') {
2219
  if (real_val === '1' || real_val === 'on' || real_val === 'true') {
2220
- $element.attr('checked', 'checked');
2221
  } else {
2222
- $element.removeAttr('checked');
2223
  }
2224
  } else {
2225
  $element.val(real_val);
@@ -2330,6 +2322,9 @@ jQuery(function() {
2330
 
2331
  // if this player is published, mark it as such
2332
  has_draft_status = ( response.status == 'draft' );
 
 
 
2333
  }
2334
 
2335
  overlay_hide();
@@ -2373,7 +2368,7 @@ jQuery(function() {
2373
 
2374
  $doc.trigger('fv_player_editor_finished');
2375
  $('#fv_wp_flowplayer_field_src').trigger('keyup'); // to ensure we show/hide all relevent notices
2376
- }).error(function(xhr) {
2377
  if (xhr.status == 404) {
2378
  overlay_show('message', 'The requested player could not be found. Please try again.');
2379
  } else {
@@ -2656,6 +2651,7 @@ jQuery(function() {
2656
  if (slive != null && slive[1] != null && slive[1] == 'true') {
2657
  jQuery("input[name=fv_wp_flowplayer_field_live]").each(function () {
2658
  this.checked = 1;
 
2659
  });
2660
  }
2661
 
@@ -2890,7 +2886,7 @@ jQuery(function() {
2890
 
2891
  jQuery('#fv_player_copy_to_clipboard').select();
2892
  }
2893
- }).error(function() {
2894
  overlay_show('message', 'An unexpected error has occurred. Please try again');
2895
  });
2896
 
@@ -2901,9 +2897,9 @@ jQuery(function() {
2901
  function insert_button_toggle_disabled( disable ) {
2902
  var button = $('.fv_player_field_insert-button');
2903
  if( disable ) {
2904
- button.attr('disabled', 'disabled');
2905
  } else {
2906
- button.removeAttr('disabled');
2907
  }
2908
  }
2909
 
@@ -3468,11 +3464,12 @@ jQuery(function() {
3468
  /*
3469
  Click on Loading Overlay Close button
3470
  */
3471
- $doc.on('click', '#fv-player-editor-overlay-close', function() {
3472
  $.fn.fv_player_box.close();
3473
  // hide the overlay asynchronously to allow the actual modal close animation to finish,
3474
  // so it doesn't blink from error message to an empty editor and only then starts to fade
3475
  setTimeout(overlay_hide, 1000);
 
3476
  });
3477
 
3478
  /*
@@ -3515,7 +3512,7 @@ jQuery(function() {
3515
  function (response) {
3516
  jQuery('#the-list tr:first').before(jQuery(response).find('#the-list tr:first'));
3517
  jQuery('.fv-wordpress-flowplayer-button').fv_player_box.close();
3518
- }).error(function() {
3519
  jQuery('.fv-wordpress-flowplayer-button').fv_player_box.close();
3520
  });
3521
 
@@ -3523,7 +3520,7 @@ jQuery(function() {
3523
  fv_player_editor.overlay_notice( button, response, 'error' );
3524
 
3525
  }
3526
- }).error(function() {
3527
  fv_player_editor.overlay_notice( button, 'Unknown error!', 'error' );
3528
 
3529
  });
@@ -3567,15 +3564,62 @@ jQuery(function() {
3567
  // on fv_flowplayer_shortcode_new
3568
  if( item.length == 0 ) item = jQuery('.fv-player-playlist-item[data-index=0]');
3569
 
3570
- var is_stream = item.find('[name=fv_wp_flowplayer_field_rtmp_path]').val() || src.match(/m3u8/) || src.match(/rtmp:/) || src.match(/\.mpd/),
3571
- is_vimeo_or_youtube = fv_player_editor_conf.have_fv_player_vimeo_live && src.match(/vimeo\.com\//) || src.match(/youtube\.com\//);
 
3572
 
3573
- item.find('[name=fv_wp_flowplayer_field_live]').closest('tr').toggle(!!is_stream || !!is_vimeo_or_youtube);
3574
- item.find('[name=fv_wp_flowplayer_field_audio]').closest('tr').toggle(!!is_stream);
3575
- item.find('[name=fv_wp_flowplayer_field_dvr]').closest('tr').toggle(!!is_stream);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3576
 
3577
  editor_resize();
3578
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3579
 
3580
  function init_saved_player_fields( id_player ) {
3581
  var
@@ -3757,7 +3801,7 @@ jQuery(function() {
3757
  },
3758
 
3759
  playlist_buttons_toggle: function( show ) {
3760
- $('.playlist_add, .playlist_edit').toggle( show );
3761
  },
3762
 
3763
  insert_button_toggle: function( show ) {
@@ -3929,7 +3973,7 @@ function fv_wp_flowplayer_check_for_video_meta_field(fieldName) {
3929
  }
3930
 
3931
 
3932
- jQuery(document).on('click', '#fv-player-editor-export-overlay-copy', function() {
3933
  var button = this;
3934
  fv_player_clipboard(jQuery('[name=fv_player_copy_to_clipboard]').val(), function() {
3935
  fv_player_editor.overlay_notice( button, 'Text Copied To Clipboard!', 'success', 3000 );
26
  // data to save in Ajax
27
  ajax_save_this_please = false,
28
 
29
+ // last saved data to detect changes for auto-saving
30
+ ajax_save_previous = false,
31
+
32
  current_player_db_id = -1,
33
  current_video_to_edit = -1,
34
 
206
  el_preview_target = $('#fv-player-shortcode-editor-preview-target');
207
 
208
  var
 
209
  next = false,
210
  overlay_close_waiting_for_save = false,
211
  loading = true,
284
  overlay.find('textarea').val( $('<div/>').text(json_export_data).html() );
285
 
286
  jQuery('[name=fv_player_copy_to_clipboard]').select();
287
+ }).fail(function() {
288
  overlay_show('message', 'An unexpected error has occurred. Please try again.');
289
  });
290
 
362
 
363
  $element_td.find('span, a:not(.fv-player-remove-confirm)').show();
364
  }
365
+ }).fail(function() {
366
  $spinner.remove();
367
 
368
  $element.html('Error');
396
  $('#the-list tr:first').before(jQuery(response).find('#the-list tr:first'));
397
  $spinner.remove();
398
  $element.show();
399
+ }).fail(function() {
400
  $spinner.remove();
401
  $element.show();
402
  });
404
  $spinner.remove();
405
  $element.html('Error');
406
  }
407
+ }).fail(function() {
408
  $spinner
409
  $element.html('Error');
410
  });
416
  /*
417
  * NAV TABS
418
  */
419
+ $('.fv-player-tabs-header a').on( 'click', function(e) {
420
  e.preventDefault();
421
  $('.fv-player-tabs-header a').removeClass('nav-tab-active');
422
  $(this).addClass('nav-tab-active')
449
  * Playlist view thumbnail toggle
450
  */
451
  var list_style_toggles = $('#fv-player-list-thumb-toggle > a');
452
+ list_style_toggles.on( 'click', function(){
453
  var button = $(this);
454
  if( button.hasClass('disabled') ) return;
455
 
645
  * End of playlist Actions
646
  */
647
 
648
+ jQuery('#fv_wp_flowplayer_field_end_actions').on( 'change', show_end_actions );
649
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
650
 
651
  /*
652
  * Preview iframe dialog resize
661
  */
662
 
663
  // TODO: Check
664
+ jQuery('#fv_wp_flowplayer_field_share').on( 'change', function(){
665
  var value = jQuery(this).val();
666
 
667
  switch(value){
741
  return;
742
  }
743
 
744
+ if( ajax_save_previous && JSON.stringify(ajax_data) == JSON.stringify(ajax_save_previous) ) {
745
+ debug_log('No changes to save.');
746
  return;
747
  }
748
 
749
  if( is_saving ) {
750
+ debug_log('Still saving!');
751
  next = ajax_data;
752
  return;
753
  }
754
 
755
+ ajax_save_previous = ajax_data;
756
 
757
  ajax(ajax_data);
758
 
813
  }
814
  });
815
 
816
+ if( next ) {
817
+ debug_log('There is more to save...');
818
+
819
  ajax(next);
820
  next = false;
821
  } else {
858
  error(e);
859
  }
860
 
861
+ }, 'json' ).fail( function() {
862
  $('.fv-player-save-error').show();
863
 
864
  el_spinner.hide();
1139
  }
1140
  }
1141
  }
1142
+
1143
+ var item = jQuery($element).parents('table'),
1144
+ show = [],
1145
+ check = [];
1146
+
1147
+ if( !!json_data.is_live ) {
1148
+ show = [ 'dvr', 'live' ];
1149
+ check = [ 'live' ];
1150
+ }
1151
+
1152
+ if( json_data.is_audio == -1 ) {
1153
+ show.push('audio');
1154
+ } else if( !!json_data.is_audio ) {
1155
+ show.push('audio');
1156
+ check.push('audio');
1157
+ }
1158
+
1159
+ show_stream_fields_worker( item, show, check );
1160
+
1161
  $element.removeData('fv_player_video_data_ajax');
1162
  $element.removeData('fv_player_video_data_ajax_retry_count');
1163
 
1164
  // remove spinners
1165
  $('.fv-player-shortcode-editor-small-spinner').remove();
1166
+ }).fail(function () {
1167
  fv_player_editor.meta_data_load_finished();
1168
  // remove element AJAX data
1169
  $element.removeData('fv_player_video_data_ajax');
1409
 
1410
  overlay.find('select').html( dropdown.join('') );
1411
 
1412
+ }).fail(function () {
1413
  overlay_show('message', 'An unexpected error has occurred. Please try again.');
1414
 
1415
  });
1454
  clearInterval(refreshTask);
1455
  $this.removeData('fv_player_video_auto_refresh_task');
1456
  }*/
1457
+
1458
+ // Reset the HLS stream checkboxes (Live, DVR, ...)
1459
+ show_stream_fields_worker( $this, [], [] );
1460
  });
1461
 
1462
  jQuery('#fv_wp_flowplayer_field_player_name').show();
2180
 
2181
  // special processing for end video actions
2182
  if (real_key == 'fv_wp_flowplayer_field_end_action_value') {
2183
+ show_end_actions( false, value );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2184
  return;
2185
  } else if (['fv_wp_flowplayer_field_email_list', 'fv_wp_flowplayer_field_popup_id', 'fv_wp_flowplayer_field_redirect'].indexOf(real_key) > -1) {
2186
  // ignore the original fields, if we still use old DB values
2209
  }
2210
  } else if ($element.get(0).nodeName == 'INPUT' && $element.get(0).type.toLowerCase() == 'checkbox') {
2211
  if (real_val === '1' || real_val === 'on' || real_val === 'true') {
2212
+ $element.prop('checked',true);
2213
  } else {
2214
+ $element.prop('checked',false);
2215
  }
2216
  } else {
2217
  $element.val(real_val);
2322
 
2323
  // if this player is published, mark it as such
2324
  has_draft_status = ( response.status == 'draft' );
2325
+
2326
+ // Set the current data as previous to let auto-saving detect changes
2327
+ ajax_save_previous = build_ajax_data(true);
2328
  }
2329
 
2330
  overlay_hide();
2368
 
2369
  $doc.trigger('fv_player_editor_finished');
2370
  $('#fv_wp_flowplayer_field_src').trigger('keyup'); // to ensure we show/hide all relevent notices
2371
+ }).fail(function(xhr) {
2372
  if (xhr.status == 404) {
2373
  overlay_show('message', 'The requested player could not be found. Please try again.');
2374
  } else {
2651
  if (slive != null && slive[1] != null && slive[1] == 'true') {
2652
  jQuery("input[name=fv_wp_flowplayer_field_live]").each(function () {
2653
  this.checked = 1;
2654
+ jQuery(this).closest('tr').show();
2655
  });
2656
  }
2657
 
2886
 
2887
  jQuery('#fv_player_copy_to_clipboard').select();
2888
  }
2889
+ }).fail(function() {
2890
  overlay_show('message', 'An unexpected error has occurred. Please try again');
2891
  });
2892
 
2897
  function insert_button_toggle_disabled( disable ) {
2898
  var button = $('.fv_player_field_insert-button');
2899
  if( disable ) {
2900
+ button.prop('disabled', true);
2901
  } else {
2902
+ button.prop('disabled', false);
2903
  }
2904
  }
2905
 
3464
  /*
3465
  Click on Loading Overlay Close button
3466
  */
3467
+ $doc.on('click', '[data-fv-player-editor-overlay-close]', function() {
3468
  $.fn.fv_player_box.close();
3469
  // hide the overlay asynchronously to allow the actual modal close animation to finish,
3470
  // so it doesn't blink from error message to an empty editor and only then starts to fade
3471
  setTimeout(overlay_hide, 1000);
3472
+ return false;
3473
  });
3474
 
3475
  /*
3512
  function (response) {
3513
  jQuery('#the-list tr:first').before(jQuery(response).find('#the-list tr:first'));
3514
  jQuery('.fv-wordpress-flowplayer-button').fv_player_box.close();
3515
+ }).fail(function() {
3516
  jQuery('.fv-wordpress-flowplayer-button').fv_player_box.close();
3517
  });
3518
 
3520
  fv_player_editor.overlay_notice( button, response, 'error' );
3521
 
3522
  }
3523
+ }).fail(function() {
3524
  fv_player_editor.overlay_notice( button, 'Unknown error!', 'error' );
3525
 
3526
  });
3564
  // on fv_flowplayer_shortcode_new
3565
  if( item.length == 0 ) item = jQuery('.fv-player-playlist-item[data-index=0]');
3566
 
3567
+ // TODO: Gradually get rid of this and detect each stream type instead
3568
+ var is_stream = item.find('[name=fv_wp_flowplayer_field_rtmp_path]').val() || src.match(/rtmp:/) || src.match(/\.mpd/),
3569
+ is_vimeo_live = fv_player_editor_conf.have_fv_player_vimeo_live && src.match(/vimeo\.com\//);
3570
 
3571
+ var show = [];
3572
+ if( !!is_stream ) show = [ 'audio', 'dvr', 'live' ];
3573
+ if( !!is_vimeo_live ) show = [ 'live' ];
3574
+
3575
+ show_stream_fields_worker( item, show );
3576
+
3577
+ editor_resize();
3578
+ }
3579
+
3580
+ function show_stream_fields_worker(item, to_show, to_check) {
3581
+ jQuery.each( [ 'live', 'audio', 'dvr' ], function(k,v) {
3582
+ var field = item.find('[name=fv_wp_flowplayer_field_'+v+']'),
3583
+ is_checked = field.prop('checked');
3584
+
3585
+ // We show the checkbox if it's to be shown or if it's checked
3586
+ field.closest('tr').toggle( is_checked || to_show && to_show.indexOf(v) != -1 );
3587
+
3588
+ // If it's not already checked we check it or not check it based on args
3589
+ if( !is_checked ) {
3590
+ field.prop( 'checked', to_check && to_check.indexOf(v) != -1 );
3591
+ }
3592
+ });
3593
+
3594
+ // DVR should be always shown for live streams
3595
+ if( item.find('[name=fv_wp_flowplayer_field_live]').prop('checked') ) {
3596
+ item.find('[name=fv_wp_flowplayer_field_dvr]').closest('tr').show();
3597
+ }
3598
 
3599
  editor_resize();
3600
  }
3601
+
3602
+ function show_end_actions( e, value ) {
3603
+ // redirect, popup and email_list
3604
+ var type = jQuery('#fv_wp_flowplayer_field_end_actions').val();
3605
+
3606
+ jQuery('.fv_player_actions_end-toggle').hide().find('[name]').val('');
3607
+
3608
+ var field = jQuery('#fv_wp_flowplayer_field_' + type);
3609
+ field.parents('tr').show();
3610
+ if( value ) {
3611
+ field.val(value);
3612
+ }
3613
+
3614
+ // The field id is different for popup
3615
+ if( type == 'popup' ){
3616
+ var field = jQuery('#fv_wp_flowplayer_field_' + type + '_id');
3617
+ field.parents('tr').show();
3618
+ if( value ) {
3619
+ field.val(value);
3620
+ }
3621
+ }
3622
+ }
3623
 
3624
  function init_saved_player_fields( id_player ) {
3625
  var
3801
  },
3802
 
3803
  playlist_buttons_toggle: function( show ) {
3804
+ $('.playlist_add, .playlist_edit').css( 'display', show ? 'inline-block' : 'none' );
3805
  },
3806
 
3807
  insert_button_toggle: function( show ) {
3973
  }
3974
 
3975
 
3976
+ jQuery(document).on('click', '[data-fv-player-editor-export-overlay-copy]', function() {
3977
  var button = this;
3978
  fv_player_clipboard(jQuery('[name=fv_player_copy_to_clipboard]').val(), function() {
3979
  fv_player_editor.overlay_notice( button, 'Text Copied To Clipboard!', 'success', 3000 );
models/bunny-stream-wizard/images/bunnycdn-api-2x.png ADDED
Binary file
models/bunny-stream-wizard/images/bunnycdn-api.png ADDED
Binary file
models/bunny-stream-wizard/images/logo.png ADDED
Binary file
models/bunny-stream-wizard/images/pricing-2x.png ADDED
Binary file
models/bunny-stream-wizard/images/pricing.png ADDED
Binary file
models/bunny-stream-wizard/step_0_introduction.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class FV_Player_Bunny_Stream_Introduction extends FV_Player_Wizard_Step_Base_Class {
4
+
5
+ // prevent the standard buttons from showing
6
+ var $buttons = array(
7
+ 'next' => array(
8
+ 'value' => 'Start',
9
+ 'primary' => true
10
+ )
11
+ );
12
+
13
+ function display() {
14
+ ?>
15
+ <tr>
16
+ <td colspan="2">
17
+ <h2>Welcome</h2>
18
+ <p><a href="https://bunny.net/stream/?ref=rsfonj1su1" target="_blank">Bunny Stream</a> offers great encoding and hosting for your videos.</p>
19
+ <p>With free video encoding, storage from $0.01/GB/month and CDN from $0.005/GB/month, their prices don’t even have a competitor that would fall in the same price bracket.</p>
20
+ <p><img src="<?php echo plugins_url( 'images/pricing.png', __FILE__ ); ?>" srcset="<?php echo plugins_url( 'images/pricing.png', __FILE__ ); ?> 1x, <?php echo plugins_url( 'images/pricing-2x.png', __FILE__ ); ?> 2x" /></p>
21
+ <p>Detailed comparison can be found in our <a href="https://foliovision.com/2021/09/video-encoding-prices-cost" target="_blank">The True Cost Of A Video Encoding Workflow</a> article.</p>
22
+ <p>If you do not have a Bunny.net account, please <a href="https://bunny.net/stream/?ref=rsfonj1su1" target="_blank">sign up for it here</a>.</p>
23
+ </td>
24
+ </tr>
25
+ <?php
26
+ }
27
+
28
+ }
29
+
30
+ $this->register_step('FV_Player_Bunny_Stream_Introduction');
models/bunny-stream-wizard/step_1_api_key.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class FV_Player_Bunny_Stream_Wizard_API_Key extends FV_Player_Wizard_Step_Base_Class {
4
+
5
+ protected
6
+ $key = 'bunnycdn_api',
7
+ $name = 'Bunny.net API Key',
8
+
9
+ $buttons = array(
10
+ 'next' => array(
11
+ 'value' => 'Check API key',
12
+ )
13
+ );
14
+
15
+ public function __construct() {
16
+ require_once( dirname(__FILE__).'/../class.fv-player-bunny_stream-api.php' );
17
+ }
18
+
19
+ function display() {
20
+ ?>
21
+ <tr>
22
+ <td colspan="2">
23
+ <h2>Bunny.net API key</h2>
24
+ <p>We need your Bunny.net API key to connect to your Stream Library.<br />Please open <a href="https://panel.bunny.net/dashboard/account" target="_blank">panel.bunny.net/dashboard/account</a> to get your API key.</p>
25
+ <p>(Note: we do not store this token, it's only used during this Wizard session).</p>
26
+ <p><img src="<?php echo plugins_url( 'images/bunnycdn-api.png', __FILE__ ); ?>" srcset="<?php echo plugins_url( 'images/bunnycdn-api.png', __FILE__ ); ?> 1x, <?php echo plugins_url( 'images/bunnycdn-api-2x.png', __FILE__ ); ?> 2x" /></p>
27
+ </td>
28
+ </tr>
29
+ <?php
30
+ parent::display();
31
+ }
32
+
33
+ function process() {
34
+ $api_key = trim( $_POST[ $this->key ] );
35
+ $api = new FV_Player_Bunny_Stream_API( $api_key );
36
+
37
+ // test the API key by listing Stream Libraries
38
+ $result = $api->api_call( 'https://api.bunny.net/videolibrary?page=1&perPage=1' );
39
+ if ( is_wp_error( $result ) ) {
40
+ return array('error' => $result->get_error_message() );
41
+ }
42
+
43
+ $bunny_stream_library_picker = new FV_Player_Bunny_Stream_Wizard_Stream_Libs();
44
+
45
+ ob_start();
46
+ $bunny_stream_library_picker->display();
47
+ $bunny_stream_library_picker->buttons();
48
+
49
+ return array(
50
+ 'next_step' => ob_get_clean(),
51
+ 'ok' => true
52
+ );
53
+ }
54
+
55
+ function should_show() {
56
+ return !FV_Player_Bunny_Stream()->is_configured();
57
+ }
58
+
59
+ }
60
+
61
+ $this->register_step('FV_Player_Bunny_Stream_Wizard_API_Key');
models/bunny-stream-wizard/step_2_stream_libs.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class FV_Player_Bunny_Stream_Wizard_Stream_Libs extends FV_Player_Wizard_Step_Base_Class {
4
+
5
+ protected
6
+ $buttons_across_2_columns = true,
7
+
8
+ $buttons = array(
9
+ 'next' => array(
10
+ 'value' => 'Save and Continue',
11
+ )
12
+ );
13
+
14
+ public function __construct() {
15
+ require_once( dirname(__FILE__).'/../class.fv-player-bunny_stream-api.php' );
16
+ }
17
+
18
+ function display() {
19
+ ?>
20
+ <tr>
21
+ <td colspan="2">
22
+ <h2>Bunny Stream Library</h2>
23
+ <p>Pick an existing library to upload videos to or create a new one:</p>
24
+ </td>
25
+ </tr>
26
+ <tr>
27
+ <td colspan="2">
28
+ <input type="hidden" name="bunnycdn_api" value="<?php echo esc_attr($_POST['bunnycdn_api']); ?>" />
29
+ <select name="fv_bunny_stream_wizard_lib" id="fv_bunny_stream_wizard_lib">
30
+ <option value="-1" disabled selected hidden>Pick a Library...</option>
31
+ <option value="-2">- Create a new Stream Library -</option>
32
+ <?php
33
+ // retrieve a list of existing Stream Libraries
34
+ if ( !empty($_POST['bunnycdn_api']) ) {
35
+ $api = new FV_Player_Bunny_Stream_API( $_POST['bunnycdn_api'] );
36
+ $libs = $api->api_call( 'https://api.bunny.net/videolibrary?page=1&perPage=1000' );
37
+ if ( $libs->Items && count( $libs->Items ) ) {
38
+ foreach ( $libs->Items as $lib ) {
39
+ ?>
40
+ <option value="<?php echo $lib->Id; ?>"><?php echo $lib->Name; ?></option>
41
+ <?php
42
+ }
43
+ }
44
+ }
45
+ ?>
46
+ </select>
47
+ <script>
48
+ (function ($) {
49
+ $( '#fv_bunny_stream_wizard_lib' ).on( 'change', function() {
50
+ var self = this;
51
+
52
+ // show the library rows, hide the select dropdown
53
+ if ( this.value == '-2' ) {
54
+ $( '.bunny_stream_wizard_hidden' ).css( 'display', 'block' );
55
+ $( self ).hide();
56
+
57
+ // add a "Cancel" button next to a save button, so we can go back to picking an existing library
58
+ var $cancelBtn = $('#bunny_stream_wizard_cancel');
59
+ if ( !$cancelBtn.length ) {
60
+ $( 'input[data-fv-player-wizard-next]' ).after( $( '<a id="bunny_stream_wizard_cancel" href="#" style="margin-left: 10px">Cancel</a>' ).on( 'click', function() {
61
+ $( '.bunny_stream_wizard_hidden' ).css( 'display', 'none' );
62
+ $( self ).show()[0].selectedIndex = 0;
63
+ $( this ).hide();
64
+
65
+ return false;
66
+ }) );
67
+ } else {
68
+ $cancelBtn.show();
69
+ }
70
+ }
71
+ } );
72
+ }(jQuery));
73
+ </script>
74
+ </td>
75
+ </tr>
76
+
77
+ <tr class="bunny_stream_wizard_hidden hidden">
78
+ <td><label for="bunny_stream_wizard[name]">New Stream Library Name:</label></td>
79
+ <td>
80
+ <input class="regular-text code" id="bunny_stream_wizard[name]" name="bunny_stream_wizard[name]" data-optional="1" type="text" value="" />
81
+ </td>
82
+ </tr>
83
+ <?php
84
+ }
85
+
86
+ function process() {
87
+ global $fv_fp;
88
+
89
+ // library not picked neither created
90
+ if ( !empty( $_POST['fv_bunny_stream_wizard_lib'] ) && $_POST['fv_bunny_stream_wizard_lib'] == '-1' ) {
91
+ return array('error' => 'No action selected. Please pick a library or create a new one.' );
92
+ }
93
+
94
+ // data missing
95
+ if (
96
+ empty( $_POST['fv_bunny_stream_wizard_lib'] )
97
+ ||
98
+ (
99
+ $_POST['fv_bunny_stream_wizard_lib'] == '-2' &&
100
+ ( empty( $_POST['bunny_stream_wizard'] ) || empty( $_POST['bunny_stream_wizard']['name'] ) )
101
+ )
102
+ ) {
103
+ return array('error' => 'Some required wizard data are missing. Please make sure you provided all information for this page.' );
104
+ }
105
+
106
+ // create new API instance
107
+ $api = new FV_Player_Bunny_Stream_API( $_POST['bunnycdn_api'] );
108
+
109
+ if ( $_POST['fv_bunny_stream_wizard_lib'] == '-2' ) {
110
+ // create the stream library
111
+ $lib = $api->api_call( 'https://api.bunny.net/videolibrary', array( 'Id' => 1, 'Name' => trim( $_POST['bunny_stream_wizard']['name'] ) ), 'POST' );
112
+
113
+ if ( is_wp_error($lib) ) {
114
+ return array('error' => $lib->get_error_message() );
115
+ }
116
+
117
+ // load the Pull Zone and get its CDN URL, so we can display thumbnails in the Bunny Stream browser
118
+ $pull_zone = $api->api_call( 'https://api.bunny.net/pullzone/' . $lib->PullZoneId );
119
+
120
+ if ( is_wp_error($pull_zone) ) {
121
+ return array('error' => $pull_zone->get_error_message() );
122
+ }
123
+ } else {
124
+ // get existing library data
125
+ $lib = $api->api_call( 'https://api.bunny.net/videolibrary/' . $_POST['fv_bunny_stream_wizard_lib'] );
126
+
127
+ if ( is_wp_error($lib) ) {
128
+ return array('error' => $lib->get_error_message() );
129
+ }
130
+
131
+ // load the Pull Zone and get its CDN URL, so we can display thumbnails in the Bunny Stream browser
132
+ $pull_zone = $api->api_call( 'https://api.bunny.net/pullzone/' . $lib->PullZoneId );
133
+
134
+ if ( is_wp_error($pull_zone) ) {
135
+ return array('error' => $pull_zone->get_error_message() );
136
+ }
137
+ }
138
+
139
+ // store the library info in config
140
+ $fv_fp->conf['bunny_stream']['api_key'] = $lib->ApiKey;
141
+ $fv_fp->conf['bunny_stream']['lib_id'] = $lib->Id;
142
+ $fv_fp->conf['bunny_stream']['cdn_hostname'] = $pull_zone->Hostnames[0]->Value;
143
+ $fv_fp->_set_conf( $fv_fp->conf );
144
+
145
+ return array( 'ok' => true );
146
+ }
147
+
148
+ }
149
+
150
+ $this->register_step('FV_Player_Bunny_Stream_Wizard_Stream_Libs');
models/bunny-stream-wizard/step_finish.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class FV_Player_Bunny_Stream_Wizard_step_finish extends FV_Player_Wizard_Step_Base_Class {
4
+
5
+ protected $buttons = array();
6
+
7
+ function display() {
8
+ ?>
9
+ <tr>
10
+ <td colspan="2">
11
+ <h2>Finished</h2>
12
+ <p>Congratulations, you just finished your FV Player Bunny Stream setup!</p>
13
+ <p><a href="<?php echo admin_url('admin.php?page=fv_player'); ?>" class="button button-primary">Upload your first video</a></p>
14
+ </td>
15
+ </tr>
16
+ <?php
17
+ }
18
+
19
+ }
20
+
21
+ $this->register_step('FV_Player_Bunny_Stream_Wizard_step_finish');
models/checker.php CHANGED
@@ -192,8 +192,11 @@ class FV_Player_Checker {
192
  if( isset($ThisFileInfo) && isset($ThisFileInfo['playtime_seconds']) ) {
193
  $time = $ThisFileInfo['playtime_seconds'];
194
  }
195
-
 
 
196
  if(preg_match('/.m3u8(\?.*)?$/i', $remotefilename_encoded)){
 
197
 
198
  remove_action( 'http_api_curl', array( 'FV_Player_Checker', 'http_api_curl' ) );
199
  $remotefilename_encoded = apply_filters( 'fv_flowplayer_video_src', $remotefilename_encoded , array('dynamic'=>true) );
@@ -202,7 +205,9 @@ class FV_Player_Checker {
202
  $playlist = false;
203
  $duration = 0;
204
  $segments = false;
205
-
 
 
206
  if(preg_match_all('/^#EXTINF:([0-9]+\.?[0-9]*)/im', $response,$segments)){
207
  foreach($segments[1] as $segment_item){
208
  $duration += $segment_item;
@@ -219,7 +224,20 @@ class FV_Player_Checker {
219
  $had_ext_x_stream_inf = false;
220
  }
221
 
222
- if( stripos($line,'#EXT-X-STREAM-INF:') === 0 ) $had_ext_x_stream_inf = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  }
224
 
225
  foreach($streams as $item){
@@ -229,6 +247,9 @@ class FV_Player_Checker {
229
  }
230
  $request = wp_remote_get($item_url);
231
  $playlist_item = wp_remote_retrieve_body( $request );
 
 
 
232
  if(preg_match_all('/^#EXTINF:([0-9]+\.?[0-9]*)/im', $playlist_item,$segments)){
233
  foreach($segments[1] as $segment_item){
234
  $duration += $segment_item;
@@ -253,6 +274,8 @@ class FV_Player_Checker {
253
  }
254
 
255
  $fv_flowplayer_meta['duration'] = $time;
 
 
256
  $fv_flowplayer_meta['etag'] = isset($headers['headers']['etag']) ? $headers['headers']['etag'] : false; // todo: check!
257
  $fv_flowplayer_meta['date'] = time();
258
  $fv_flowplayer_meta['check_time'] = microtime(true) - $tStart;
192
  if( isset($ThisFileInfo) && isset($ThisFileInfo['playtime_seconds']) ) {
193
  $time = $ThisFileInfo['playtime_seconds'];
194
  }
195
+
196
+ $is_audio = false;
197
+
198
  if(preg_match('/.m3u8(\?.*)?$/i', $remotefilename_encoded)){
199
+ $is_audio = -1; // We do not know if it's audio only yet
200
 
201
  remove_action( 'http_api_curl', array( 'FV_Player_Checker', 'http_api_curl' ) );
202
  $remotefilename_encoded = apply_filters( 'fv_flowplayer_video_src', $remotefilename_encoded , array('dynamic'=>true) );
205
  $playlist = false;
206
  $duration = 0;
207
  $segments = false;
208
+
209
+ $is_live = stripos( $response, '#EXT-X-ENDLIST' ) === false;
210
+
211
  if(preg_match_all('/^#EXTINF:([0-9]+\.?[0-9]*)/im', $response,$segments)){
212
  foreach($segments[1] as $segment_item){
213
  $duration += $segment_item;
224
  $had_ext_x_stream_inf = false;
225
  }
226
 
227
+ if( stripos($line,'#EXT-X-STREAM-INF:') === 0 ) {
228
+ $had_ext_x_stream_inf = true;
229
+
230
+ // If there are sub-playlists we can be certain it's either audio stream...
231
+ if( $is_audio == -1 ) {
232
+ $is_audio = true;
233
+ }
234
+
235
+ // ...or we found a video track, then we are sure it's not audio stream
236
+ if( stripos($line,'RESOLUTION=') !== false ) {
237
+ $is_audio = false;
238
+ }
239
+ }
240
+
241
  }
242
 
243
  foreach($streams as $item){
247
  }
248
  $request = wp_remote_get($item_url);
249
  $playlist_item = wp_remote_retrieve_body( $request );
250
+
251
+ $is_live = stripos( $playlist_item, '#EXT-X-ENDLIST' ) === false;
252
+
253
  if(preg_match_all('/^#EXTINF:([0-9]+\.?[0-9]*)/im', $playlist_item,$segments)){
254
  foreach($segments[1] as $segment_item){
255
  $duration += $segment_item;
274
  }
275
 
276
  $fv_flowplayer_meta['duration'] = $time;
277
+ $fv_flowplayer_meta['is_live'] = $is_live;
278
+ $fv_flowplayer_meta['is_audio'] = $is_audio;
279
  $fv_flowplayer_meta['etag'] = isset($headers['headers']['etag']) ? $headers['headers']['etag'] : false; // todo: check!
280
  $fv_flowplayer_meta['date'] = time();
281
  $fv_flowplayer_meta['check_time'] = microtime(true) - $tStart;
models/class.fv-player-bunny_stream-api.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class FV_Player_Bunny_Stream_API {
4
+
5
+ private $access_key;
6
+
7
+ public function __construct( $access_key = null ) {
8
+ global $fv_fp;
9
+
10
+ if ( $access_key ) {
11
+ $this->access_key = $access_key;
12
+ } else {
13
+ // if we don't have an access key, try to get it from Bunny Stream config
14
+ $this->access_key = $fv_fp->_get_option( array('bunny_stream','api_key') );
15
+ if ( !$this->access_key ) {
16
+ throw new Exception('Bunny.net API class did not receive an API key and could not detect a stored one in the configuration.');
17
+ }
18
+ }
19
+ }
20
+
21
+ public function api_call( $endpoint, $args = array(), $method = 'GET' ) {
22
+ if( $method == 'POST' ) {
23
+ $response = wp_remote_post( $endpoint, array(
24
+ 'headers' => array(
25
+ "Accept: application/json",
26
+ 'Content-Type' => 'application/json',
27
+ 'AccessKey' => $this->access_key
28
+ ),
29
+ 'body' => wp_json_encode( $args ),
30
+ 'timeout' => 10
31
+ ) );
32
+
33
+ } else {
34
+ $response = wp_remote_get( $endpoint, array(
35
+ 'headers' => array(
36
+ "Accept: application/json",
37
+ 'Content-Type' => 'application/json',
38
+ 'AccessKey' => $this->access_key
39
+ ),
40
+ 'timeout' => 10
41
+ ) );
42
+
43
+ }
44
+
45
+ // on error, return it directly
46
+ if ( is_wp_error( $response ) ) {
47
+ return $response;
48
+ }
49
+
50
+ if ( wp_remote_retrieve_body($response) ) {
51
+ $body = wp_remote_retrieve_body($response);
52
+ $obj = json_decode( $body );
53
+ if ( $obj === null && json_last_error() !== JSON_ERROR_NONE ) {
54
+ return new WP_Error( 1, 'Response from the API is not a valid JSON.', $body );
55
+ }
56
+
57
+ // non-200 codes are errors, too
58
+ if ( substr( $response['response']['code'], 0, 2) != '20' ) {
59
+ return new WP_Error( 2, $obj->Message );
60
+ }
61
+
62
+ } else {
63
+ return new WP_Error( 3, 'Unable to retrieve response body from the API.' );
64
+ }
65
+
66
+ return $obj;
67
+ }
68
+
69
+ }
models/class.fv-player-bunny_stream-browser.php ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if( !class_exists('FV_Player_Bunny_Stream_Browser') && class_exists('FV_Player_Media_Browser') ) :
4
+
5
+ require_once( dirname(__FILE__).'/class.fv-player-bunny_stream-api.php' );
6
+
7
+ class FV_Player_Bunny_Stream_Browser extends FV_Player_Media_Browser {
8
+
9
+ function init() {
10
+ global $fv_fp;
11
+
12
+ if ( $fv_fp->_get_option( array('bunny_stream','api_key') ) && ( is_admin() || get_current_screen()->base == 'fv_player_bunny_stream' ) ) {
13
+ wp_enqueue_script( 'fv-player-bunny_stream-browser', plugins_url( 'js/bunny_stream-browser.js', dirname(__FILE__) ), array( 'flowplayer-browser-base' ), FV_Player_Bunny_Stream()->get_version(), true );
14
+ do_action( 'fv_player_media_browser_enqueue_base_uploader_css' );
15
+ wp_enqueue_script( 'fv-player-bunny_stream-upload', plugins_url( 'js/bunny_stream-upload.js', dirname(__FILE__) ), array( 'flowplayer-browser-base' ), filemtime( dirname(__FILE__).'/js/bunny_stream-upload.js' ), true );
16
+ wp_localize_script( 'fv-player-bunny_stream-upload', 'fv_player_bunny_stream_upload_settings', array(
17
+ 'upload_button_text' => __('Upload to Bunny Stream', 'fv-player-bunny_stream'),
18
+ 'lib_id' => $fv_fp->_get_option( array('bunny_stream','lib_id') ),
19
+ 'api_key' => $fv_fp->_get_option( array('bunny_stream','api_key') ),
20
+ 'job_submit_nonce' => wp_create_nonce('fv_player_bunny_stream'),
21
+ ));
22
+ }
23
+ }
24
+
25
+ function register() {
26
+ add_action( $this->ajax_action_name, array($this, 'load_assets') );
27
+
28
+ // register extra AJAX functions for file uploads to DOS
29
+ add_action( 'wp_ajax_create_upload', array( $this, 'create_upload' ) );
30
+ add_action( 'wp_ajax_upload_complete', array( $this, 'upload_complete' ) );
31
+ add_action( 'wp_ajax_upload_abort', array( $this, 'upload_abort' ) );
32
+ }
33
+
34
+ // Legacy
35
+ function init_for_gutenberg() {}
36
+
37
+ function create_upload() {
38
+ global $FV_Player_DigitalOcean_Spaces;
39
+
40
+ // make sure we have correct CORS on the DOS bucket
41
+ $this->s3("putBucketCors",
42
+ array(
43
+ "Bucket" => $FV_Player_DigitalOcean_Spaces->get_space(),
44
+ "CORSConfiguration" => array(
45
+ "CORSRules" => array(
46
+ array(
47
+ 'AllowedHeaders' => array(
48
+ 'Access-Control-Allow-Methods',
49
+ 'Access-Control-Allow-Origin',
50
+ 'Origin',
51
+ 'Range',
52
+ ),
53
+ 'AllowedMethods'=> array('GET','HEAD','PUT'),
54
+ "AllowedOrigins"=> array("*"),
55
+ ),
56
+ ),
57
+ ),
58
+ )
59
+ );
60
+
61
+ $res = $this->s3( "createMultipartUpload", array(
62
+ 'Bucket' => $FV_Player_DigitalOcean_Spaces->get_space(),
63
+ 'Key' => $_POST['fileInfo']['name'],
64
+ 'ContentType' => $_REQUEST['fileInfo']['type'],
65
+ 'Metadata' => $_REQUEST['fileInfo']
66
+ ));
67
+
68
+ wp_send_json( array(
69
+ 'uploadId' => $res->get('UploadId'),
70
+ 'key' => $res->get('Key'),
71
+ ));
72
+ wp_die();
73
+ }
74
+
75
+ function upload_complete() {
76
+ global $FV_Player_DigitalOcean_Spaces;
77
+
78
+ $partsModel = $this->s3("listParts", array(
79
+ 'Bucket' => $FV_Player_DigitalOcean_Spaces->get_space(),
80
+ 'Key' => $_REQUEST['sendBackData']['key'],
81
+ 'UploadId' => $_REQUEST['sendBackData']['uploadId'],
82
+ ) );
83
+
84
+ $ret = $this->s3( "completeMultipartUpload" , array(
85
+ 'Bucket' => $FV_Player_DigitalOcean_Spaces->get_space(),
86
+ 'Key' => $_REQUEST['sendBackData']['key'],
87
+ 'UploadId' => $_REQUEST['sendBackData']['uploadId'],
88
+ 'MultipartUpload' => array(
89
+ "Parts" => $partsModel["Parts"],
90
+ ),
91
+ ))->toArray();
92
+
93
+ wp_send_json( array(
94
+ 'success' => true,
95
+ 'url' => $ret['ObjectURL'],
96
+ 'key' => $ret['Key'],
97
+ 'nonce' => wp_create_nonce( 'fv_player_coconut' ),
98
+ ));
99
+ wp_die();
100
+ }
101
+
102
+ function upload_abort() {
103
+ global $FV_Player_DigitalOcean_Spaces;
104
+
105
+ // if initial pre-upload request fails, we'll have no sendBackData to abort
106
+ if ( !empty( $_REQUEST['sendBackData'] ) ) {
107
+ $this->s3("abortMultipartUpload",[
108
+ 'Bucket' => $FV_Player_DigitalOcean_Spaces->get_space(),
109
+ 'Key' => $_REQUEST['sendBackData']['key'],
110
+ 'UploadId' => $_REQUEST['sendBackData']['uploadId']
111
+ ]);
112
+ }
113
+
114
+ wp_send_json( array(
115
+ 'success' => true
116
+ ));
117
+ wp_die();
118
+ }
119
+
120
+ function get_formatted_assets_data() {
121
+ global $fv_fp, $wpdb;
122
+
123
+ $local_jobs = $wpdb->get_results( "SELECT id, job_id FROM " . FV_Player_Bunny_Stream()->get_table_name() );
124
+ $local_jobs = wp_list_pluck( $local_jobs, 'id', 'job_id');
125
+
126
+ // load videos based from the library
127
+ $api = new FV_Player_Bunny_Stream_API();
128
+
129
+ $query_string = array( 'itemsPerPage' => 50, 'orderBy' => 'date' );
130
+ $query_string['page'] = ( !empty($_POST['page']) && is_numeric($_POST['page']) && (int) $_POST['page'] == $_POST['page'] ? $_POST['page'] : 1 );
131
+ if( !empty($_POST['search']) ) {
132
+ $query_string['search'] = $_POST['search'];
133
+ }
134
+
135
+ $endpoint = add_query_arg(
136
+ $query_string,
137
+ 'https://video.bunnycdn.com/library/'.$fv_fp->_get_option( array('bunny_stream','lib_id') ).'/videos'
138
+ );
139
+
140
+ $result = $api->api_call( $endpoint );
141
+
142
+ if ( is_wp_error( $result ) ) {
143
+ $result = array( 'error' => $result->get_error_message() );
144
+ } else if ( !is_object( $result ) ) {
145
+ $result = array( 'error' => $result );
146
+ }
147
+
148
+ $result->time = time();
149
+ $video_data_more_pages_exist = ( $result->totalItems > ( $result->currentPage * $result->itemsPerPage ) );
150
+
151
+ // prepare base folder
152
+ $body = array();
153
+ $body['name'] = 'Home';
154
+ $body['path'] = 'Home/';
155
+ $body['type'] = 'folder';
156
+ $body['items'] = array();
157
+
158
+ // prepare result for browser
159
+ // ... $result will be a return-value array instead of an object if there was an error
160
+ if ( !is_array( $result ) ) {
161
+ $date_format = get_option( 'date_format' );
162
+ $cdn_hostname = 'https://' . $fv_fp->_get_option( array('bunny_stream','cdn_hostname') ) . '/';
163
+
164
+ foreach ($result->items as $video) {
165
+ $item = array(
166
+ 'link' => $cdn_hostname . $video->guid . '/playlist.m3u8',
167
+ 'name' => $video->title,
168
+ 'size' => $video->storageSize,
169
+ 'type' => 'file',
170
+ 'path' => 'Home/' . $video->title,
171
+ 'duration' => $video->length,
172
+ 'modified' => date( $date_format, strtotime( $video->dateUploaded ) ),
173
+ 'width' => $video->width,
174
+ 'height' => $video->height,
175
+ 'extra' => array(),
176
+ );
177
+
178
+ if( !empty($local_jobs[$video->guid]) ) {
179
+ $item['extra']['encoding_job_id'] = $local_jobs[$video->guid];
180
+ }
181
+
182
+ // job in processing
183
+ if ( $video->status < 4 ) {
184
+ $item['extra']['encoding_job_status'] = 'processing';
185
+ $item['extra']['displayData'] = 'This file is currently being processed by the Bunny Stream service.';
186
+ $item['extra']['percentage'] = $video->encodeProgress . '%';
187
+ // don't allow selecting this file until it's at least playable
188
+ if ( !$video->availableResolutions ) {
189
+ $item['extra']['disabled'] = 1;
190
+ } else {
191
+ // video is playable but still encoding, mark it as such
192
+ $item['extra']['encoding_job_status'] = 'playable';
193
+
194
+ // These properties are already there
195
+ $item['splash'] = $cdn_hostname . $video->guid . '/' . $video->thumbnailFileName;
196
+ $item['extra']['title'] = $video->title;
197
+ }
198
+ } else if ( $video->status > 4 ) {
199
+ // job errored out
200
+ $item['extra']['disabled'] = 1;
201
+ $item['extra']['encoding_job_status'] = 'error';
202
+ if ( $video->status == 5 ) {
203
+ $item['extra']['displayData'] = 'Processing error on the Bunny Stream side.';
204
+ } else {
205
+ $item['extra']['displayData'] = 'Upload error or file upload cancelled.';
206
+ }
207
+ } else {
208
+ // job complete
209
+ $item['splash'] = $cdn_hostname . $video->guid . '/' . $video->thumbnailFileName;
210
+ $item['extra']['title'] = $video->title;
211
+ }
212
+
213
+ $body['items'][] = $item;
214
+ }
215
+ }
216
+
217
+ $json_final = array(
218
+ 'items' => $body,
219
+ 'is_last_page' => !$video_data_more_pages_exist,
220
+ );
221
+
222
+ // ... $result will be a return-value array instead of an object if there was an error
223
+ if ( is_array($result) ) {
224
+ $json_final['err'] = $result['error'];
225
+ }
226
+
227
+ return $json_final;
228
+ }
229
+
230
+ function load_assets() {
231
+ $json_final = $this->get_formatted_assets_data();
232
+
233
+ wp_send_json( $json_final );
234
+ wp_die();
235
+ }
236
+
237
+ }
238
+
239
+ new FV_Player_Bunny_Stream_Browser( 'wp_ajax_load_bunny_stream_jobs' );
240
+
241
+ endif;
models/class.fv-player-bunny_stream-wizard.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class FV_Player_Bunny_Stream_Wizard extends FV_Player_Wizard_Base_Class {
4
+
5
+ static $instance = null;
6
+
7
+ public static function _get_instance() {
8
+ if( !self::$instance ) {
9
+ self::$instance = new self();
10
+ }
11
+
12
+ return self::$instance;
13
+ }
14
+
15
+ public function __construct() {
16
+ parent::__construct( array(
17
+ 'id' => 'fv_player_bunny_stream_wizard',
18
+ 'page' => 'fv_player_bunny_stream',
19
+ 'steps_path' => dirname(__FILE__).'/bunny-stream-wizard',
20
+ 'title' => 'FV Player Bunny Stream Wizard'
21
+ ) );
22
+ }
23
+
24
+ public function view() {
25
+ ?>
26
+ <style>
27
+ /* Make sure the SVG images have some spacing and background */
28
+ .fv-player-wizard-step img[src$="svg"] {
29
+ background-color: white;
30
+ padding: 1em;
31
+ max-width: calc( 100% - 2em );
32
+ }
33
+ </style>
34
+ <?php
35
+ $this->show();
36
+
37
+ }
38
+
39
+ }
40
+
41
+ function FV_Player_Bunny_Stream_Wizard() {
42
+ return FV_Player_Bunny_Stream_Wizard::_get_instance();
43
+ }
44
+
45
+ FV_Player_Bunny_Stream_Wizard();
models/class.fv-player-bunny_stream.php ADDED
@@ -0,0 +1,485 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( dirname(__FILE__).'/class.fv-player-bunny_stream-wizard.php' );
4
+
5
+ class FV_Player_Bunny_Stream extends FV_Player_Video_Encoder {
6
+
7
+ private static $instance = null;
8
+
9
+ public $plugin_api;
10
+
11
+ /**
12
+ * gets the instance via lazy initialization (created on first usage)
13
+ */
14
+ public static function getInstance( $encoder_id, $encoder_name, $encoder_wp_url_slug, $browser_inc_file ) {
15
+ if ( self::$instance === null ) {
16
+ self::$instance = new static( $encoder_id, $encoder_name, $encoder_wp_url_slug, $browser_inc_file );
17
+ }
18
+
19
+ return self::$instance;
20
+ }
21
+
22
+ /**
23
+ * prevent the instance from being cloned (which would create a second instance of it)
24
+ */
25
+ private function __clone() {}
26
+
27
+ /**
28
+ * prevent from being unserialized (which would create a second instance of it)
29
+ */
30
+ public function __wakeup() {
31
+ throw new Exception("Cannot unserialize singleton");
32
+ }
33
+
34
+ protected function __construct( $encoder_id, $encoder_name, $encoder_wp_url_slug, $browser_inc_file ) {
35
+ $this->version = '7.5.13.727';
36
+
37
+ parent::__construct( $encoder_id, $encoder_name, $encoder_wp_url_slug, $browser_inc_file );
38
+ }
39
+
40
+ public function admin_notices() {}
41
+
42
+ /**
43
+ * Bunny Stream doesn't use configurations, so we'll just return the same config that we received.
44
+ *
45
+ * @param $conf Pre-populated configuration array into which the extending Encoder's class configuration should go.
46
+ *
47
+ * @return array Simply returns the same config that we received, since Bunny Stream doesn't use configurations.
48
+ */
49
+ public function default_settings( $conf ) {
50
+ return $conf;
51
+ }
52
+
53
+ /**
54
+ * Verifies the currently used endpoint supported by the extending Encoder, such as (S)FTP or S3 credentials
55
+ * and either directly outputs a JSON-formatted error (for AJAX purposes) or returns the error to be processed further.
56
+ *
57
+ * @return mixed Returns TRUE if the current endpoint is set up properly, an error object/array otherwise.
58
+ * If we're running an AJAX request, this method must return a valid JSON-formatted error for that request
59
+ * by utilizing the wp_send_json() method in this format: wp_send_json( array('error' => $error) );
60
+ */
61
+ protected function verify_active_endpoint( $target ) {
62
+ // if we have API key, library ID & CDN hostname, we're good and any errors (such as edited & invalid / expired API key) would show up
63
+ // when we try to contact the API
64
+ return $this->is_configured();
65
+ }
66
+
67
+ /*
68
+ * Returns the CDN URL - same as get_cdn_url() for now, until we determine whether we need something else or if we can merge these 2.
69
+ * TODO: determine whether we need 2 CDN functions or if we can merge this with get_cdn_url()
70
+ */
71
+ function get_cdn_conf( /*$no_credentials = false*/ ) {
72
+ global $fv_fp;
73
+
74
+ return trailingslashit( $fv_fp->_get_option( array('bunny_stream', 'cdn_hostname') ) );
75
+ }
76
+
77
+ /**
78
+ * Gives you the HTTP URL of the target location
79
+ * TODO: determine whether we need 2 CDN functions or if we can merge this with get_cdn_conf()
80
+ *
81
+ * @return string
82
+ */
83
+ function get_cdn_url() {
84
+ global $fv_fp;
85
+
86
+ return trailingslashit( $fv_fp->_get_option( array('bunny_stream', 'cdn_hostname') ) );
87
+ }
88
+
89
+ /**
90
+ * Bunny Stream uses no configuration, it will encode videos according to each stream's settings.
91
+ * This method simply therefore returns exactly what it was given.
92
+ *
93
+ * @param $args array Config array from the base encoder class.
94
+ *
95
+ * @return array Returns the same $args array that it was given, since Bunny Streams use no configurations.
96
+ */
97
+ function get_conf( $args ) {
98
+ return $args;
99
+ }
100
+
101
+ /**
102
+ * Determines whether this Encoder has been properly configured.
103
+ */
104
+ function is_configured() {
105
+ global $fv_fp;
106
+ return !empty($fv_fp) && method_exists($fv_fp,'_get_option') && $fv_fp->_get_option( array('bunny_stream','api_key') ) && $fv_fp->_get_option( array('bunny_stream','lib_id') ) && $fv_fp->_get_option( array('bunny_stream','cdn_hostname') );
107
+ }
108
+
109
+ /**
110
+ * Normalizes Bunny Stream statuses for use in our DB.
111
+ *
112
+ * @param $status string The original status from Bunny Stream.
113
+ *
114
+ * @return string Returns the normalized status for use in our DB.
115
+ */
116
+ function get_bunny_stream_status( $status ) {
117
+ if( $status == 0 || $status == 1 || $status == 2 ) {
118
+ // 0 = queued, 1 = processing, 2 = encoding ... but these 3 mean the same thing for our purposes
119
+ $status = 'processing';
120
+ } else if( $status == 3 || $status == 4 ) {
121
+ // 4 = resolution finished (which was previously changed to 3 afterwards but is no longer the case, so 4 is as good as done)
122
+ $status = 'completed';
123
+ } else {
124
+ $status = 'error';
125
+ }
126
+
127
+ return $status;
128
+ }
129
+
130
+ /**
131
+ * Prepares and returns data to be inserted into the "output" column of this encoder's DB table.
132
+ */
133
+ protected function prepare_job_output_column_value() {
134
+ return json_encode( array(
135
+ 'base_url' => trailingslashit( $this->get_cdn_conf() ),
136
+ 'replacing_url' => trailingslashit( $this->get_cdn_url() )
137
+ ) );
138
+ }
139
+
140
+ public function job_create_expiration( $ttl ) {
141
+ return 4 * 3600;
142
+ }
143
+
144
+ /**
145
+ * Update job status
146
+ *
147
+ * @param object|int $pending_job Table row from wp_fv_player_encoding_jobs or its job ID
148
+ *
149
+ * @global object $wpdb WordPress database object
150
+ * @global object $fv_fp FV Player
151
+ *
152
+ * @return array
153
+ * array(
154
+ * 'result' object Job info from Bunny.net
155
+ * 'status' string You get either "processing", "completed" or "error"
156
+ * 'output' object URLs for resources - for Bunny Streams, we don't change CDN URLs, so both URLs here will be the same
157
+ * )
158
+ */
159
+ protected function job_check( $pending_job ) {
160
+ global $wpdb, $fv_fp;
161
+
162
+ if( is_numeric($pending_job) ) {
163
+ $pending_job = $wpdb->get_row( $wpdb->prepare( "SELECT id, progress, result, output FROM " . $this->table_name . " WHERE id = %d", $pending_job ) );
164
+ }
165
+
166
+ if( !$pending_job ) {
167
+ return;
168
+ }
169
+
170
+ $output = json_decode( $pending_job->output );
171
+ $job_details = json_decode( $pending_job->result );
172
+
173
+ if ( ! isset( $job_details->guid ) ) {
174
+ $job_id = $pending_job->job_id;
175
+ } else {
176
+ $job_id = $job_details->guid;
177
+ }
178
+
179
+ require_once( dirname( __FILE__ ) . '/class.fv-player-bunny_stream-api.php' );
180
+ $api = new FV_Player_Bunny_Stream_API();
181
+ $job = $api->api_call( 'https://video.bunnycdn.com/library/' . $fv_fp->_get_option( array(
182
+ 'bunny_stream',
183
+ 'lib_id'
184
+ ) ) . '/videos/' . $job_id );
185
+
186
+ if ( ! is_wp_error( $job ) ) {
187
+ $status = $this->get_bunny_stream_status( $job->status );
188
+ $progress = $job->encodeProgress;
189
+
190
+ // check whether this job hasn't failed upload
191
+ if ( $job->status == 6 ) {
192
+ // job failed upload
193
+ $wpdb->update( $this->table_name, array(
194
+ 'date_checked' => date( "Y-m-d H:i:s" ),
195
+ 'status' => 'error',
196
+ 'error' => 'Upload failed',
197
+ ), array(
198
+ 'id' => $pending_job->id
199
+ ), array(
200
+ '%s'
201
+ ), array(
202
+ '%d'
203
+ )
204
+ );
205
+ } else {
206
+ $wpdb->update( $this->table_name, array(
207
+ 'result' => json_encode( $job ),
208
+ 'status' => $status,
209
+ 'date_checked' => date( "Y-m-d H:i:s" ),
210
+ 'progress' => $progress . '%',
211
+ ), array(
212
+ 'id' => $pending_job->id
213
+ ), array(
214
+ '%s',
215
+ '%s',
216
+ '%s',
217
+ '%s'
218
+ ), array(
219
+ '%d'
220
+ ) );
221
+ }
222
+ } else {
223
+ $wpdb->update( $this->table_name, array(
224
+ 'date_checked' => date( "Y-m-d H:i:s" ),
225
+ 'error' => $job->get_error_message(),
226
+ ), array(
227
+ 'id' => $pending_job->id
228
+ ), array(
229
+ '%s'
230
+ ), array(
231
+ '%d'
232
+ )
233
+ );
234
+
235
+ $status = 0;
236
+ }
237
+
238
+ $ret = array(
239
+ 'result' => $job,
240
+ 'status' => $status,
241
+ 'output' => $output,
242
+ );
243
+
244
+ if ( isset($progress) ) {
245
+ $ret['progress'] = $progress;
246
+ } else if ( isset( $pending_job ) && !empty( $pending_job->progress ) ) {
247
+ $ret['progress'] = $pending_job->progress;
248
+ }
249
+
250
+ return $ret;
251
+ }
252
+
253
+ /**
254
+ * Submit the job to Bunny Stream and store the result in table
255
+ *
256
+ * @param int $job_id Job ID
257
+
258
+ * @global object $wpdb WordPress database object
259
+ * @global object $fv_fp FV Player instance to load options with
260
+ *
261
+ * @return bool Result
262
+ */
263
+ function job_submit( $id ) {
264
+ global $fv_fp, $wpdb;
265
+
266
+ $target_name = $wpdb->get_var( $wpdb->prepare( "SELECT target FROM " . $this->table_name ." WHERE id = %d", $id ) );
267
+
268
+ require_once( dirname( __FILE__ ) . '/class.fv-player-bunny_stream-api.php');
269
+ $api = new FV_Player_Bunny_Stream_API();
270
+ $job = $api->api_call(
271
+ 'https://video.bunnycdn.com/library/' . $fv_fp->_get_option( array('bunny_stream','lib_id') ) . '/videos',
272
+ array(
273
+ 'title' => $target_name,
274
+ ),
275
+ 'POST'
276
+ );
277
+
278
+ $job_id = 0;
279
+ $progress = '0%';
280
+
281
+ if ( !is_wp_error( $job ) ) {
282
+ $job_id = $job->guid;
283
+ $status = 'processing';
284
+ $result = $job;
285
+ } else {
286
+ $result = array( 'exception' => $job->get_error_message() );
287
+ $status = 'error';
288
+ $progress = 'failed';
289
+ }
290
+
291
+ $wpdb->update( $this->table_name, array(
292
+ 'job_id' => $job_id,
293
+ 'result' => $result,
294
+ 'status' => $status,
295
+ 'progress' => $progress,
296
+ ), array(
297
+ 'id' => $id // where id
298
+ ), array(
299
+ '%s', // job_id
300
+ '%s', // result
301
+ '%s', // status
302
+ '%s' // progress
303
+ ), array(
304
+ '%d' // id
305
+ ) );
306
+
307
+ return array(
308
+ 'status' => $status,
309
+ 'result' => $result,
310
+ );
311
+ }
312
+
313
+ /**
314
+ * Displays the jobs listing page contents.
315
+ */
316
+ function tools_panel_jobs() {
317
+ do_action( 'fv_player_video_encoder_include_listing_lib' );
318
+
319
+ $this->plugin_update_database();
320
+
321
+ $this->jobs_check();
322
+
323
+ $user = get_current_user_id();
324
+ $screen = get_current_screen();
325
+ $screen_option = $screen->get_option('per_page', 'option');
326
+ $per_page = get_user_meta($user, $screen_option, true);
327
+ if ( empty ( $per_page) || $per_page < 1 ) {
328
+ $per_page = $screen->get_option( 'per_page', 'default' );
329
+ }
330
+
331
+ do_action( 'fv_player_video_encoder_include_listing_lib' );
332
+
333
+ $table = new FV_Player_Encoder_List_Table( array( 'encoder_id' => 'bunny_stream', 'table_name' => $this->table_name, 'per_page' => $per_page ) );
334
+ $table->prepare_items();
335
+ ?>
336
+ <style>
337
+ .wrap .fv-player-bunny_stream-add, .wrap .fv-player-bunny_stream-add:active {
338
+ top: 24px;
339
+ }
340
+ </style>
341
+ <a href="#" class="page-title-action fv-player-bunny_stream-add" data-add_new="1">Add New</a>
342
+
343
+ <div id="fv_player_players_table">
344
+ <form id="fv-player-filter" method="get" action="<?php echo admin_url( 'admin.php?page=fv_player' ); ?>">
345
+ <input type="hidden" name="page" value="fv_player" />
346
+
347
+ <?php $table->views() ?>
348
+
349
+ <?php $table->advanced_filters(); ?>
350
+
351
+ <?php $table->display() ?>
352
+ </form>
353
+ </div>
354
+
355
+ <?php
356
+ }
357
+
358
+ /**
359
+ * Displays the Encoder's settings page contents.
360
+ */
361
+ function tools_panel_settings() {
362
+
363
+ if( isset($_POST['fv_player_bunny_stream_settings_nonce']) && !empty($_POST['bunny_stream']) ) {
364
+
365
+ if( wp_verify_nonce( $_POST['fv_player_bunny_stream_settings_nonce'],'fv_player_bunny_stream_settings_nonce') ) {
366
+ global $fv_fp;
367
+ if( method_exists($fv_fp,'_set_conf') ) {
368
+ if( empty($fv_fp->conf['bunny_stream']) ) {
369
+ $fv_fp->conf['bunny_stream'] = array();
370
+ }
371
+
372
+ foreach( $_POST['bunny_stream'] AS $k => $v ) {
373
+ $fv_fp->conf['bunny_stream'][$k] = trim($v);
374
+ }
375
+
376
+ $fv_fp->_set_conf( $fv_fp->conf );
377
+
378
+ echo "<div class='updated'><p>Settings saved</p></div>";
379
+
380
+ }
381
+ } else {
382
+ echo "<div class='error'><p>Nonce error.</p></div>";
383
+
384
+ }
385
+ }
386
+
387
+ if( $this->is_configured() ) {
388
+ include( dirname(__FILE__).'/../view/bunny-stream-settings.php' );
389
+ }
390
+
391
+ if( $this->is_configured() ) {
392
+ FV_Player_Bunny_Stream_Wizard()->log_show();
393
+
394
+ } else {
395
+ FV_Player_Bunny_Stream_Wizard()->view();
396
+
397
+ }
398
+ }
399
+
400
+ function email_notification() {
401
+ if( isset( $_GET['fv_player_bunny_stream_job_webhook'] ) && !empty($_GET['fv_player_bunny_stream_job_webhook']) ) {
402
+ global $wpdb, $fv_fp;
403
+
404
+ // https://docs.bunny.net/docs/stream-webhook
405
+ $body = file_get_contents( "php://input" );
406
+ $webhook = json_decode( $body, true );
407
+
408
+ if ( ! $webhook ) {
409
+ return;
410
+ }
411
+
412
+ $job_id = $webhook['VideoGuid'];
413
+ $status = $webhook['Status'];
414
+ $status = $this->get_bunny_stream_status( $status );
415
+
416
+ if ( strcmp( $status, 'processing' ) == 0 ) {
417
+ // check if we have this job in the DB and if not, add it there
418
+ if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM " . $this->table_name . " WHERE job_id = %s", $job_id ) ) ) {
419
+ // get info about this job first, so we can set up DB data correctly
420
+ require_once( dirname( __FILE__ ) . '/class.fv-player-bunny_stream-api.php' );
421
+ $api = new FV_Player_Bunny_Stream_API();
422
+ $job = $api->api_call( 'https://video.bunnycdn.com/library/' . $fv_fp->_get_option( array(
423
+ 'bunny_stream',
424
+ 'lib_id'
425
+ ) ) . '/videos/' . $job_id );
426
+
427
+ if ( ! is_wp_error( $job ) ) {
428
+ $wpdb->insert( $this->table_name, array(
429
+ 'date_created' => date( "Y-m-d H:i:s" ),
430
+ 'source' => $job->title,
431
+ 'target' => $job->title,
432
+ 'type' => 'bunny_stream',
433
+ 'mime' => $fv_fp->get_mime_type( $job->title ),
434
+ 'status' => $status,
435
+ 'output' => $this->prepare_job_output_column_value(),
436
+ 'args' => '',
437
+ 'author' => get_current_user_id(),
438
+ 'job_id' => $job_id,
439
+ 'result' => $job,
440
+ 'progress' => $job->encodeProgress,
441
+ ), array(
442
+ '%s',
443
+ '%s',
444
+ '%s',
445
+ '%s',
446
+ '%s',
447
+ '%s',
448
+ '%s',
449
+ '%s',
450
+ '%d',
451
+ '%s',
452
+ '%s',
453
+ '%s',
454
+ ) );
455
+ }
456
+ }
457
+
458
+ exit;
459
+ }
460
+
461
+ $row = $wpdb->get_row(
462
+ $wpdb->prepare( "SELECT `job_id`, `author` , `target`, `result` FROM " . $this->table_name . " WHERE job_id = %s", $job_id )
463
+ );
464
+
465
+ $this->send_email( $job_id, $row->author, $status, $row->target, $row->result );
466
+
467
+ die();
468
+ }
469
+ }
470
+
471
+ /**
472
+ * Must return __FILE__ from the extending class.
473
+ * Used to determine plugin path for registering JS and CSS.
474
+ */
475
+ function getFILE() {
476
+ return __FILE__;
477
+ }
478
+ }
479
+
480
+ function FV_Player_Bunny_Stream() {
481
+ return FV_Player_Bunny_Stream::getInstance( 'bunny_stream', 'Bunny Stream', 'fv_player_bunny_stream', dirname(__FILE__) . '/class.fv-player-bunny_stream-browser.php' );
482
+ }
483
+
484
+ // create the instance right away, so the browser and other assets are loaded correctly where they should be
485
+ FV_Player_Bunny_Stream();
models/db.php CHANGED
@@ -1592,8 +1592,10 @@ class FV_Player_Db {
1592
  $url = $secured_url;
1593
  }
1594
 
1595
- $json_data['duration'] = $FV_Player_Checker->check_mimetype(array($url), false, true);
1596
- $json_data['duration'] = $json_data['duration']['duration'];
 
 
1597
  }
1598
 
1599
  header('Content-Type: application/json');
1592
  $url = $secured_url;
1593
  }
1594
 
1595
+ $check = $FV_Player_Checker->check_mimetype(array($url), false, true);
1596
+ $json_data['duration'] = $check['duration'];
1597
+ $json_data['is_live'] = $check['is_live'];
1598
+ $json_data['is_audio'] = $check['is_audio'];
1599
  }
1600
 
1601
  header('Content-Type: application/json');
models/flowplayer-frontend.php CHANGED
@@ -528,11 +528,14 @@ class flowplayer_frontend extends flowplayer
528
  // Align
529
  $attributes['class'] .= $this->get_align();
530
 
531
- if( $this->_get_option('engine') || $this->aCurArgs['engine'] == 'flash' ) {
532
  $attributes['data-engine'] = 'flash';
533
  }
534
 
535
- if( $this->aCurArgs['embed'] == 'false' || $this->aCurArgs['embed'] == 'off' || ( $this->_get_option('disableembedding') && $this->aCurArgs['embed'] != 'true' ) ) {
 
 
 
536
 
537
  } else {
538
  $attributes['data-fv-embed'] = $this->get_embed_url();
@@ -737,7 +740,7 @@ class flowplayer_frontend extends flowplayer
737
  $this->ret['html'] .= $this->sHTMLAfter.$scripts_after;
738
 
739
  // change engine for IE9 and 10
740
- if( $this->aCurArgs['engine'] == 'false' ) {
741
  $this->ret['script']['fv_flowplayer_browser_ie'][$this->hash] = true;
742
  }
743
 
@@ -1206,14 +1209,17 @@ class flowplayer_frontend extends flowplayer
1206
  $sHTMLVideoLink = false;
1207
  }
1208
 
1209
- if( $this->aCurArgs['embed'] == 'false' || $this->aCurArgs['embed'] == 'off' ) {
1210
  $sHTMLVideoLink = false;
1211
  }
1212
 
1213
  $sHTMLEmbed = '<div><label><a class="embed-code-toggle" href="#"><strong>Embed</strong></a></label></div><div class="embed-code"><label>Copy and paste this HTML code into your webpage to embed.</label><textarea></textarea></div>';
1214
 
1215
 
1216
- if( $this->aCurArgs['embed'] == 'false' || $this->aCurArgs['embed'] == 'off' || ( $this->_get_option('disableembedding') && $this->aCurArgs['embed'] != 'true' ) ) {
 
 
 
1217
  $sHTMLEmbed = '';
1218
  }
1219
 
528
  // Align
529
  $attributes['class'] .= $this->get_align();
530
 
531
+ if( $this->_get_option('engine') || !empty($this->aCurArgs['engine']) && $this->aCurArgs['engine'] == 'flash' ) {
532
  $attributes['data-engine'] = 'flash';
533
  }
534
 
535
+ if(
536
+ !empty($this->aCurArgs['embed']) && ( $this->aCurArgs['embed'] == 'false' || $this->aCurArgs['embed'] == 'off' ) ||
537
+ $this->_get_option('disableembedding') && ( empty($this->aCurArgs['embed']) || $this->aCurArgs['embed'] != 'true' )
538
+ ) {
539
 
540
  } else {
541
  $attributes['data-fv-embed'] = $this->get_embed_url();
740
  $this->ret['html'] .= $this->sHTMLAfter.$scripts_after;
741
 
742
  // change engine for IE9 and 10
743
+ if( !empty($this->aCurArgs['engine']) && $this->aCurArgs['engine'] == 'false' ) {
744
  $this->ret['script']['fv_flowplayer_browser_ie'][$this->hash] = true;
745
  }
746
 
1209
  $sHTMLVideoLink = false;
1210
  }
1211
 
1212
+ if( !empty($this->aCurArgs['embed']) && ( $this->aCurArgs['embed'] == 'false' || $this->aCurArgs['embed'] == 'off' ) ) {
1213
  $sHTMLVideoLink = false;
1214
  }
1215
 
1216
  $sHTMLEmbed = '<div><label><a class="embed-code-toggle" href="#"><strong>Embed</strong></a></label></div><div class="embed-code"><label>Copy and paste this HTML code into your webpage to embed.</label><textarea></textarea></div>';
1217
 
1218
 
1219
+ if(
1220
+ !empty($this->aCurArgs['embed']) && ( $this->aCurArgs['embed'] == 'false' || $this->aCurArgs['embed'] == 'off' ) ||
1221
+ $this->_get_option('disableembedding') && ( empty($this->aCurArgs['embed']) || $this->aCurArgs['embed'] != 'true' )
1222
+ ) {
1223
  $sHTMLEmbed = '';
1224
  }
1225
 
models/list-table.php CHANGED
@@ -278,16 +278,16 @@ class FV_Player_List_Table extends WP_List_Table {
278
  $value = $player->date_created > 0 ? "<abbr title='$player->date_created'>".date('Y/m/d',strtotime($player->date_created))."</abbr>" : false;
279
  break;
280
  case 'player_name' :
281
- $value = "<a href='#' class='fv-player-edit' data-player_id='{$id}'>".$player->player_name."</a>";
282
  $value .= "<div class='row-actions'>";
283
  $value .= "<a href='#' class='fv-player-edit' data-player_id='{$id}'>Edit</a> | ";
284
- $value .= "<a href='#' class='fv-player-export' data-player_id='{$id}' data-nonce='".wp_create_nonce('fv-player-db-export-'.$id)."'>Export</a><span> | ";
285
- $value .= "<a href='#' class='fv-player-clone' data-player_id='{$id}' data-nonce='".wp_create_nonce('fv-player-db-export-'.$id)."'>Clone</a><span> | ";
286
  $value .= "<span class='trash'><a href='#' class='fv-player-remove' data-player_id='{$id}' data-nonce='".wp_create_nonce('fv-player-db-remove-'.$id)."'>Delete</a></span>";
287
 
288
  $value .= '<input type="text" class="fv-player-shortcode-input" readonly value="'.esc_attr('[fvplayer id="'. $id .'"]').'" style="display: none" /><a href="#" class="button fv-player-shortcode-copy">Copy Shortcode</a>';
289
 
290
- $value .= "</div>";
291
  break;
292
  case 'embeds':
293
  $player = new FV_Player_Db_Player($id);
278
  $value = $player->date_created > 0 ? "<abbr title='$player->date_created'>".date('Y/m/d',strtotime($player->date_created))."</abbr>" : false;
279
  break;
280
  case 'player_name' :
281
+ $value = "<a href='#' class='fv-player-edit' data-player_id='{$id}'>".$player->player_name."</a>\n";
282
  $value .= "<div class='row-actions'>";
283
  $value .= "<a href='#' class='fv-player-edit' data-player_id='{$id}'>Edit</a> | ";
284
+ $value .= "<a href='#' class='fv-player-export' data-player_id='{$id}' data-nonce='".wp_create_nonce('fv-player-db-export-'.$id)."'>Export</a> | ";
285
+ $value .= "<a href='#' class='fv-player-clone' data-player_id='{$id}' data-nonce='".wp_create_nonce('fv-player-db-export-'.$id)."'>Clone</a> | ";
286
  $value .= "<span class='trash'><a href='#' class='fv-player-remove' data-player_id='{$id}' data-nonce='".wp_create_nonce('fv-player-db-remove-'.$id)."'>Delete</a></span>";
287
 
288
  $value .= '<input type="text" class="fv-player-shortcode-input" readonly value="'.esc_attr('[fvplayer id="'. $id .'"]').'" style="display: none" /><a href="#" class="button fv-player-shortcode-copy">Copy Shortcode</a>';
289
 
290
+ $value .= "</div>\n";
291
  break;
292
  case 'embeds':
293
  $player = new FV_Player_Db_Player($id);
models/media-browser.php CHANGED
@@ -12,7 +12,10 @@ abstract class FV_Player_Media_Browser {
12
  add_action( 'enqueue_block_editor_assets', array($this, 'init_base') ); // for Gutenberg
13
  add_action( 'admin_print_scripts-toplevel_page_fv_player', array($this, 'init_base'), 0 ); // wp-admin -> FV Player
14
  add_action( 'admin_print_scripts-widgets.php', array($this, 'init_base'), 0 ); // wp-admin -> Widgets
15
- add_action( 'admin_print_scripts-fv-player_page_fv_player_coconut', array($this, 'init_base'), 0 ); // wp-admin -> FV Player -> Encode video
 
 
 
16
  add_action( 'fv_player_media_browser_enqueue_base_uploader_css', array( $this, 'include_base_uploader_css' ) );
17
 
18
  // register extending class WP AJAX action
12
  add_action( 'enqueue_block_editor_assets', array($this, 'init_base') ); // for Gutenberg
13
  add_action( 'admin_print_scripts-toplevel_page_fv_player', array($this, 'init_base'), 0 ); // wp-admin -> FV Player
14
  add_action( 'admin_print_scripts-widgets.php', array($this, 'init_base'), 0 ); // wp-admin -> Widgets
15
+
16
+ // TODO: Video encoder class should take care of this
17
+ add_action( 'admin_print_scripts-fv-player_page_fv_player_coconut', array($this, 'init_base'), 0 ); // wp-admin -> FV Player -> Coconut Jobs
18
+ add_action( 'admin_print_scripts-fv-player_page_fv_player_bunny_stream', array($this, 'init_base'), 0 ); // wp-admin -> FV Player -> Bunny Stream Jobs
19
  add_action( 'fv_player_media_browser_enqueue_base_uploader_css', array( $this, 'include_base_uploader_css' ) );
20
 
21
  // register extending class WP AJAX action
models/player-position-save.php CHANGED
@@ -65,15 +65,20 @@ class FV_Player_Position_Save {
65
  // TODO: XSS filter for POST values?
66
  // check if videoTimes is not a JSON-encoded value, which will happen
67
  // when the request came from a navigation.sendBeacon() call instead of the usual AJAX call
68
- $decoded_times = json_decode(urldecode($_POST['videoTimes']), true);
69
- $decoded_playlists = json_decode(urldecode($_POST['playlistItems']), true);
70
-
71
- if ($decoded_times !== false) {
72
- $_POST['videoTimes'] = $decoded_times;
 
73
  }
74
 
75
- if ($decoded_playlists !== false) {
76
- $_POST['playlistItems'] = $decoded_playlists;
 
 
 
 
77
  }
78
 
79
  $success = false;
65
  // TODO: XSS filter for POST values?
66
  // check if videoTimes is not a JSON-encoded value, which will happen
67
  // when the request came from a navigation.sendBeacon() call instead of the usual AJAX call
68
+ if( isset( $_POST['videoTimes'] ) ) {
69
+ $decoded_times = json_decode(urldecode($_POST['videoTimes']), true);
70
+
71
+ if ($decoded_times !== false) {
72
+ $_POST['videoTimes'] = $decoded_times;
73
+ }
74
  }
75
 
76
+ if( isset( $_POST['playlistItems'] ) ) {
77
+ $decoded_playlists = json_decode(urldecode($_POST['playlistItems']), true);
78
+
79
+ if ($decoded_playlists !== false) {
80
+ $_POST['playlistItems'] = $decoded_playlists;
81
+ }
82
  }
83
 
84
  $success = false;
models/video-encoder/class.fv-player-encoder-list-table.php CHANGED
@@ -252,7 +252,13 @@ class FV_Player_Encoder_List_Table extends WP_List_Table {
252
 
253
  private function get_result_counts() {
254
  global $wpdb;
255
- $this->total_items = $wpdb->get_var( "SELECT COUNT(*) FROM ".$this->table_name );
 
 
 
 
 
 
256
  }
257
 
258
  public function get_columns() {
252
 
253
  private function get_result_counts() {
254
  global $wpdb;
255
+
256
+ $aWhere = array();
257
+ $aWhere[] = "type = '{$this->encoder_id}'";
258
+
259
+ $where = count($aWhere) ? " WHERE ".implode( " AND ", $aWhere ) : "";
260
+
261
+ $this->total_items = $wpdb->get_var( "SELECT COUNT(*) FROM ".$this->table_name." ".$where );
262
  }
263
 
264
  public function get_columns() {
models/video-encoder/video-encoder.php CHANGED
@@ -7,7 +7,7 @@ abstract class FV_Player_Video_Encoder {
7
  $encoder_wp_url_slug = '', // used in all links that will point to the list of this encoder jobs
8
  // examples: fv_player_coconut, fv_player_bunny_stream ...
9
  $encoder_name = '', // used to display name of the service where appropriate (mostly information DIVs in a HTML output)
10
- // examples: Coconut, Bunny.net Stream ...
11
  $instance = null, // self-explanatory
12
  $admin_page = false, // will be set to a real admin submenu page object once created
13
  $browser_inc_file = ''; // the full inclusion path for this Encoder's browser PHP backend file, so we can include_once() it
@@ -164,7 +164,13 @@ abstract class FV_Player_Video_Encoder {
164
  */
165
  public function admin_enqueue_editor_scripts($page) {
166
  if( $page == 'post.php' || $page == 'post-new.php' || $page == 'toplevel_page_fv_player' ) {
167
- wp_enqueue_script('fvplayer-shortcode-editor-' . $this->encoder_id, plugins_url( 'js/shortcode-editor.js', $this->getFILE() ), array('jquery', 'fvwpflowplayer-shortcode-editor'), $this->version );
 
 
 
 
 
 
168
  }
169
  }
170
 
@@ -189,6 +195,16 @@ abstract class FV_Player_Video_Encoder {
189
 
190
  return $response;
191
  }
 
 
 
 
 
 
 
 
 
 
192
 
193
  /**
194
  * Returns augmented arguments array for the category picker with the option for "checked_ontop" set to FALSE.
@@ -406,9 +422,9 @@ abstract class FV_Player_Video_Encoder {
406
  */
407
  function init_browser() {
408
  // it should not show when picking the media file in dashboard
409
- if( empty( $_GET['page'] ) || strcmp( $_GET['page'], $this->encoder_wp_url_slug ) != 0 ) {
410
  include_once( $this->browser_inc_file );
411
- }
412
  }
413
 
414
  /**
@@ -453,6 +469,10 @@ abstract class FV_Player_Video_Encoder {
453
  global $wpdb;
454
 
455
  $ids = array();
 
 
 
 
456
  $pending_jobs = $wpdb->get_results( "SELECT * FROM ". $this->table_name . " WHERE type = '{$this->encoder_id}' AND status = 'processing'" . ( $all ? '' : ' AND date_checked < DATE_SUB( UTC_TIMESTAMP(), INTERVAL 30 SECOND )' ) );
457
 
458
  foreach( $pending_jobs AS $pending_job ) {
@@ -722,9 +742,12 @@ abstract class FV_Player_Video_Encoder {
722
  */
723
  public function admin_enqueue_scripts( $page ) {
724
  if( $page == 'post.php' || $page == 'post-new.php' || $page == 'toplevel_page_fv_player' || $page == 'settings_page_fvplayer' || $page == 'fv-player_page_' . $this->encoder_wp_url_slug ) {
725
- wp_register_script('fv_player_' . $this->encoder_id . '_admin', plugins_url( 'js/admin.js', $this->getFILE() ), array('jquery'), filemtime( dirname( $this->getFILE() ) . '/js/admin.js') );
726
- wp_enqueue_script('fv_player_' . $this->encoder_id . '_admin');
727
- wp_localize_script( 'fv_player_' . $this->encoder_id . '_admin', $this->encoder_id . '_pending_jobs', $this->jobs_check(true) );
 
 
 
728
  }
729
  }
730
 
@@ -907,7 +930,7 @@ abstract class FV_Player_Video_Encoder {
907
  KEY source (source(191)),
908
  KEY type (type),
909
  KEY status (status),
910
- KEY job_id (job_id(15)),
911
  )" . $wpdb->get_charset_collate() . ";";
912
 
913
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
7
  $encoder_wp_url_slug = '', // used in all links that will point to the list of this encoder jobs
8
  // examples: fv_player_coconut, fv_player_bunny_stream ...
9
  $encoder_name = '', // used to display name of the service where appropriate (mostly information DIVs in a HTML output)
10
+ // examples: Coconut, Bunny Stream ...
11
  $instance = null, // self-explanatory
12
  $admin_page = false, // will be set to a real admin submenu page object once created
13
  $browser_inc_file = ''; // the full inclusion path for this Encoder's browser PHP backend file, so we can include_once() it
164
  */
165
  public function admin_enqueue_editor_scripts($page) {
166
  if( $page == 'post.php' || $page == 'post-new.php' || $page == 'toplevel_page_fv_player' ) {
167
+
168
+ $file = $this->locate_script('shortcode-editor.js');
169
+ if( $file ) {
170
+ $handle = 'fvplayer-shortcode-editor-' . $this->encoder_id;
171
+ wp_enqueue_script( $handle, plugins_url( $file, $this->getFILE() ), array('jquery'), filemtime( dirname( $this->getFILE() ) . $file), true );
172
+ }
173
+
174
  }
175
  }
176
 
195
 
196
  return $response;
197
  }
198
+
199
+ function locate_script( $script ) {
200
+ $file = false;
201
+ if( file_exists( dirname( $this->getFILE() ) . '/../js/'.$this->encoder_id.'-'.$script ) ) {
202
+ $file = '/../js/'.$this->encoder_id.'-'.$script;
203
+ } else if( file_exists( dirname( $this->getFILE() ).'/js/'.$script ) ) {
204
+ $file = '/js/'.$script;
205
+ }
206
+ return $file;
207
+ }
208
 
209
  /**
210
  * Returns augmented arguments array for the category picker with the option for "checked_ontop" set to FALSE.
422
  */
423
  function init_browser() {
424
  // it should not show when picking the media file in dashboard
425
+ //if( empty( $_GET['page'] ) || strcmp( $_GET['page'], $this->encoder_wp_url_slug ) != 0 ) {
426
  include_once( $this->browser_inc_file );
427
+ //}
428
  }
429
 
430
  /**
469
  global $wpdb;
470
 
471
  $ids = array();
472
+ if( $wpdb->get_var("SHOW TABLES LIKE '".$this->table_name."'") != $this->table_name ) {
473
+ return $ids;
474
+ }
475
+
476
  $pending_jobs = $wpdb->get_results( "SELECT * FROM ". $this->table_name . " WHERE type = '{$this->encoder_id}' AND status = 'processing'" . ( $all ? '' : ' AND date_checked < DATE_SUB( UTC_TIMESTAMP(), INTERVAL 30 SECOND )' ) );
477
 
478
  foreach( $pending_jobs AS $pending_job ) {
742
  */
743
  public function admin_enqueue_scripts( $page ) {
744
  if( $page == 'post.php' || $page == 'post-new.php' || $page == 'toplevel_page_fv_player' || $page == 'settings_page_fvplayer' || $page == 'fv-player_page_' . $this->encoder_wp_url_slug ) {
745
+ $file = $this->locate_script('admin.js');
746
+ if( $file ) {
747
+ $handle = 'fv_player_' . $this->encoder_id . '_admin';
748
+ wp_enqueue_script( $handle, plugins_url( $file, $this->getFILE() ), array('jquery'), filemtime( dirname( $this->getFILE() ) . $file), true );
749
+ wp_localize_script( $handle, $this->encoder_id . '_pending_jobs', $this->jobs_check(true) );
750
+ }
751
  }
752
  }
753
 
930
  KEY source (source(191)),
931
  KEY type (type),
932
  KEY status (status),
933
+ KEY job_id (job_id(15))
934
  )" . $wpdb->get_charset_collate() . ";";
935
 
936
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
readme.txt CHANGED
@@ -359,6 +359,13 @@ Thank you for being part of the HMTL 5 mobile video revolution!
359
 
360
  == Changelog ==
361
 
 
 
 
 
 
 
 
362
  = 7.5.12.727 - 2021/11/25 =
363
 
364
  * Bugfix - Playlist tabs not pausing the old tab player properly
359
 
360
  == Changelog ==
361
 
362
+ = 7.5.13.727 - 2021/12/20 =
363
+
364
+ * New feature - drag&drop video upload and encoding with the Bunny Stream service!
365
+ * New feature - Editor now detects the HLS stream type to show Live stream and Audio stream checkboxes only when needed
366
+ * Compatibility - Editor - jQuery 3.6 fixes
367
+ * Bugfix - Editor - prevent autosave attempt right after opening the editor
368
+
369
  = 7.5.12.727 - 2021/11/25 =
370
 
371
  * Bugfix - Playlist tabs not pausing the old tab player properly
view/bunny-stream-categories.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php // hide the "All Categories" and "Most Used" tabs as it's not important ?>
2
+ <style>
3
+ #fv_player_encoding_category-tabs {
4
+ display: none;
5
+ }
6
+ </style>
7
+
8
+ <?php
9
+ // we miss some of the code WP admin stuff here
10
+ if( !function_exists('post_categories_meta_box') ) {
11
+ require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' );
12
+ }
13
+ wp_enqueue_script('post');
14
+
15
+ ob_start();
16
+ $fake_post = new stdClass;
17
+ $fake_post->ID = -1;
18
+ post_categories_meta_box( $fake_post, array( 'args' => array( 'taxonomy' => 'fv_player_encoding_category') ) );
19
+ $html = ob_get_clean();
20
+
21
+ $html = preg_replace( '~(<ul id="fv_player_encoding_categorychecklist".*?>)\s+(</ul>)~', '$1<li id="fv-player-coconut-category-nag">Add a category to keep your video files organized</li>$2', $html );
22
+
23
+ echo $html;
view/bunny-stream-settings.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $fv_fp;
3
+ ?>
4
+
5
+ <style>
6
+ .form-table tr > td:first-child {
7
+ width: 200px;
8
+ }
9
+ .regular-text {
10
+ width: 100%;
11
+ max-width: 50em;
12
+ }
13
+ .tabs-panel {
14
+ max-width: 48em;
15
+ }
16
+
17
+ </style>
18
+
19
+ <form method="POST">
20
+ <table class='form-table'>
21
+ <?php
22
+ $fv_fp->_get_input_text( array(
23
+ 'key' => array( 'bunny_stream', 'lib_id' ),
24
+ 'name' => __('Stream Library ID', 'fv-player-bunny_stream'),
25
+ 'class' => 'regular-text code'
26
+ ) );
27
+
28
+ $fv_fp->_get_input_text( array(
29
+ 'key' => array( 'bunny_stream', 'api_key' ),
30
+ 'name' => __('Stream Library API Key', 'fv-player-bunny_stream'),
31
+ 'class' => 'regular-text code'
32
+ ) );
33
+
34
+ $fv_fp->_get_input_text( array(
35
+ 'key' => array( 'bunny_stream', 'cdn_hostname' ),
36
+ 'name' => __('Stream Library CDN Hostname', 'fv-player-bunny_stream'),
37
+ 'class' => 'regular-text code'
38
+ ) );
39
+ ?>
40
+ <tr>
41
+ <td></td>
42
+ <td>
43
+ <?php wp_nonce_field( 'fv_player_bunny_stream_settings_nonce', 'fv_player_bunny_stream_settings_nonce' ); ?>
44
+ <input type="submit" class="button button-primary" value="Save" />
45
+ </td>
46
+ </tr>
47
+ </table>
48
+ </form>
view/wizard.php CHANGED
@@ -128,7 +128,7 @@ var fv_Player_site_base = '<?php echo home_url('/') ?>';
128
 
129
  <div id="fv-player-editor-message-overlay" class="fv-player-editor-overlay">
130
  <p></p>
131
- <a id="fv-player-editor-overlay-close" href="#" value="Close" class="button button-primary">Close</a>
132
  </div>
133
 
134
  <div id="fv-player-editor-copy_player-overlay" class="fv-player-editor-overlay">
@@ -136,7 +136,7 @@ var fv_Player_site_base = '<?php echo home_url('/') ?>';
136
  <option hidden disabled selected value>Choose a Player...</option>
137
  </select>
138
 
139
- <a id="fv-player-editor-overlay-close" href="#" class="button">Close</a>
140
  </div>
141
 
142
  <div id="fv-player-editor-import-overlay" class="fv-player-editor-overlay">
@@ -144,7 +144,7 @@ var fv_Player_site_base = '<?php echo home_url('/') ?>';
144
  <br />
145
  <br />
146
  <a id="fv-player-editor-import-overlay-import" href="#" class="button button-primary">Import player</a>
147
- <a id="fv-player-editor-overlay-close" href="#" class="button">Close</a>
148
  <div class="fv-player-editor-overlay-notice"></div>
149
  </div>
150
 
@@ -152,8 +152,8 @@ var fv_Player_site_base = '<?php echo home_url('/') ?>';
152
  <textarea name="fv_player_copy_to_clipboard" rows="13"></textarea>
153
  <br />
154
  <br />
155
- <a id="fv-player-editor-export-overlay-copy" href="#" class="button button-primary">Copy To Clipboard</a>
156
- <a id="fv-player-editor-overlay-close" href="#" class="button">Close</a>
157
  <div class="fv-player-editor-overlay-notice"></div>
158
  </div>
159
 
@@ -162,8 +162,8 @@ var fv_Player_site_base = '<?php echo home_url('/') ?>';
162
  <textarea name="fv_player_copy_to_clipboard" rows="15"></textarea>
163
  <br />
164
  <br />
165
- <a id="fv-player-editor-export-overlay-copy" href="#" class="button button-primary">Copy To Clipboard</a>
166
- <a id="fv-player-editor-overlay-close" href="#" class="button button-primary">Close</a>
167
  <div class="fv-player-editor-overlay-notice"></div>
168
  </div>
169
 
@@ -306,7 +306,7 @@ var fv_Player_site_base = '<?php echo home_url('/') ?>';
306
  <td class="field"><div class="add_rtmp_wrapper"><a href="#" class="partial-underline" style="outline: 0"><span id="add-rtmp">+</span>&nbsp;<?php _e('Add RTMP', 'fv_flowplayer'); ?></a></div></td>
307
  </tr>
308
 
309
- <tr <?php if( !isset($fv_flowplayer_conf["interface"]["mobile"]) || $fv_flowplayer_conf["interface"]["mobile"] !== 'true' ) echo ' class="fv_player_interface_hide"'; ?> class="first-item-only">
310
  <th scope="row" class="label"><label for="fv_wp_flowplayer_field_mobile" class="alignright"><?php _e('Mobile video', 'fv_flowplayer'); ?></label></th>
311
  <td class="field" colspan="2"><input type="text" class="text<?php echo $upload_field_class; ?>" id="fv_wp_flowplayer_field_mobile" name="fv_wp_flowplayer_field_mobile" value="" placeholder="<?php _e('Put low-bandwidth video here or leave blank', 'fv_flowplayer'); ?>" />
312
  <?php if ($allow_uploads == 'true') { ?>
@@ -375,7 +375,7 @@ var fv_Player_site_base = '<?php echo home_url('/') ?>';
375
  <td class="field fv-fp-subtitles" colspan="2">
376
  <div class="fv-fp-subtitle">
377
  <select class="fv_wp_flowplayer_field_subtitles_lang" name="fv_wp_flowplayer_field_subtitles_lang">
378
- <option></option>
379
  <?php
380
  $aLanguages = flowplayer::get_languages();
381
  $aCurrent = explode('-', get_bloginfo('language'));
@@ -402,7 +402,7 @@ var fv_Player_site_base = '<?php echo home_url('/') ?>';
402
  <td colspan="2">
403
  </td>
404
  <td>
405
- <a class="fv_flowplayer_language_add_link" style="outline: 0" class="partial-underline" href="#"><span class="add-subtitle-lang">+</span>&nbsp;<?php _e('Add Another Language', 'fv_flowplayer'); ?></a>
406
  </td>
407
  </tr>
408
  </table>
@@ -415,7 +415,7 @@ var fv_Player_site_base = '<?php echo home_url('/') ?>';
415
  <th>
416
  <label for="fv_wp_flowplayer_field_width" class="alignright"><?php _e('Size', 'fv_flowplayer'); ?></label>
417
  </th>
418
- <td class="field" colspan="2">
419
  <input type="text" id="fv_wp_flowplayer_field_width" class="fv_wp_flowplayer_field_width" name="fv_wp_flowplayer_field_width" style="width: 19%; margin-right: 25px;" value="" placeholder="<?php _e('Width', 'fv_flowplayer'); ?>"/>
420
  <input type="text" id="fv_wp_flowplayer_field_height" class="fv_wp_flowplayer_field_height" name="fv_wp_flowplayer_field_height" style="width: 19%" value="" placeholder="<?php _e('Height', 'fv_flowplayer'); ?>"/>
421
  </td>
@@ -436,7 +436,7 @@ var fv_Player_site_base = '<?php echo home_url('/') ?>';
436
  array('season','Season'),
437
  array('polaroid','Polaroid'),
438
  array('text','Text')
439
- ), 'class' => 'hide-if-singular', 'id' => 'fv_wp_flowplayer_add_format_wrapper' ) );
440
  ?>
441
  <?php fv_player_shortcode_row( array( 'label' => 'Sharing Buttons', 'name' => 'share', 'dropdown' => array( 'Default', 'Yes', 'No', 'Custom' ) ) ); ?>
442
 
@@ -481,8 +481,8 @@ var fv_Player_site_base = '<?php echo home_url('/') ?>';
481
  <td>
482
  <?php fv_flowplayer_admin_select_popups(array('id' => 'fv_wp_flowplayer_field_popup_id', 'show_default' => true)) ?>
483
  <div style="display: none">
484
- <p><span class="dashicons dashicons-warning"></span> <?php _e('You are using the legacy popup functionality. Move the popup code', 'fv-wordpress-flowplayer'); ?> <a href="<?php echo site_url(); ?>/wp-admin/options-general.php?page=fvplayer#tab_popups" target="_target"><?php _e('here', 'fv-wordpress-flowplayer'); ?></a><?php _e(', then use the drop down menu above.', 'fv-wordpress-flowplayer'); ?></p>
485
- <textarea type="text" id="fv_wp_flowplayer_field_popup" name="fv_wp_flowplayer_field_popup" style="width: 93%"></textarea>
486
  </div>
487
  </td>
488
  </tr>
@@ -508,12 +508,12 @@ var fv_Player_site_base = '<?php echo home_url('/') ?>';
508
  <tr <?php if( !isset($fv_flowplayer_conf["interface"]["ads"]) || $fv_flowplayer_conf["interface"]["ads"] !== 'true' ) echo ' class="fv_player_interface_hide"'; ?>>
509
  <th scope="row" class="label"><label for="fv_wp_flowplayer_field_ad" class="alignright"><?php _e('Ad code', 'fv_flowplayer'); ?></label></th>
510
  <td>
511
- <textarea type="text" id="fv_wp_flowplayer_field_ad" name="fv_wp_flowplayer_field_ad" style="width: 93%"></textarea>
512
  </td>
513
  </tr>
514
  <tr <?php if( !isset($fv_flowplayer_conf["interface"]["ads"]) || $fv_flowplayer_conf["interface"]["ads"] !== 'true' ) echo ' class="fv_player_interface_hide"'; ?>>
515
  <th scope="row" class="label"><label for="fv_wp_flowplayer_field_liststyle" class="alignright"><?php _e('Ad Size', 'fv_flowplayer'); ?></label></th>
516
- <td class="field" <?php if( !isset($fv_flowplayer_conf["interface"]["ads"]) || $fv_flowplayer_conf["interface"]["ads"] !== 'true' ) echo ' class="fv_player_interface_hide"'; ?>>
517
  <input type="text" id="fv_wp_flowplayer_field_ad_width" name="fv_wp_flowplayer_field_ad_width" style="width: 19%; margin-right: 25px;" value="" placeholder="<?php _e('Width', 'fv_flowplayer'); ?>"/>
518
  <input type="text" id="fv_wp_flowplayer_field_ad_height" name="fv_wp_flowplayer_field_ad_height" style="width: 19%; margin-right: 25px;" value="" placeholder="<?php _e('Height', 'fv_flowplayer'); ?>"/>
519
  <input type="checkbox" id="fv_wp_flowplayer_field_ad_skip" name="fv_wp_flowplayer_field_ad_skip" /> <?php _e('Skip global ad in this video', 'fv_flowplayer'); ?>
128
 
129
  <div id="fv-player-editor-message-overlay" class="fv-player-editor-overlay">
130
  <p></p>
131
+ <a data-fv-player-editor-overlay-close href="#" class="button button-primary">Close</a>
132
  </div>
133
 
134
  <div id="fv-player-editor-copy_player-overlay" class="fv-player-editor-overlay">
136
  <option hidden disabled selected value>Choose a Player...</option>
137
  </select>
138
 
139
+ <a data-fv-player-editor-overlay-close href="#" class="button">Close</a>
140
  </div>
141
 
142
  <div id="fv-player-editor-import-overlay" class="fv-player-editor-overlay">
144
  <br />
145
  <br />
146
  <a id="fv-player-editor-import-overlay-import" href="#" class="button button-primary">Import player</a>
147
+ <a data-fv-player-editor-overlay-close href="#" class="button">Close</a>
148
  <div class="fv-player-editor-overlay-notice"></div>
149
  </div>
150
 
152
  <textarea name="fv_player_copy_to_clipboard" rows="13"></textarea>
153
  <br />
154
  <br />
155
+ <a data-fv-player-editor-export-overlay-copy href="#" class="button button-primary">Copy To Clipboard</a>
156
+ <a data-fv-player-editor-overlay-close href="#" class="button">Close</a>
157
  <div class="fv-player-editor-overlay-notice"></div>
158
  </div>
159
 
162
  <textarea name="fv_player_copy_to_clipboard" rows="15"></textarea>
163
  <br />
164
  <br />
165
+ <a data-fv-player-editor-export-overlay-copy href="#" class="button button-primary">Copy To Clipboard</a>
166
+ <a data-fv-player-editor-overlay-close href="#" class="button button-primary">Close</a>
167
  <div class="fv-player-editor-overlay-notice"></div>
168
  </div>
169
 
306
  <td class="field"><div class="add_rtmp_wrapper"><a href="#" class="partial-underline" style="outline: 0"><span id="add-rtmp">+</span>&nbsp;<?php _e('Add RTMP', 'fv_flowplayer'); ?></a></div></td>
307
  </tr>
308
 
309
+ <tr class="first-item-only<?php if( !isset($fv_flowplayer_conf["interface"]["mobile"]) || $fv_flowplayer_conf["interface"]["mobile"] !== 'true' ) echo ' fv_player_interface_hide'; ?>">
310
  <th scope="row" class="label"><label for="fv_wp_flowplayer_field_mobile" class="alignright"><?php _e('Mobile video', 'fv_flowplayer'); ?></label></th>
311
  <td class="field" colspan="2"><input type="text" class="text<?php echo $upload_field_class; ?>" id="fv_wp_flowplayer_field_mobile" name="fv_wp_flowplayer_field_mobile" value="" placeholder="<?php _e('Put low-bandwidth video here or leave blank', 'fv_flowplayer'); ?>" />
312
  <?php if ($allow_uploads == 'true') { ?>
375
  <td class="field fv-fp-subtitles" colspan="2">
376
  <div class="fv-fp-subtitle">
377
  <select class="fv_wp_flowplayer_field_subtitles_lang" name="fv_wp_flowplayer_field_subtitles_lang">
378
+ <option value="">&nbsp;</option>
379
  <?php
380
  $aLanguages = flowplayer::get_languages();
381
  $aCurrent = explode('-', get_bloginfo('language'));
402
  <td colspan="2">
403
  </td>
404
  <td>
405
+ <a class="fv_flowplayer_language_add_link partial-underline" style="outline: 0" href="#"><span class="add-subtitle-lang">+</span>&nbsp;<?php _e('Add Another Language', 'fv_flowplayer'); ?></a>
406
  </td>
407
  </tr>
408
  </table>
415
  <th>
416
  <label for="fv_wp_flowplayer_field_width" class="alignright"><?php _e('Size', 'fv_flowplayer'); ?></label>
417
  </th>
418
+ <td class="field">
419
  <input type="text" id="fv_wp_flowplayer_field_width" class="fv_wp_flowplayer_field_width" name="fv_wp_flowplayer_field_width" style="width: 19%; margin-right: 25px;" value="" placeholder="<?php _e('Width', 'fv_flowplayer'); ?>"/>
420
  <input type="text" id="fv_wp_flowplayer_field_height" class="fv_wp_flowplayer_field_height" name="fv_wp_flowplayer_field_height" style="width: 19%" value="" placeholder="<?php _e('Height', 'fv_flowplayer'); ?>"/>
421
  </td>
436
  array('season','Season'),
437
  array('polaroid','Polaroid'),
438
  array('text','Text')
439
+ ), 'class' => 'hide-if-singular' ) );
440
  ?>
441
  <?php fv_player_shortcode_row( array( 'label' => 'Sharing Buttons', 'name' => 'share', 'dropdown' => array( 'Default', 'Yes', 'No', 'Custom' ) ) ); ?>
442
 
481
  <td>
482
  <?php fv_flowplayer_admin_select_popups(array('id' => 'fv_wp_flowplayer_field_popup_id', 'show_default' => true)) ?>
483
  <div style="display: none">
484
+ <p><span class="dashicons dashicons-warning"></span> <?php _e('You are using the legacy popup functionality. Move the popup code', 'fv-wordpress-flowplayer'); ?> <a href="<?php echo site_url(); ?>/wp-admin/options-general.php?page=fvplayer#tab_popups" target="_blank"><?php _e('here', 'fv-wordpress-flowplayer'); ?></a><?php _e(', then use the drop down menu above.', 'fv-wordpress-flowplayer'); ?></p>
485
+ <textarea id="fv_wp_flowplayer_field_popup" name="fv_wp_flowplayer_field_popup" style="width: 93%"></textarea>
486
  </div>
487
  </td>
488
  </tr>
508
  <tr <?php if( !isset($fv_flowplayer_conf["interface"]["ads"]) || $fv_flowplayer_conf["interface"]["ads"] !== 'true' ) echo ' class="fv_player_interface_hide"'; ?>>
509
  <th scope="row" class="label"><label for="fv_wp_flowplayer_field_ad" class="alignright"><?php _e('Ad code', 'fv_flowplayer'); ?></label></th>
510
  <td>
511
+ <textarea id="fv_wp_flowplayer_field_ad" name="fv_wp_flowplayer_field_ad" style="width: 93%"></textarea>
512
  </td>
513
  </tr>
514
  <tr <?php if( !isset($fv_flowplayer_conf["interface"]["ads"]) || $fv_flowplayer_conf["interface"]["ads"] !== 'true' ) echo ' class="fv_player_interface_hide"'; ?>>
515
  <th scope="row" class="label"><label for="fv_wp_flowplayer_field_liststyle" class="alignright"><?php _e('Ad Size', 'fv_flowplayer'); ?></label></th>
516
+ <td class="field<?php if( !isset($fv_flowplayer_conf["interface"]["ads"]) || $fv_flowplayer_conf["interface"]["ads"] !== 'true' ) echo ' fv_player_interface_hide'; ?>">
517
  <input type="text" id="fv_wp_flowplayer_field_ad_width" name="fv_wp_flowplayer_field_ad_width" style="width: 19%; margin-right: 25px;" value="" placeholder="<?php _e('Width', 'fv_flowplayer'); ?>"/>
518
  <input type="text" id="fv_wp_flowplayer_field_ad_height" name="fv_wp_flowplayer_field_ad_height" style="width: 19%; margin-right: 25px;" value="" placeholder="<?php _e('Height', 'fv_flowplayer'); ?>"/>
519
  <input type="checkbox" id="fv_wp_flowplayer_field_ad_skip" name="fv_wp_flowplayer_field_ad_skip" /> <?php _e('Skip global ad in this video', 'fv_flowplayer'); ?>