Commit c0eeeab6 authored by Simon Daron's avatar Simon Daron
Browse files

give play capacity to resume

parent 84b14591
......@@ -95,14 +95,14 @@
},
// Transform JSON sound object to HTML container for playlist.
_htmlifyJsonSound: function(sound) {
var container = $('<li>');
var container = $('<li>').attr('data-origin',sound.id);
var audio = $('<audio>',this.options.html5audioOptions).hide();
$.each(sound.source,function(k,v){
var source = $('<source>',{src:v,type:k});
audio.append(source);
});
audio.attr('title',sound.title)
.attr('data-origin',sound.id)
.on('play',function(){
thePlaylist.setFocus(container);
container.addClass('playing');
......@@ -153,7 +153,8 @@
},
// Create a public method.
registerAudio: function(audio,success) {
var htmlAudio = this._htmlifyJsonSound(this.jsonifyAudio(audio));
var audioObj = this.jsonifyAudio(audio);
var htmlAudio = this._htmlifyJsonSound(audioObj);
this.playlistContainer.append(htmlAudio);
this.isLastAdd = htmlAudio;
if(!this.isActive){this.setFocus(this.isLastAdd);}
......@@ -162,6 +163,12 @@
this._update();
},
// Play next sound
bindControl: function(control,audio,element,options) {
element.addClass('loading');
audioID = audio.attr('id');
//TODO for controls in page content
},
// Play next sound
registerControl: function(name,options) {
this.controlButtons[name] = $('<button>',options);
this.controlContainer.append(this.controlButtons[name]);
......@@ -221,6 +228,11 @@
this.isActive.next().find('audio').trigger('beforePlay').trigger('play');
return true;
},
// Play next sound
playLast: function() {
this.playlistContainer.find('audio').last().trigger('beforePlay').trigger('play');
return true;
},
// Pause all sounds.
pauseSounds: function(selector) {
this.playlistContainer.find('audio').each(function(){$(this).trigger('pause');});
......
......@@ -15,6 +15,7 @@ $(function() {
self.registerControl('showList',{class:"icon-list",click: function(){
self.playlistContainer.toggleClass('deploy');
}});
self.controlButtons['showList'].appendTo($('#localList .label'));
},
onPlay:function(self){
$('#DirectStreamPanik')[0].pause();
......@@ -41,9 +42,9 @@ $(function() {
}
});
/****************************************************/
/**** AUDIOPLAYER ****/
/****************************************************/
/****************************************************/
/**** AUDIOPLAYER ****/
/****************************************************/
if($('#player-container').offset()){
var topPosition = 0;
topPosition = $('#player-container').offset().top;
......@@ -59,9 +60,9 @@ $(function() {
}
});
}
/****************************************************/
/**** AJAX REQUESTS ****/
/****************************************************/
/****************************************************/
/**** AJAX REQUESTS ****/
/****************************************************/
String.prototype.decodeHTML = function() {
return $("<div>", {html: "" + this}).html();
};
......@@ -114,7 +115,7 @@ $(function() {
loadPage_request = $.get(href, null, afterLoad);
};
init = function() {
$("#All a, #All area, #All form").removeClass('loading');
$("#All a, #All area").removeClass('loading');
$("#All a, #All area").unbind('click').on('click',function() {
$(this).addClass('loading');
var href = $(this).attr("href");
......@@ -123,15 +124,16 @@ $(function() {
* part points to the same domain */
if (!href) {
doLog('No href attributes, unable to load content','error');
$("#All a, #All area, #All form").removeClass('loading');
$("#All a, #All area").removeClass('loading');
return false;
}else if (href.indexOf(document.domain) > -1 ||
href.indexOf(':') === -1 || href.indexOf(':') > 5) {
}else if (!$(this).attr('target') && (
href.indexOf(document.domain) > -1 ||href.indexOf(':') === -1 || href.indexOf(':') > 5
)) {
loadPage(href);
return false;
}else{
$(this).attr('target','_blanck');
$("#All a, #All area, #All form").removeClass('loading');
$("#All a, #All area").removeClass('loading');
return true;
}
});
......@@ -158,10 +160,22 @@ $(function() {
});
activeTab.trigger('load');
});
$('[data-player-audio]').on('click',function(){
var audio = $($(this).attr('data-player-audio'));
$localList.playlist("registerAudio",audio,doLog(audio.attr('title')+' has been added to your playlist.','ok'));
$('[data-player-action]').on('click',function(){
var audio = $('#'+$(this).attr('data-player-audio'));
if($(this).attr('data-player-action') == "registerAudio"){
$localList.playlist("registerAudio",audio,doLog(audio.attr('title')+' has been added to your playlist.','ok'));
}else if($(this).attr('data-player-action') == "playAudio"){
$localList.playlist("registerAudio",audio,doLog(audio.attr('title')+' has been added to your playlist.','ok'));
$localList.playlist("playLast");
}else{
$localList.playlist($(this).attr('data-player-action'));
}
});
$('[data-player-control]').each(function(){
var audio = $('#'+$(this).attr('data-player-audio'));
$localList.playlist("bindControl",$(this).attr('data-player-control'),audio,$(this));
});
$('[data-highlight]').on('check',function(){
$($(this).attr('data-about')).find($(this).attr('data-highlight')).addClass('highlighted').removeClass('normal');
}).on('uncheck',function(){
......@@ -186,47 +200,6 @@ $(function() {
$('[data-toggle].icon-check-empty').each(function(){
$(this).trigger('uncheck');
});
/*
$('[data-highlight].icon-check').each(function(){
$(this).trigger('check');
});
*/
/*
$("[data-audio-control]").each(function() {
var audio = $('#'+$(this).attr('data-audio-control'));
var audioElement = audio[0];
if(audioElement){
var addToPlaylist = $(this).find('.add');
addToPlaylist.on('click',function(e){
audio.clone().appendTo('#Playlist');
$('#Playlist').parent().show();
});
var playPauseButton = $(this).find('.playpause');
//alert($(this).attr('data-audio'));
playPauseButton.on('click',function(e){
if (audioElement.paused == false) {
audioElement.pause();
} else {
audioElement.play();
}
});
//alert($(this).attr('data-audio'));
playPauseButton.on('click',function(e){
if (audioElement.paused == false) {
audioElement.pause();
} else {
audioElement.play();
}
});
// Bind back event in case of direct control
audio.on('play',function(){
playPauseButton.addClass('icon-pause').removeClass('icon-play');
}).on('pause',function(){
playPauseButton.addClass('icon-play').removeClass('icon-pause');
});
}
});
*/
}
init();
});
......@@ -4,14 +4,14 @@
<div class="controls huge">
<button class="icon-plus-sign"
title="Add to playlist"
data-player-audio="#Audio-{{ sound.file.url|slugify }}"
data-player-method="add"
data-player-audio="Audio-{{ sound.file.url|slugify }}"
data-player-action="registerAudio"
id="addToPlaylist-{{ sound.file.url|slugify }}"
></button>
<button class="icon-play-circle"
title="Play"
data-player-audio="#Audio-{{ sound.file.url|slugify }}"
data-player-method="play"
data-player-audio="Audio-{{ sound.file.url|slugify }}"
data-player-action="playAudio"
></button>
{% if sound|is_format_available:'ogg' %}
<a target="_blanck" class="icon-download button" href="{{ sound|format_url:'ogg' }}"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment