Music Player for WooCommerce - Version 1.0.171

Version Description

  • Improves the fade-out effect and the module that calculates the duration of audios.
Download this release

Release Info

Developer codepeople
Plugin Icon 128x128 Music Player for WooCommerce
Version 1.0.171
Comparing to
See all releases

Code changes from version 1.0.170 to 1.0.171

Files changed (4) hide show
  1. js/public.js +14 -13
  2. js/public_src.js +35 -20
  3. readme.txt +5 -1
  4. wcmp.php +2 -2
js/public.js CHANGED
@@ -1,13 +1,14 @@
1
- var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(b,f,e){b instanceof String&&(b=String(b));for(var g=b.length,h=0;h<g;h++){var c=b[h];if(f.call(e,c,h,b))return{i:h,v:c}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;
2
- $jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(b,f,e){b!=Array.prototype&&b!=Object.prototype&&(b[f]=e.value)};$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global&&null!=global?global:b};$jscomp.global=$jscomp.getGlobal(this);
3
- $jscomp.polyfill=function(b,f,e,g){if(f){e=$jscomp.global;b=b.split(".");for(g=0;g<b.length-1;g++){var h=b[g];h in e||(e[h]={});e=e[h]}b=b[b.length-1];g=e[b];f=f(g);f!=g&&null!=f&&$jscomp.defineProperty(e,b,{configurable:!0,writable:!0,value:f})}};$jscomp.polyfill("Array.prototype.find",function(b){return b?b:function(b,e){return $jscomp.findInternal(this,b,e).v}},"es6","es3");
4
- (function(){var b=[],f=0;window.generate_the_wcmp=function(e){function g(a,l){if(a+1<f||l){var d=a+1;!l||d!=f&&0!=c('[playernumber="'+d+'"]').closest("[data-loop]").length&&c('[playernumber="'+d+'"]').closest("[data-loop]")[0]==c('[playernumber="'+a+'"]').closest("[data-loop]")[0]||(d=c('[playernumber="'+a+'"]').closest("[data-loop]").find("[playernumber]:first").attr("playernumber"));b[d]instanceof c&&b[d].is("a")?b[d].is(":visible")?b[d].click():g(a+1,l):c(b[d].container).is(":visible")?b[d].play():
5
- g(a+1,l)}}function h(a){var b=a.data("product"),d=c("img.product-"+b);d.length&&1==c('[data-product="'+b+'"]').length&&(b=d.offset(),a=a.closest("div.wcmp-player"),a.css({position:"absolute","z-index":999999}).offset({left:b.left+(d.width()-a.width())/2,top:b.top+(d.height()-a.height())/2}))}if(!("boolean"!==typeof e&&"undefined"!=typeof wcmp_global_settings&&1*wcmp_global_settings.onload)&&"undefined"===typeof generated_the_wcmp){generated_the_wcmp=!0;var c=jQuery;c(".wcmp-player-container").on("click",
6
- "*",function(a){a.preventDefault();a.stopPropagation();return!1});c.expr[":"].regex=function(a,b,d){b=d[3].split(",");var e=/^(data|css):/;d=b[0].match(e)?b[0].split(":")[0]:"attr";e=b.shift().replace(e,"");return(new RegExp(b.join("").replace(/^\s+|\s+$/g,""),"ig")).test(c(a)[d](e))};var q="undefined"!=typeof wcmp_global_settings?wcmp_global_settings.play_all:!0,k="undefined"!=typeof wcmp_global_settings?!(1*wcmp_global_settings.play_simultaneously):!0,n="undefined"!=typeof wcmp_global_settings?
7
- 1*wcmp_global_settings.fade_out:!0,p="undefined"!=typeof wcmp_global_settings&&"ios_controls"in wcmp_global_settings&&1*wcmp_global_settings.ios_controls?!0:!1;e=c("audio.wcmp-player:not(.track):not([playernumber])");var r=c("audio.wcmp-player.track:not([playernumber])"),m={pauseOtherPlayers:k,iPadUseNativeControls:p,iPhoneUseNativeControls:p,success:function(a,b){c(b).attr("volume")&&(a.setVolume(parseFloat(c(b).attr("volume"))),0==a.volume&&a.setMuted(!0));var d=function(a){var b=c(a).find("audio,video").data("duration");
8
- "undefined"!=typeof b&&c(a).closest(".wcmp-player-container").find(".mejs-duration").html(b)};a.addEventListener("timeupdate",function(b){d(a);isNaN(a.currentTime)||isNaN(a.duration)||(n&&4>a.duration-a.currentTime?a.setVolume(a.volume-a.volume/3):a.currentTime&&("undefined"==typeof a.bkVolume&&(a.bkVolume=parseFloat(c(a).find("audio,video").attr("volume")||a.volume)),a.setVolume(a.bkVolume),0==a.bkVolume&&a.setMuted(!0)))});a.addEventListener("volumechange",function(b){isNaN(a.currentTime)||isNaN(a.duration)||
9
- !(4<a.duration-a.currentTime)&&n||!a.currentTime||(a.bkVolume=a.volume)});a.addEventListener("ended",function(b){b=c(a).closest('[data-loop="1"]');if(1*q||b.length){var d=1*c(a).attr("playernumber");g(d,b.length)}});a.addEventListener("loadedmetadata",function(){d(a)})}};k=".product-type-grouped :regex(name,quantity\\[\\d+\\])";e.each(function(){var a=c(this);a.find("source").attr("src");a.attr("playernumber",f);m.audioVolume="vertical";try{b[f]=new MediaElementPlayer(a[0],m)}catch(l){"console"in
10
- window&&console.log(l)}f++});r.each(function(){var a=c(this);a.find("source").attr("src");a.attr("playernumber",f);m.features=["playpause"];try{b[f]=new MediaElementPlayer(a[0],m)}catch(l){"console"in window&&console.log(l)}f++;h(a);c(window).resize(function(){h(a)})});c(k).length||(k=".product-type-grouped [data-product_id]");c(k).length||(k=".woocommerce-grouped-product-list [data-product_id]");c(k).length||(k='.woocommerce-grouped-product-list [id*="product-"]');c(k).each(function(){try{var a=
11
- c(this),b=(a.data("product_id")||a.attr("name")||a.attr("id")).replace(/[^\d]/g,""),d=c(".wcmp-player-list.merge_in_grouped_products .product-"+b+":first .wcmp-player-title"),e=c("<table></table>");d.length&&!d.closest(".wcmp-first-in-product").length&&(d.closest("tr").addClass("wcmp-first-in-product"),0==d.closest("form").length&&d.closest(".wcmp-player-list").prependTo(a.closest("form")),e.append(a.closest("tr").prepend("<td>"+d.html()+"</td>")),d.html("").append(e))}catch(t){}})}};window.wcmp_force_init=
12
- function(){delete window.generated_the_wcmp;generate_the_wcmp(!0)};jQuery(generate_the_wcmp);jQuery(window).on("load",function(){generate_the_wcmp(!0);var b=jQuery,f=window.navigator.userAgent;b("[data-lazyloading]").each(function(){var e=b(this);e.attr("preload",e.data("lazyloading"))});if(f.match(/iPad/i)||f.match(/iPhone/i))if("undefined"!=typeof wcmp_global_settings?wcmp_global_settings.play_all:1)b(".wcmp-player .mejs-play button").one("click",function(){if("undefined"==typeof wcmp_preprocessed_players){wcmp_preprocessed_players=
13
- !0;var e=b(this);b(".wcmp-player audio").each(function(){this.play();this.pause()});setTimeout(function(){e.click()},500)}})}).on("popstate",function(){jQuery("audio[data-product]:not([playernumber])").length&&wcmp_force_init()});jQuery(document).on("scroll wpfAjaxSuccess woof_ajax_done yith-wcan-ajax-filtered wpf_ajax_success berocket_ajax_products_loaded berocket_ajax_products_infinite_loaded",wcmp_force_init)})();
 
1
+ var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,e,c){a instanceof String&&(a=String(a));for(var h=a.length,g=0;g<h;g++){var d=a[g];if(e.call(c,d,g,a))return{i:g,v:d}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;
2
+ $jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,e,c){a!=Array.prototype&&a!=Object.prototype&&(a[e]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
3
+ $jscomp.polyfill=function(a,e,c,h){if(e){c=$jscomp.global;a=a.split(".");for(h=0;h<a.length-1;h++){var g=a[h];g in c||(c[g]={});c=c[g]}a=a[a.length-1];h=c[a];e=e(h);e!=h&&null!=e&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:e})}};$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,c){return $jscomp.findInternal(this,a,c).v}},"es6","es3");
4
+ (function(){var a=[],e=0;window.generate_the_wcmp=function(c){function h(b,l){if(b+1<e||l){var f=b+1;!l||f!=e&&0!=d('[playernumber="'+f+'"]').closest("[data-loop]").length&&d('[playernumber="'+f+'"]').closest("[data-loop]")[0]==d('[playernumber="'+b+'"]').closest("[data-loop]")[0]||(f=d('[playernumber="'+b+'"]').closest("[data-loop]").find("[playernumber]:first").attr("playernumber"));a[f]instanceof d&&a[f].is("a")?a[f].is(":visible")?a[f].click():h(b+1,l):d(a[f].container).is(":visible")?a[f].play():
5
+ h(b+1,l)}}function g(b){var a=b.data("product"),f=d("img.product-"+a);f.length&&1==d('[data-product="'+a+'"]').length&&(a=f.offset(),b=b.closest("div.wcmp-player"),b.css({position:"absolute","z-index":999999}).offset({left:a.left+(f.width()-b.width())/2,top:a.top+(f.height()-b.height())/2}))}if(!("boolean"!==typeof c&&"undefined"!=typeof wcmp_global_settings&&1*wcmp_global_settings.onload)&&"undefined"===typeof generated_the_wcmp){generated_the_wcmp=!0;var d=jQuery;d(".wcmp-player-container").on("click",
6
+ "*",function(b){b.preventDefault();b.stopPropagation();return!1});d.expr[":"].regex=function(b,a,f){a=f[3].split(",");var c=/^(data|css):/;f=a[0].match(c)?a[0].split(":")[0]:"attr";c=a.shift().replace(c,"");return(new RegExp(a.join("").replace(/^\s+|\s+$/g,""),"ig")).test(d(b)[f](c))};var q="undefined"!=typeof wcmp_global_settings?wcmp_global_settings.play_all:!0,k="undefined"!=typeof wcmp_global_settings?!(1*wcmp_global_settings.play_simultaneously):!0,n="undefined"!=typeof wcmp_global_settings?
7
+ 1*wcmp_global_settings.fade_out:!0,p="undefined"!=typeof wcmp_global_settings&&"ios_controls"in wcmp_global_settings&&1*wcmp_global_settings.ios_controls?!0:!1;c=d("audio.wcmp-player:not(.track):not([playernumber])");var r=d("audio.wcmp-player.track:not([playernumber])"),m={pauseOtherPlayers:k,iPadUseNativeControls:p,iPhoneUseNativeControls:p,success:function(b,c){var f=d(c).data("duration"),e=d(c).data("estimated_duration"),g=d(c).attr("playernumber");"undefined"!=typeof e&&(b.getDuration=function(){return e});
8
+ "undefined"!=typeof f&&setTimeout(function(b,c){return function(){a[b].updateDuration=function(){d(this.media).closest(".wcmp-player").find(".mejs-duration").html(c)};a[b].updateDuration()}}(g,f),50);d(c).attr("volume")&&(b.setVolume(parseFloat(d(c).attr("volume"))),0==b.volume&&b.setMuted(!0));b.addEventListener("timeupdate",function(a){a=b.getDuration();isNaN(b.currentTime)||isNaN(a)||(n&&4>a-b.currentTime?b.setVolume(b.volume-b.volume/3):b.currentTime&&("undefined"==typeof b.bkVolume&&(b.bkVolume=
9
+ parseFloat(d(b).find("audio,video").attr("volume")||b.volume)),b.setVolume(b.bkVolume),0==b.bkVolume&&b.setMuted(!0)))});b.addEventListener("volumechange",function(a){a=b.getDuration();isNaN(b.currentTime)||isNaN(a)||!(4<a-b.currentTime)&&n||!b.currentTime||(b.bkVolume=b.volume)});b.addEventListener("ended",function(a){a=d(b).closest('[data-loop="1"]');b.currentTime=0;if(1*q||a.length){var c=1*d(b).attr("playernumber");isNaN(c)&&(c=1*d(b).find("[playernumber]").attr("playernumber"));h(c,a.length)}})}};
10
+ k=".product-type-grouped :regex(name,quantity\\[\\d+\\])";c.each(function(){var b=d(this);b.find("source").attr("src");b.attr("playernumber",e);m.audioVolume="vertical";try{a[e]=new MediaElementPlayer(b[0],m)}catch(l){"console"in window&&console.log(l)}e++});r.each(function(){var b=d(this);b.find("source").attr("src");b.attr("playernumber",e);m.features=["playpause"];try{a[e]=new MediaElementPlayer(b[0],m)}catch(l){"console"in window&&console.log(l)}e++;g(b);d(window).resize(function(){g(b)})});d(k).length||
11
+ (k=".product-type-grouped [data-product_id]");d(k).length||(k=".woocommerce-grouped-product-list [data-product_id]");d(k).length||(k='.woocommerce-grouped-product-list [id*="product-"]');d(k).each(function(){try{var b=d(this),a=(b.data("product_id")||b.attr("name")||b.attr("id")).replace(/[^\d]/g,""),c=d(".wcmp-player-list.merge_in_grouped_products .product-"+a+":first .wcmp-player-title"),e=d("<table></table>");c.length&&!c.closest(".wcmp-first-in-product").length&&(c.closest("tr").addClass("wcmp-first-in-product"),
12
+ 0==c.closest("form").length&&c.closest(".wcmp-player-list").prependTo(b.closest("form")),e.append(b.closest("tr").prepend("<td>"+c.html()+"</td>")),c.html("").append(e))}catch(t){}})}};window.wcmp_force_init=function(){delete window.generated_the_wcmp;generate_the_wcmp(!0)};jQuery(generate_the_wcmp);jQuery(window).on("load",function(){generate_the_wcmp(!0);var a=jQuery,e=window.navigator.userAgent;a("[data-lazyloading]").each(function(){var c=a(this);c.attr("preload",c.data("lazyloading"))});if(e.match(/iPad/i)||
13
+ e.match(/iPhone/i))if("undefined"!=typeof wcmp_global_settings?wcmp_global_settings.play_all:1)a(".wcmp-player .mejs-play button").one("click",function(){if("undefined"==typeof wcmp_preprocessed_players){wcmp_preprocessed_players=!0;var c=a(this);a(".wcmp-player audio").each(function(){this.play();this.pause()});setTimeout(function(){c.click()},500)}})}).on("popstate",function(){jQuery("audio[data-product]:not([playernumber])").length&&wcmp_force_init()});jQuery(document).on("scroll wpfAjaxSuccess woof_ajax_done yith-wcan-ajax-filtered wpf_ajax_success berocket_ajax_products_loaded berocket_ajax_products_infinite_loaded",
14
+ wcmp_force_init)})();
js/public_src.js CHANGED
@@ -93,27 +93,42 @@
93
  iPadUseNativeControls: ios_controls,
