id: '', // ID var: used to edit playlist
title: '',
description: '',
+ state: 'stop', // state var: to state play or pause glyphicon
+ playing: '', // playing var: used to know if an audio is already playing or not
addPlaylist: function(name, id){
this.playlists.push({
this.id = ""; // init ID
},
- loadSong: function(resElem){
+ loadAudio: function(resElem){
var audio = new Audio();
- //For old browsers that do not support mp3 files
- audio.onerror = function(){
- this.src = this.src.replace("mp3", "ogg");
- this.play();
- };
- audio.src = resElem;
+ //For old browsers that do not support mp3 files
+ /*audio.onerror = function(){
+ this.src = this.src.replace("mp3", "ogg");
+ this.play();
+ };*/
+ audio.src = resElem;
audio.play();
},
+ stopAudio: function(resElem){
+ var audio = new Audio();
+ audio.src = resElem;
+ audio.pause();
+ },
+
+ changeGlyph: function(resElem){
+ if(this.playing === '' || this.playing === resElem){
+ if(this.state === 'stop'){
+ this.state = 'play';
+ document.getElementById(resElem).setAttribute("class", "glyphicon glyphicon-pause");
+ playlistUtils.loadAudio(resElem);
+ }
+ else if(this.state === 'play'){
+ this.state = 'stop';
+ document.getElementById(resElem).setAttribute("class", "glyphicon glyphicon-play");
+ playlistUtils.stopAudio(resElem);
+ }
+ this.playing = resElem;
+ }
+ else{
+ playlistUtils.stopAudio(this.playing);
+ this.state = 'stop';
+ document.getElementById(this.playing).setAttribute("class", "glyphicon glyphicon-play");
+ this.playing = '';
+ playlistUtils.changeGlyph(resElem);
+ }
+ },
+
/**
* Returns an uniqid by creating the current local time in millisecond + a random number. Used for markers and some json calls
* Copied from Timeside.utils.uniqid (Timeside might NOT ALWAYS be loaded, see home.html when user is authenitcated)
{% endif %}
{% endif %}
</td>
- <td align="center" style="vertical-align:middle;">
+ <td style="vertical-align:middle">
{% if resource.element.file or resource.element.has_mediafile %}
- <a href="#" id="{% url 'telemeta-item-export' resource.element.public_id 'mp3' %}" onclick="playlistUtils.loadSong(this.id)">
- <span class="glyphicon glyphicon-volume-up" style="font-size: 1.3em;"><p style="opacity:0;font-size:0">d</p></span>
- </a>
+ <span class="glyphicon glyphicon-ok" style="font-size: 1.3em;color: green;"><p style="opacity:0;font-size:0">d</p></span>
{% endif %}
</td>
- <td style="vertical-align:middle">
- <a href="#" onclick="if(confirm(gettrans('delete the resource from the playlist permanently?'))){playlistUtils.removeResource('{{resource.public_id}}');};return false;" class="component_icon button icon_cancel" style="padding: 4px 12px;"></a>
+ <td align="center" style="vertical-align:middle;">
+ {% if resource.element.file or resource.element.has_mediafile %}
+ <a href="#" id="{% url 'telemeta-item-export' resource.element.public_id 'mp3' %}" onclick="playlistUtils.changeGlyph(this.id)" class="glyphicon glyphicon-play" style="font-size: 1.3em;text-decoration: none"><p style="opacity:0;font-size:0">d</p></a>
+ {% endif %}
+ <a href="#" onclick="if(confirm(gettrans('delete the resource from the playlist permanently?'))){playlistUtils.removeResource('{{resource.public_id}}');};return false;">
+ <span class="glyphicon glyphicon-trash" style="font-size: 1.3em;color: black;"><p style="opacity:0;font-size:0">d</p></span>
+ </a>
</td>
</tr>
{% endfor %}