Files
Testing/include/jplayer/examples/pink.flag/demo-01-android.html
sean 0e8a8b3028
Some checks failed
deploy-testing / deploy (push) Has been cancelled
Initial testing snapshot
2026-11-17 16:15:01 -05:00

217 lines
6.1 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!-- Website Design By: www.happyworm.com -->
<title>Demo : jPlayer Android Fix</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../../dist/skin/pink.flag/css/jplayer.pink.flag.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../lib/jquery.min.js"></script>
<script type="text/javascript" src="../../dist/jplayer/jquery.jplayer.min.js"></script>
<script type="text/javascript">
//<![CDATA[
// TMP For testing on standard browsers.
// $.jPlayer.platform.android = true;
var jPlayerAndroidFix = (function($) {
var fix = function(id, media, options) {
this.playFix = false;
this.init(id, media, options);
};
fix.prototype = {
init: function(id, media, options) {
var self = this;
// Store the params
this.id = id;
this.media = media;
this.options = options;
// Make a jQuery selector of the id, for use by the jPlayer instance.
this.player = $(this.id);
// Make the ready event to set the media to initiate.
this.player.bind($.jPlayer.event.ready, function(event) {
// Use this fix's setMedia() method.
self.setMedia(self.media);
});
// Apply Android fixes
if($.jPlayer.platform.android) {
// Fix playing new media immediately after setMedia.
this.player.bind($.jPlayer.event.progress, function(event) {
if(self.playFixRequired) {
self.playFixRequired = false;
// Enable the contols again
// self.player.jPlayer('option', 'cssSelectorAncestor', self.cssSelectorAncestor);
// Play if required, otherwise it will wait for the normal GUI input.
if(self.playFix) {
self.playFix = false;
$(this).jPlayer("play");
}
}
});
// Fix missing ended events.
this.player.bind($.jPlayer.event.ended, function(event) {
if(self.endedFix) {
self.endedFix = false;
setTimeout(function() {
self.setMedia(self.media);
},0);
// what if it was looping?
}
});
this.player.bind($.jPlayer.event.pause, function(event) {
if(self.endedFix) {
var remaining = event.jPlayer.status.duration - event.jPlayer.status.currentTime;
if(event.jPlayer.status.currentTime === 0 || remaining < 1) {
// Trigger the ended event from inside jplayer instance.
setTimeout(function() {
self.jPlayer._trigger($.jPlayer.event.ended);
},0);
}
}
});
}
// Instance jPlayer
this.player.jPlayer(this.options);
// Store a local copy of the jPlayer instance's object
this.jPlayer = this.player.data('jPlayer');
// Store the real cssSelectorAncestor being used.
this.cssSelectorAncestor = this.player.jPlayer('option', 'cssSelectorAncestor');
// Apply Android fixes
this.resetAndroid();
return this;
},
setMedia: function(media) {
this.media = media;
// Apply Android fixes
this.resetAndroid();
// Set the media
this.player.jPlayer("setMedia", this.media);
return this;
},
play: function() {
// Apply Android fixes
if($.jPlayer.platform.android && this.playFixRequired) {
// Apply Android play fix, if it is required.
this.playFix = true;
} else {
// Other browsers play it, as does Android if the fix is no longer required.
this.player.jPlayer("play");
}
},
resetAndroid: function() {
// Apply Android fixes
if($.jPlayer.platform.android) {
this.playFix = false;
this.playFixRequired = true;
this.endedFix = true;
// Disable the controls
// this.player.jPlayer('option', 'cssSelectorAncestor', '#NeverFoundDisabled');
}
}
};
return fix;
})(jQuery);
$(document).ready(function() {
var id = "#jquery_jplayer_1";
var bubble = {
title:"Bubble",
mp3:"http://www.jplayer.org/audio/mp3/Miaow-07-Bubble.mp3",
oga:"http://www.jplayer.org/audio/ogg/Miaow-07-Bubble.ogg"
};
var lismore = {
title:"Lismore",
mp3:"http://www.jplayer.org/audio/mp3/Miaow-04-Lismore.mp3",
oga:"http://www.jplayer.org/audio/ogg/Miaow-04-Lismore.ogg"
};
var options = {
swfPath: "../../dist/jplayer",
supplied: "mp3,oga",
wmode: "window",
useStateClassSkin: true,
autoBlur: false,
smoothPlayBar: true,
keyEnabled: true,
remainingDuration: true,
toggleDuration: true
};
var myAndroidFix = new jPlayerAndroidFix(id, bubble, options);
$('#setMedia-Bubble').click(function() {
myAndroidFix.setMedia(bubble);
});
$('#setMedia-Bubble-play').click(function() {
myAndroidFix.setMedia(bubble).play();
});
$('#setMedia-Lismore').click(function() {
myAndroidFix.setMedia(lismore);
});
$('#setMedia-Lismore-play').click(function() {
myAndroidFix.setMedia(lismore).play();
});
});
//]]>
</script>
</head>
<body>
<div id="jquery_jplayer_1" class="jp-jplayer"></div>
<div id="jp_container_1" class="jp-audio" role="application" aria-label="media player">
<div class="jp-type-single">
<div class="jp-gui jp-interface">
<div class="jp-volume-controls">
<button class="jp-mute" role="button" tabindex="0">mute</button>
<button class="jp-volume-max" role="button" tabindex="0">max volume</button>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
</div>
<div class="jp-controls-holder">
<div class="jp-controls">
<button class="jp-play" role="button" tabindex="0">play</button>
<button class="jp-stop" role="button" tabindex="0">stop</button>
</div>
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-current-time" role="timer" aria-label="time">&nbsp;</div>
<div class="jp-duration" role="timer" aria-label="duration">&nbsp;</div>
<div class="jp-toggles">
<button class="jp-repeat" role="button" tabindex="0">repeat</button>
</div>
</div>
</div>
<div class="jp-details">
<div class="jp-title" aria-label="title">&nbsp;</div>
</div>
<div class="jp-no-solution">
<span>Update Required</span>
To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
</div>
</div>
</div>
</body>
</html>