94
  iPhoneUseNativeControls: ios_controls,
95
  success: function( media, dom ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  if($(dom).attr('volume'))
97
  {
98
  media.setVolume(parseFloat($(dom).attr('volume')));
99
  if(media.volume == 0) media.setMuted(true);
100
  }
101
- var update_duration = function(t){
102
- var duration = $(t).find('audio,video').data('duration');
103
- if(typeof duration != 'undefined')
104
- {
105
- $(t).closest('.wcmp-player-container')
106
- .find('.mejs-duration')
107
- .html(duration);
108
- }
109
- };
110
 
111
  media.addEventListener( 'timeupdate', function( evt ){
112
- var e = media;
113
- update_duration(e);
114
- if(!isNaN( e.currentTime ) && !isNaN( e.duration ))
115
  {
116
- if( fade_out && e.duration - e.currentTime < 4 )
117
  {
118
  e.setVolume( e.volume - e.volume / 3 );
119
  }
@@ -132,26 +147,26 @@
132
  });
133
 
134
  media.addEventListener( 'volumechange', function( evt ){
135
- var e = media;
136
- if(!isNaN( e.currentTime ) && !isNaN( e.duration ))
137
  {
138
- if( ( e.duration - e.currentTime > 4 || !fade_out) && e.currentTime ) e[ 'bkVolume' ] = e.volume;
139
  }
140
  });
141
 
142
  media.addEventListener( 'ended', function( evt ){
143
  var e = media,
144
  c = $(e).closest('[data-loop="1"]');
 
 
145
  if( play_all*1 || c.length)
146
  {
147
  var playernumber = $(e).attr('playernumber')*1;
 
 
148
  _playNext( playernumber, c.length);
149
  }
150
  });
151
-
152
- media.addEventListener('loadedmetadata', function(){
153
- update_duration(media);
154
- });
155
  }
156
  },
