mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-06 03:49:56 +02:00
First draft for "Play Next" feature
This commit is contained in:
parent
cb9062c004
commit
7c5ec76f51
11 changed files with 88 additions and 3 deletions
BIN
images/icon_play_next.png
Normal file
BIN
images/icon_play_next.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 635 B |
|
@ -186,6 +186,12 @@ class Stream_Playlist
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function check_autoplay_next()
|
||||||
|
{
|
||||||
|
// Currently only supported for web player
|
||||||
|
return (AmpConfig::get('ajax_load') && AmpConfig::get('play_type') == 'web_player');
|
||||||
|
}
|
||||||
|
|
||||||
public function generate_playlist($type, $redirect = false)
|
public function generate_playlist($type, $redirect = false)
|
||||||
{
|
{
|
||||||
if (!count($this->urls)) {
|
if (!count($this->urls)) {
|
||||||
|
|
|
@ -211,6 +211,27 @@ class WebPlayer
|
||||||
return $addjs;
|
return $addjs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get play_next javascript.
|
||||||
|
* @param \Playlist $playlist
|
||||||
|
* @param string $callback_container
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function play_next_js($playlist, $callback_container='')
|
||||||
|
{
|
||||||
|
$addjs = "";
|
||||||
|
foreach ($playlist->urls as $item) {
|
||||||
|
if ($item->type == 'broadcast') {
|
||||||
|
// TODO: Figure out how this works
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
$addjs .= $callback_container . "playNext(" . self::get_media_js_param($item) . ");";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $addjs;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get media javascript parameters.
|
* Get media javascript parameters.
|
||||||
* @param \playable_item $item
|
* @param \playable_item $item
|
||||||
|
|
|
@ -187,5 +187,24 @@ jPlayerPlaylist.prototype._highlight = function(index) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
jPlayerPlaylist.prototype.addAfter = function(media, idx) {
|
||||||
|
if (idx >= this.original.length || idx < 0) {
|
||||||
|
console.log("jPlayerPlaylist.addAfter: ERROR, Index out of bounds");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(this.cssSelector.playlist + " ul")
|
||||||
|
.find("li[name=" + idx + "]").after(this._createListItem(media)).end()
|
||||||
|
.find("li:last-child").hide().slideDown(this.options.playlistOptions.addTime);
|
||||||
|
|
||||||
|
this._updateControls();
|
||||||
|
this.original.splice(idx + 1, 0, media);
|
||||||
|
this.playlist.splice(idx + 1, 0, media);
|
||||||
|
|
||||||
|
if(this.original.length === 1) {
|
||||||
|
this.select(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
|
@ -88,6 +88,9 @@ switch ($_REQUEST['action']) {
|
||||||
if (!empty($_REQUEST['append'])) {
|
if (!empty($_REQUEST['append'])) {
|
||||||
$_SESSION['iframe']['target'] .= '&append=true';
|
$_SESSION['iframe']['target'] .= '&append=true';
|
||||||
}
|
}
|
||||||
|
if (!empty($_REQUEST['playnext'])) {
|
||||||
|
$_SESSION['iframe']['target'] .= '&playnext=true';
|
||||||
|
}
|
||||||
if ($_REQUEST['subtitle']) {
|
if ($_REQUEST['subtitle']) {
|
||||||
$_SESSION['iframe']['subtitle'] = $_REQUEST['subtitle'];
|
$_SESSION['iframe']['subtitle'] = $_REQUEST['subtitle'];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
function PlayerFrame()
|
function PlayerFrame()
|
||||||
{
|
{
|
||||||
var appendmedia = false;
|
var appendmedia = false;
|
||||||
|
var playnext = false;
|
||||||
var $webplayer = $("#webplayer");
|
var $webplayer = $("#webplayer");
|
||||||
if ($webplayer.is(':visible')) {
|
if ($webplayer.is(':visible')) {
|
||||||
<?php
|
<?php
|
||||||
|
@ -35,6 +36,10 @@ if ($_REQUEST['append']) {
|
||||||
?>
|
?>
|
||||||
appendmedia = true;
|
appendmedia = true;
|
||||||
<?php
|
<?php
|
||||||
|
} else if ($_REQUEST['playnext']) {
|
||||||
|
?>
|
||||||
|
playnext = true;
|
||||||
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
}
|
}
|
||||||
|
@ -45,6 +50,8 @@ if ($_REQUEST['append']) {
|
||||||
|
|
||||||
if (appendmedia) {
|
if (appendmedia) {
|
||||||
<?php echo WebPlayer::add_media_js($this); ?>
|
<?php echo WebPlayer::add_media_js($this); ?>
|
||||||
|
} else if (playnext) {
|
||||||
|
<?php echo WebPlayer::play_next_js($this); ?>
|
||||||
} else {
|
} else {
|
||||||
$webplayer.show();
|
$webplayer.show();
|
||||||
$.get('<?php echo AmpConfig::get('web_path'); ?>/web_player_embedded.php?playlist_id=<?php echo $this->id; ?>', function (data) {
|
$.get('<?php echo AmpConfig::get('web_path'); ?>/web_player_embedded.php?playlist_id=<?php echo $this->id; ?>', function (data) {
|
||||||
|
|
|
@ -45,6 +45,8 @@ function update_action()
|
||||||
var jplaylist = new Array();
|
var jplaylist = new Array();
|
||||||
var jtypes = new Array();
|
var jtypes = new Array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function addMedia(media)
|
function addMedia(media)
|
||||||
{
|
{
|
||||||
var jpmedia = {};
|
var jpmedia = {};
|
||||||
|
@ -62,6 +64,24 @@ function addMedia(media)
|
||||||
|
|
||||||
jplaylist.add(jpmedia);
|
jplaylist.add(jpmedia);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function playNext(media)
|
||||||
|
{
|
||||||
|
var jpmedia = {};
|
||||||
|
jpmedia['title'] = media['title'];
|
||||||
|
jpmedia['artist'] = media['artist'];
|
||||||
|
jpmedia[media['filetype']] = media['url'];
|
||||||
|
jpmedia['poster'] = media['poster'];
|
||||||
|
jpmedia['artist_id'] = media['artist_id'];
|
||||||
|
jpmedia['album_id'] = media['album_id'];
|
||||||
|
jpmedia['media_id'] = media['media_id'];
|
||||||
|
jpmedia['replaygain_track_gain'] = media['replaygain_track_gain'];
|
||||||
|
jpmedia['replaygain_track_peak'] = media['replaygain_track_peak'];
|
||||||
|
jpmedia['replaygain_album_gain'] = media['replaygain_album_gain'];
|
||||||
|
jpmedia['replaygain_album_peak'] = media['replaygain_album_peak'];
|
||||||
|
|
||||||
|
jplaylist.addAfter(jpmedia, jplaylist.current);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<script language="javascript" type="text/javascript">
|
<script language="javascript" type="text/javascript">
|
||||||
function ExitPlayer()
|
function ExitPlayer()
|
||||||
|
|
|
@ -100,6 +100,9 @@ foreach ($data as $row) {
|
||||||
<?php if (Stream_Playlist::check_autoplay_append()) { ?>
|
<?php if (Stream_Playlist::check_autoplay_append()) { ?>
|
||||||
<?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $song->id . '&append=true','play_add', T_('Play last'),'addplay_song_' . $nb . '_' . $song->id); ?>
|
<?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $song->id . '&append=true','play_add', T_('Play last'),'addplay_song_' . $nb . '_' . $song->id); ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<?php if (Stream_Playlist::check_autoplay_next()) { ?>
|
||||||
|
<?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $song->id . '&playnext=true', 'play_next', T_('Play next'), 'nextplay_song_' . $nb . '_' . $song->id); ?>
|
||||||
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -62,6 +62,9 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
|
||||||
<?php if (Stream_Playlist::check_autoplay_append()) { ?>
|
<?php if (Stream_Playlist::check_autoplay_append()) { ?>
|
||||||
<?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $song->id . '&append=true','play_add', T_('Play last'),'addplay_song_' . $song->id); ?>
|
<?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $song->id . '&append=true','play_add', T_('Play last'),'addplay_song_' . $song->id); ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<?php if (Stream_Playlist::check_autoplay_next()) { ?>
|
||||||
|
<?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $song->id . '&playnext=true','play_next', T_('Play next'),'nextplay_song_' . $song->id); ?>
|
||||||
|
<?php } ?>
|
||||||
<?php echo $song->show_custom_play_actions(); ?>
|
<?php echo $song->show_custom_play_actions(); ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php echo Ajax::button('?action=basket&type=song&id=' . $song->id,'add', T_('Add to temporary playlist'),'add_song_' . $song->id); ?>
|
<?php echo Ajax::button('?action=basket&type=song&id=' . $song->id,'add', T_('Add to temporary playlist'),'add_song_' . $song->id); ?>
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
<?php if (Stream_Playlist::check_autoplay_append()) { ?>
|
<?php if (Stream_Playlist::check_autoplay_append()) { ?>
|
||||||
<?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $libitem->id . '&append=true', 'play_add', T_('Play last'), 'addplay_song_' . $libitem->id); ?>
|
<?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $libitem->id . '&append=true', 'play_add', T_('Play last'), 'addplay_song_' . $libitem->id); ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<?php if (Stream_Playlist::check_autoplay_next()) { ?>
|
||||||
|
<?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $libitem->id . '&playnext=true', 'play_next', T_('Play next'), 'nextplay_song_' . $libitem->id); ?>
|
||||||
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -883,8 +883,8 @@ table.tabledata .th-bottom:focus {
|
||||||
}
|
}
|
||||||
|
|
||||||
table.tabledata tbody .cel_play {
|
table.tabledata tbody .cel_play {
|
||||||
max-width: 40px;
|
max-width: 60px;
|
||||||
min-width: 40px;
|
min-width: 60px;
|
||||||
width: 40px !important;
|
width: 40px !important;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue