From d8ee6728ff31b77051317aaf471331f3a3868279 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Tue, 6 Feb 2018 12:13:56 +0100 Subject: [PATCH 1/5] fix: popups not being shown when a video has ad showing at the end --- flowplayer-beta/fv-flowplayer.min.js | 64 +++++++++++++++++++++++++--- flowplayer/fv-flowplayer.min.js | 2 +- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/flowplayer-beta/fv-flowplayer.min.js b/flowplayer-beta/fv-flowplayer.min.js index 5b617da9e..288c1d5cc 100644 --- a/flowplayer-beta/fv-flowplayer.min.js +++ b/flowplayer-beta/fv-flowplayer.min.js @@ -840,6 +840,9 @@ if( isIE11 ) { * Ads */ flowplayer(function (api,root) { + // last popup reference gets saved if a popup should be shown at the end of the video but an AD follows it + // ... in that case, we need to save this popup and show it after the AD itself + var last_popup = null; root = jQuery(root); if( root.data('end_popup_preview') ){ @@ -847,7 +850,7 @@ flowplayer(function (api,root) { api.trigger('finish', [ api] ); }); } - + var player_id = root.attr('id'); api.bind("ready", function (e, api) { //console.log('ad ready to show',root.attr('class')); @@ -857,12 +860,61 @@ flowplayer(function (api,root) { root.find('.fp-player').append( '
'+html+'
' ); } }).bind("finish", function (e, api) { - if( typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length ) { - if( root.find('.wpfp_custom_popup').length > 0) { - root.find('.wpfp_custom_popup').show(); - } else if( typeof(fv_flowplayer_popup) != "undefined" && typeof(fv_flowplayer_popup[player_id]) != "undefined" ) { - root.find('.fp-player').append( '
'+fv_flowplayer_popup[player_id].html+'
' ); + var + should_show_popup = (typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length), + $popup = root.find('.wpfp_custom_popup'); + + // show either existing or a previously stored popup (see comment on "last_popup" above for more info) + if ($popup.length || last_popup) { + // check if we should be showing the popup of saving it for later + if (should_show_popup) { + // there's an existing popup, so we just show it at the end of this video + if ($popup.length) { + setTimeout(function() { + $popup.on('click', function() { + flowplayer(document.getElementById(player_id)).play(); + }); + $popup.show(); + }, 1000); + } else { + // we have a cached popup from a previous video, which should be shown at the end of this AD + // ... we need to use setTimeout here, since the player will be stopped and popup removed after the "finish" event is done + setTimeout(function() { + root.find('.fp-player').append(last_popup); + last_popup.show(); + }, 1000); + } + } else { + // store a popup clone for later showing (see comment on "last_popup" above for more info) + last_popup = $popup.clone(); + last_popup.on('click', function() { + flowplayer(document.getElementById(player_id)).play(); + }); } + + } else if (typeof(fv_flowplayer_popup) != "undefined" && typeof(fv_flowplayer_popup[player_id]) != "undefined") { + // create a new popup and change the popup variable to point to a correct element + $popup = jQuery('
' + fv_flowplayer_popup[player_id].html + '
'); + + // check if we should be showing the popup of saving it for later + if (should_show_popup) { + // we need to use setTimeout here, since the player will be stopped and popup removed after the "finish" event is done + setTimeout(function() { + $popup.on('click', function() { + flowplayer(document.getElementById(player_id)).play(); + }); + root.find('.fp-player').append($popup); + }, 1000); + } else { + // store a popup clone for later showing (see comment on "last_popup" above for more info) + last_popup = $popup.clone(); + last_popup.on('click', function() { + flowplayer(document.getElementById(player_id)).play(); + }); + } + } else { + // no popups for this player, reset last_popup variable + last_popup = null; } }).bind("pause", function (e, api) { diff --git a/flowplayer/fv-flowplayer.min.js b/flowplayer/fv-flowplayer.min.js index cb4ffe4a3..a35821d4e 100644 --- a/flowplayer/fv-flowplayer.min.js +++ b/flowplayer/fv-flowplayer.min.js @@ -750,7 +750,7 @@ flowplayer( function(api,root) { }, 100 ); }); - api.bind('finish', function() { + api.bind('finish', function() { if( root.data('fv_redirect') ) { var url = root.data('fv_redirect'); var windowFVFlowplayerRedirect = window.open(url, '_blank'); From 6cc9ca3c540bda350941c59a1405ee9f7f3c54ad Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Tue, 6 Feb 2018 13:34:27 +0100 Subject: [PATCH 2/5] chore: this should probably be in the release branch, too --- flowplayer/fv-flowplayer.min.js | 62 ++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/flowplayer/fv-flowplayer.min.js b/flowplayer/fv-flowplayer.min.js index a35821d4e..5717c26cc 100644 --- a/flowplayer/fv-flowplayer.min.js +++ b/flowplayer/fv-flowplayer.min.js @@ -831,6 +831,9 @@ if( isIE11 ) { * Ads */ flowplayer(function (api,root) { + // last popup reference gets saved if a popup should be shown at the end of the video but an AD follows it + // ... in that case, we need to save this popup and show it after the AD itself + var last_popup = null; root = jQuery(root); if( root.data('end_popup_preview') ){ @@ -848,12 +851,61 @@ flowplayer(function (api,root) { root.find('.fp-player').append( '
'+html+'
' ); } }).bind("finish", function (e, api) { - if( typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length ) { - if( root.find('.wpfp_custom_popup').length > 0) { - root.find('.wpfp_custom_popup').show(); - } else if( typeof(fv_flowplayer_popup) != "undefined" && typeof(fv_flowplayer_popup[player_id]) != "undefined" ) { - root.find('.fp-player').append( '
'+fv_flowplayer_popup[player_id].html+'
' ); + var + should_show_popup = (typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length), + $popup = root.find('.wpfp_custom_popup'); + + // show either existing or a previously stored popup (see comment on "last_popup" above for more info) + if ($popup.length || last_popup) { + // check if we should be showing the popup of saving it for later + if (should_show_popup) { + // there's an existing popup, so we just show it at the end of this video + if ($popup.length) { + setTimeout(function() { + $popup.on('click', function() { + flowplayer(document.getElementById(player_id)).play(); + }); + $popup.show(); + }, 1000); + } else { + // we have a cached popup from a previous video, which should be shown at the end of this AD + // ... we need to use setTimeout here, since the player will be stopped and popup removed after the "finish" event is done + setTimeout(function() { + root.find('.fp-player').append(last_popup); + last_popup.show(); + }, 1000); + } + } else { + // store a popup clone for later showing (see comment on "last_popup" above for more info) + last_popup = $popup.clone(); + last_popup.on('click', function() { + flowplayer(document.getElementById(player_id)).play(); + }); + } + + } else if (typeof(fv_flowplayer_popup) != "undefined" && typeof(fv_flowplayer_popup[player_id]) != "undefined") { + // create a new popup and change the popup variable to point to a correct element + $popup = jQuery('
' + fv_flowplayer_popup[player_id].html + '
'); + + // check if we should be showing the popup of saving it for later + if (should_show_popup) { + // we need to use setTimeout here, since the player will be stopped and popup removed after the "finish" event is done + setTimeout(function() { + $popup.on('click', function() { + flowplayer(document.getElementById(player_id)).play(); + }); + root.find('.fp-player').append($popup); + }, 1000); + } else { + // store a popup clone for later showing (see comment on "last_popup" above for more info) + last_popup = $popup.clone(); + last_popup.on('click', function() { + flowplayer(document.getElementById(player_id)).play(); + }); } + } else { + // no popups for this player, reset last_popup variable + last_popup = null; } }).bind("pause", function (e, api) { From 4cc84a0272cbeb843136b3186ad0784478cbcb4c Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Tue, 6 Feb 2018 13:46:27 +0100 Subject: [PATCH 3/5] fix: PPV popup not shown when AD follows the preview video --- flowplayer-beta/fv-flowplayer.min.js | 5 ++++- flowplayer/fv-flowplayer.min.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/flowplayer-beta/fv-flowplayer.min.js b/flowplayer-beta/fv-flowplayer.min.js index 288c1d5cc..eb136fa3a 100644 --- a/flowplayer-beta/fv-flowplayer.min.js +++ b/flowplayer-beta/fv-flowplayer.min.js @@ -860,6 +860,7 @@ flowplayer(function (api,root) { root.find('.fp-player').append( '
'+html+'
' ); } }).bind("finish", function (e, api) { + console.log('aa'); var should_show_popup = (typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length), $popup = root.find('.wpfp_custom_popup'); @@ -920,10 +921,12 @@ flowplayer(function (api,root) { }).bind("pause", function (e, api) { // NOTE: this feature is for showing a Pay Per View purchase popup, when the PPV plugin is enabled, // it does nothing with ads or other popups! - if( typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length ) { + if( typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length || api.video.index+2 == api.conf.playlist.length ) { if( root.find('.wpfp_custom_popup').length > 0 && root.find('.wpfp_custom_popup > .fv-player-ppv-purchase-btn-wrapper')) { + console.log('001'); root.find('.wpfp_custom_popup').show(); } else if( typeof(fv_flowplayer_popup) != "undefined" && typeof(fv_flowplayer_popup[player_id]) != "undefined" && fv_flowplayer_popup[player_id].html.indexOf('fv-player-ppv-purchase-btn-wrapper') > -1 ) { + console.log('002'); root.find('.fp-player').append( '
'+fv_flowplayer_popup[player_id].html+'
' ); } } diff --git a/flowplayer/fv-flowplayer.min.js b/flowplayer/fv-flowplayer.min.js index 5717c26cc..ef8f334b6 100644 --- a/flowplayer/fv-flowplayer.min.js +++ b/flowplayer/fv-flowplayer.min.js @@ -911,7 +911,7 @@ flowplayer(function (api,root) { }).bind("pause", function (e, api) { // NOTE: this feature is for showing a Pay Per View purchase popup, when the PPV plugin is enabled, // it does nothing with ads or other popups! - if( typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length ) { + if( typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length || api.video.index+2 == api.conf.playlist.length ) { if( root.find('.wpfp_custom_popup').length > 0 && root.find('.wpfp_custom_popup > .fv-player-ppv-purchase-btn-wrapper')) { root.find('.wpfp_custom_popup').show(); } else if( typeof(fv_flowplayer_popup) != "undefined" && typeof(fv_flowplayer_popup[player_id]) != "undefined" && fv_flowplayer_popup[player_id].html.indexOf('fv-player-ppv-purchase-btn-wrapper') > -1 ) { From 3d9463e0902d041f9cb00367ed8779014e568e8b Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Tue, 6 Feb 2018 13:48:20 +0100 Subject: [PATCH 4/5] fix: forgotten debug logs --- flowplayer-beta/fv-flowplayer.min.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/flowplayer-beta/fv-flowplayer.min.js b/flowplayer-beta/fv-flowplayer.min.js index eb136fa3a..38ee9ad65 100644 --- a/flowplayer-beta/fv-flowplayer.min.js +++ b/flowplayer-beta/fv-flowplayer.min.js @@ -923,10 +923,8 @@ flowplayer(function (api,root) { // it does nothing with ads or other popups! if( typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length || api.video.index+2 == api.conf.playlist.length ) { if( root.find('.wpfp_custom_popup').length > 0 && root.find('.wpfp_custom_popup > .fv-player-ppv-purchase-btn-wrapper')) { - console.log('001'); root.find('.wpfp_custom_popup').show(); } else if( typeof(fv_flowplayer_popup) != "undefined" && typeof(fv_flowplayer_popup[player_id]) != "undefined" && fv_flowplayer_popup[player_id].html.indexOf('fv-player-ppv-purchase-btn-wrapper') > -1 ) { - console.log('002'); root.find('.fp-player').append( '
'+fv_flowplayer_popup[player_id].html+'
' ); } } From 8bdd2f419368de27867310c5ab4d7d2f5ed50aaa Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Tue, 13 Feb 2018 12:04:26 +0100 Subject: [PATCH 5/5] fix: not advancing further when popup is to be shown b4 the last AD --- flowplayer-beta/fv-flowplayer.min.js | 69 +++++----------------------- flowplayer/fv-flowplayer.min.js | 66 ++++---------------------- 2 files changed, 21 insertions(+), 114 deletions(-) diff --git a/flowplayer-beta/fv-flowplayer.min.js b/flowplayer-beta/fv-flowplayer.min.js index 38ee9ad65..390a4c84c 100644 --- a/flowplayer-beta/fv-flowplayer.min.js +++ b/flowplayer-beta/fv-flowplayer.min.js @@ -840,9 +840,6 @@ if( isIE11 ) { * Ads */ flowplayer(function (api,root) { - // last popup reference gets saved if a popup should be shown at the end of the video but an AD follows it - // ... in that case, we need to save this popup and show it after the AD itself - var last_popup = null; root = jQuery(root); if( root.data('end_popup_preview') ){ @@ -860,62 +857,13 @@ flowplayer(function (api,root) { root.find('.fp-player').append( '
'+html+'
' ); } }).bind("finish", function (e, api) { - console.log('aa'); - var - should_show_popup = (typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length), - $popup = root.find('.wpfp_custom_popup'); - - // show either existing or a previously stored popup (see comment on "last_popup" above for more info) - if ($popup.length || last_popup) { - // check if we should be showing the popup of saving it for later - if (should_show_popup) { - // there's an existing popup, so we just show it at the end of this video - if ($popup.length) { - setTimeout(function() { - $popup.on('click', function() { - flowplayer(document.getElementById(player_id)).play(); - }); - $popup.show(); - }, 1000); - } else { - // we have a cached popup from a previous video, which should be shown at the end of this AD - // ... we need to use setTimeout here, since the player will be stopped and popup removed after the "finish" event is done - setTimeout(function() { - root.find('.fp-player').append(last_popup); - last_popup.show(); - }, 1000); - } - } else { - // store a popup clone for later showing (see comment on "last_popup" above for more info) - last_popup = $popup.clone(); - last_popup.on('click', function() { - flowplayer(document.getElementById(player_id)).play(); - }); - } - - } else if (typeof(fv_flowplayer_popup) != "undefined" && typeof(fv_flowplayer_popup[player_id]) != "undefined") { - // create a new popup and change the popup variable to point to a correct element - $popup = jQuery('
' + fv_flowplayer_popup[player_id].html + '
'); - - // check if we should be showing the popup of saving it for later - if (should_show_popup) { - // we need to use setTimeout here, since the player will be stopped and popup removed after the "finish" event is done - setTimeout(function() { - $popup.on('click', function() { - flowplayer(document.getElementById(player_id)).play(); - }); - root.find('.fp-player').append($popup); - }, 1000); - } else { - // store a popup clone for later showing (see comment on "last_popup" above for more info) - last_popup = $popup.clone(); - last_popup.on('click', function() { - flowplayer(document.getElementById(player_id)).play(); - }); + if( typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length || api.video.index+2 == api.conf.playlist.length ) { + // just an ordinary popup + if (root.find('.wpfp_custom_popup').length > 0) { + root.find('.wpfp_custom_popup').show(); + } else if (typeof(fv_flowplayer_popup) != "undefined" && typeof(fv_flowplayer_popup[player_id]) != "undefined") { + root.find('.fp-player').append('
' + fv_flowplayer_popup[player_id].html + '
'); } - } else { - // no popups for this player, reset last_popup variable - last_popup = null; } }).bind("pause", function (e, api) { @@ -941,6 +889,11 @@ flowplayer(function (api,root) { next(); } );*/ } + + // do not advance to the last AD if there's a popup to be shown + if (api.video.index+2 == api.conf.playlist.length) { + api.conf.advance = false; + } }); }); diff --git a/flowplayer/fv-flowplayer.min.js b/flowplayer/fv-flowplayer.min.js index ef8f334b6..d413401db 100644 --- a/flowplayer/fv-flowplayer.min.js +++ b/flowplayer/fv-flowplayer.min.js @@ -831,9 +831,6 @@ if( isIE11 ) { * Ads */ flowplayer(function (api,root) { - // last popup reference gets saved if a popup should be shown at the end of the video but an AD follows it - // ... in that case, we need to save this popup and show it after the AD itself - var last_popup = null; root = jQuery(root); if( root.data('end_popup_preview') ){ @@ -851,61 +848,13 @@ flowplayer(function (api,root) { root.find('.fp-player').append( '
'+html+'
' ); } }).bind("finish", function (e, api) { - var - should_show_popup = (typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length), - $popup = root.find('.wpfp_custom_popup'); - - // show either existing or a previously stored popup (see comment on "last_popup" above for more info) - if ($popup.length || last_popup) { - // check if we should be showing the popup of saving it for later - if (should_show_popup) { - // there's an existing popup, so we just show it at the end of this video - if ($popup.length) { - setTimeout(function() { - $popup.on('click', function() { - flowplayer(document.getElementById(player_id)).play(); - }); - $popup.show(); - }, 1000); - } else { - // we have a cached popup from a previous video, which should be shown at the end of this AD - // ... we need to use setTimeout here, since the player will be stopped and popup removed after the "finish" event is done - setTimeout(function() { - root.find('.fp-player').append(last_popup); - last_popup.show(); - }, 1000); - } - } else { - // store a popup clone for later showing (see comment on "last_popup" above for more info) - last_popup = $popup.clone(); - last_popup.on('click', function() { - flowplayer(document.getElementById(player_id)).play(); - }); - } - + if( typeof(api.video.index) == "undefined" || api.video.index+1 == api.conf.playlist.length || api.video.index+2 == api.conf.playlist.length ) { + // just an ordinary popup + if (root.find('.wpfp_custom_popup').length > 0) { + root.find('.wpfp_custom_popup').show(); } else if (typeof(fv_flowplayer_popup) != "undefined" && typeof(fv_flowplayer_popup[player_id]) != "undefined") { - // create a new popup and change the popup variable to point to a correct element - $popup = jQuery('
' + fv_flowplayer_popup[player_id].html + '
'); - - // check if we should be showing the popup of saving it for later - if (should_show_popup) { - // we need to use setTimeout here, since the player will be stopped and popup removed after the "finish" event is done - setTimeout(function() { - $popup.on('click', function() { - flowplayer(document.getElementById(player_id)).play(); - }); - root.find('.fp-player').append($popup); - }, 1000); - } else { - // store a popup clone for later showing (see comment on "last_popup" above for more info) - last_popup = $popup.clone(); - last_popup.on('click', function() { - flowplayer(document.getElementById(player_id)).play(); - }); + root.find('.fp-player').append('
' + fv_flowplayer_popup[player_id].html + '
'); } - } else { - // no popups for this player, reset last_popup variable - last_popup = null; } }).bind("pause", function (e, api) { @@ -931,6 +880,11 @@ flowplayer(function (api,root) { next(); } );*/ } + + // do not advance to the last AD if there's a popup to be shown + if (api.video.index+2 == api.conf.playlist.length) { + api.conf.advance = false; + } }); });