157
  selector = '.product-type-grouped :regex(name,quantity\\[\\d+\\])';
93
  iPadUseNativeControls: ios_controls,
94
  iPhoneUseNativeControls: ios_controls,
95
  success: function( media, dom ){
96
+ var duration = $(dom).data('duration'),
97
+ estimated_duration = $(dom).data('estimated_duration'),
98
+ player_index = $(dom).attr('playernumber');
99
+
100
+ if(typeof estimated_duration != 'undefined')
101
+ {
102
+ media.getDuration = function(){
103
+ return estimated_duration;
104
+ };
105
+ }
106
+
107
+ if(typeof duration != 'undefined')
108
+ {
109
+ setTimeout((function(player_index, duration){
110
+ return function(){
111
+ wcmp_players[ player_index ].updateDuration = function(){
112
+ $(this.media).closest('.wcmp-player')
113
+ .find('.mejs-duration')
114
+ .html(duration);
115
+ };
116
+ wcmp_players[ player_index ].updateDuration();
117
+ };
118
+ })(player_index, duration), 50);
119
+ }
120
+
121
  if($(dom).attr('volume'))
122
  {
123
  media.setVolume(parseFloat($(dom).attr('volume')));
124
  if(media.volume == 0) media.setMuted(true);
125
  }
 
 
 
 
 
 
 
 
 
126
 
127
  media.addEventListener( 'timeupdate', function( evt ){
128
+ var e = media, duration = e.getDuration();
129
+ if(!isNaN( e.currentTime ) && !isNaN( duration ))
 
130
  {
131
+ if( fade_out && duration - e.currentTime < 4 )
132
  {
133
  e.setVolume( e.volume - e.volume / 3 );
134
  }
147
  });
148
 
149
  media.addEventListener( 'volumechange', function( evt ){
150
+ var e = media, duration = e.getDuration();
151
+ if(!isNaN( e.currentTime ) && !isNaN(duration ))
152
  {
153
+ if( ( duration - e.currentTime > 4 || !fade_out) && e.currentTime ) e[ 'bkVolume' ] = e.volume;
154
  }
155
  });
156
 
157
  media.addEventListener( 'ended', function( evt ){
158
  var e = media,
159
  c = $(e).closest('[data-loop="1"]');
160
+ e.currentTime = 0;
161
+
162
  if( play_all*1 || c.length)
163
  {
164
  var playernumber = $(e).attr('playernumber')*1;
165
+ if(isNaN(playernumber))
166
+ playernumber = $(e).find('[playernumber]').attr('playernumber')*1;
167
  _playNext( playernumber, c.length);
168
  }
169
  });
 
 
 
 
170
  }
171
  },
