Commit dea4e098 authored by dj3c1t's avatar dj3c1t

toggle auto play next track

parent d18bca8d
......@@ -129,4 +129,22 @@ class SourceController extends Controller {
);
}
public function toggleAutoPlayNextTrackAction(Request $request) {
$this->get('session')->set(
'auto_play_next_track',
!$this->get('session')->get(
'auto_play_next_track',
false
)
);
return new RestResponse(
json_encode(
array(
"error" => false,
"data" => $this->get('session')->get('auto_play_next_track', false) ? 'true' : 'false',
)
)
);
}
}
......@@ -74,3 +74,6 @@ dj3c1t_menus:
parameters: {sourceType: 'source'}
label: Sources
glyphicon: glyphicon-triangle-right
toggle_auto_play_next_track:
service: sourceml.menus
method: toggleAutoPlayNextTrackButton
......@@ -65,6 +65,10 @@ source_source_derivations:
path: /source/derivations/{source}
defaults: { _controller: Dj3c1tSourceMLBundle:Source/Source:sourceDerivations }
source_toggle_auto_play_next_track:
path: /source/toggle_auto_play_next_track
defaults: { _controller: Dj3c1tSourceMLBundle:Source/Source:toggleAutoPlayNextTrack }
# -------------------------------------------------------------------
# Admin
#
......
......@@ -17,6 +17,7 @@ $(document).ready(
function init_players(container) {
container.find("audio.jap").jaudioPlayer({
"waveform_class": "waveform",
"auto_play_next_track": {{ app.session.get('auto_play_next_track', false) ? 'true' : 'false' }},
});
$(window).resize(
function() {
......@@ -112,6 +113,46 @@ $(document).ready(
}
);
$(".toggle_auto_play_next_track").each(
function() {
var menu_icon = $(this).find(".glyphicon");
menu_icon.removeClass("green");
menu_icon.removeClass("active");
menu_icon.addClass("green");
{% if app.session.get('auto_play_next_track', false) %}
menu_icon.addClass("active");
{% endif %}
}
);
$(".toggle_auto_play_next_track").click(
function() {
var toggle_button = $(this);
var menu_icon = toggle_button.find(".glyphicon");
$.get(
$(this).attr("href"),
function(response) {
if(response["error"]) {
alert(response["error"]);
return false;
}
$("audio.jap").jaudioPlayer(
"set_option",
"auto_play_next_track",
response["data"] == 'true' ? true : false
);
menu_icon.removeClass("green");
menu_icon.removeClass("active");
menu_icon.addClass("green");
if(response["data"] == 'true') {
menu_icon.addClass("active");
}
}
);
return false;
}
);
}
);
</script>
......
......@@ -28,4 +28,13 @@ class SourceMLMenus {
}
}
public function toggleAutoPlayNextTrackButton() {
return array(
"route" => "source_toggle_auto_play_next_track",
"label" => "Enchaîner les lectures",
"glyphicon" => "glyphicon-ok-circle",
"class" => "toggle_auto_play_next_track",
);
}
}
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