Fixed music selection script
This commit is contained in:
parent
5c637f242d
commit
711ed2c6e7
@ -1,36 +1,11 @@
|
|||||||
var player = '';
|
var player = '';
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
player = new MediaElementPlayer('#music-player', {
|
player = $('#music-player').get(0);
|
||||||
// initial volume when the player starts
|
|
||||||
startVolume: 0.5,
|
|
||||||
// useful for <audio> player loops
|
|
||||||
loop: false,
|
|
||||||
// enables Flash and Silverlight to resize to content size
|
|
||||||
enableAutosize: true,
|
|
||||||
// change the size of the audio player,
|
|
||||||
audioWidth: '100%',
|
|
||||||
// the order of controls you want on the control bar (and other plugins below)
|
|
||||||
features: ['playpause','progress','current','duration','tracks','volume'],
|
|
||||||
// Hide controls when playing and mouse is not over the video
|
|
||||||
alwaysShowControls: false,
|
|
||||||
// force iPad's native controls
|
|
||||||
iPadUseNativeControls: false,
|
|
||||||
// force iPhone's native controls
|
|
||||||
iPhoneUseNativeControls: false,
|
|
||||||
// force Android's native controls
|
|
||||||
AndroidUseNativeControls: false,
|
|
||||||
// forces the hour marker (##:00:00)
|
|
||||||
alwaysShowHours: false,
|
|
||||||
// turns keyboard support on and off for this instance
|
|
||||||
enableKeyboard: true,
|
|
||||||
// when this player starts, it will pause other players
|
|
||||||
pauseOtherPlayers: true
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.now-playing-list .music-track').on('click', function(e) {
|
$('.now-playing-list .music-track').on('click', function() {
|
||||||
// change the audio source
|
// change the audio source
|
||||||
changeAudioSources(e);
|
changeAudioSources(this);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -42,9 +17,9 @@ function changeAudioSources(trackElem) {
|
|||||||
var audioFilePath = trackElem.data('path');
|
var audioFilePath = trackElem.data('path');
|
||||||
|
|
||||||
// loop through the audio player source elements
|
// loop through the audio player source elements
|
||||||
playerSources.each(function(source) {
|
playerSources.each(function() {
|
||||||
// jQuery-ize the element
|
// jQuery-ize the element
|
||||||
source = $(source);
|
source = $(this);
|
||||||
|
|
||||||
if (source.attr('type') == 'audio/ogg') {
|
if (source.attr('type') == 'audio/ogg') {
|
||||||
// OGG source file
|
// OGG source file
|
||||||
@ -57,4 +32,6 @@ function changeAudioSources(trackElem) {
|
|||||||
|
|
||||||
// reload music player
|
// reload music player
|
||||||
player.load();
|
player.load();
|
||||||
|
// start playing new song
|
||||||
|
player.play();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user