172
  selector = '.product-type-grouped :regex(name,quantity\\[\\d+\\])';
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: codepeople
3
  Donate link: https://wcmp.dwbooster.com
4
  Tags:WooCommerce,music player,audio,music,song,player,audio player,media player,mp3,m3u,m3u8,wav,oga,ogg,dokan,wcfm
5
  Requires at least: 3.5.0
6
- Tested up to: 5.9
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -226,6 +226,10 @@ Each time save the data of a product, the files for demo are deleted and generat
226
 
227
  == Changelog ==
228
 
 
 
 
 
229
  = 1.0.170 =
230
 
231
  * Fixes an issue with the volume when the default value is zero.
3
  Donate link: https://wcmp.dwbooster.com
4
  Tags:WooCommerce,music player,audio,music,song,player,audio player,media player,mp3,m3u,m3u8,wav,oga,ogg,dokan,wcfm
5
  Requires at least: 3.5.0
6
+ Tested up to: 6.0
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
226
 
227
  == Changelog ==
228
 
229
+ = 1.0.171 =
230
+
231
+ * Improves the fade-out effect and the module that calculates the duration of audios.
232
+
233
  = 1.0.170 =
234
 
235
  * Fixes an issue with the volume when the default value is zero.
wcmp.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Music Player for WooCommerce
4
  Plugin URI: https://wcmp.dwbooster.com
5
- Version: 1.0.170
6
  Text Domain: music-player-for-woocommerce
7
  Author: CodePeople
8
  Author URI: https://wcmp.dwbooster.com
@@ -433,7 +433,7 @@ if ( !class_exists( 'WooCommerceMusicPlayer' ) ) {
433
  wp_enqueue_style( 'wcmp-style', plugin_dir_url(__FILE__).'css/style.css' );
434
  wp_enqueue_script('jquery');
435
  wp_enqueue_script('wp-mediaelement');
436
- wp_enqueue_script('wcmp-script', plugin_dir_url(__FILE__).'js/public.js', array('jquery', 'wp-mediaelement'), '1.0.170');
437
 
438
  $play_all = $GLOBALS[ 'WooCommerceMusicPlayer' ]->get_global_attr(
439
  '_wcmp_play_all',
2
  /*
3
  Plugin Name: Music Player for WooCommerce
4
  Plugin URI: https://wcmp.dwbooster.com
5
+ Version: 1.0.171
6
  Text Domain: music-player-for-woocommerce
7
  Author: CodePeople
8
  Author URI: https://wcmp.dwbooster.com
433
  wp_enqueue_style( 'wcmp-style', plugin_dir_url(__FILE__).'css/style.css' );
434
  wp_enqueue_script('jquery');
435
  wp_enqueue_script('wp-mediaelement');
436
+ wp_enqueue_script('wcmp-script', plugin_dir_url(__FILE__).'js/public.js', array('jquery', 'wp-mediaelement'), '1.0.171');
437
 
438
  $play_all = $GLOBALS[ 'WooCommerceMusicPlayer' ]->get_global_attr(
439
  '_wcmp_play_all',