diff --git a/src/Classes/SIS/SIS_Tracklist.php b/src/Classes/SIS/SIS_Tracklist.php index 3e30054d2..ac3a75e29 100644 --- a/src/Classes/SIS/SIS_Tracklist.php +++ b/src/Classes/SIS/SIS_Tracklist.php @@ -30,25 +30,17 @@ public static function getTrackListing($timeslotid, $offset = 0) $tracks = []; foreach ($tracklist as $tracklistitem) { $track = $tracklistitem->getTrack(); - if (is_array($track)) { - $tracks[] = [ - 'playtime' => $tracklistitem->getStartTime(), - 'title' => $track['title'], - 'artist' => $track['artist'], - 'album' => $track['album'], - 'trackid' => 'custom', - 'id' => $tracklistitem->getID(), - ]; - } else { - $tracks[] = [ - 'playtime' => $tracklistitem->getStartTime(), - 'title' => $track->getTitle(), - 'artist' => $track->getArtist(), - 'album' => $track->getAlbum()->getTitle(), - 'trackid' => $track->getID(), - 'id' => $tracklistitem->getID(), - ]; - } + // Essentially, if the item is a manual tracklist outside the library, it will be an array instead of an MyRadio_Track. + $is_array = is_array($track); + $tracks[] = [ + 'playtime' => $tracklistitem->getStartTime(), + 'endtime' => $tracklistitem->getEndTime(), + 'title' => $is_array ? $track['title'] : $track->getTitle(), + 'artist' => $is_array ? $track['artist'] : $track->getArtist(), + 'album' => $is_array ? $track['album'] : $track->getAlbum()->getTitle(), + 'trackid' => $is_array ? 'custom' : $track->getID(), + 'id' => $tracklistitem->getID(), + ]; } return $tracks; diff --git a/src/Classes/ServiceAPI/MyRadio_TracklistItem.php b/src/Classes/ServiceAPI/MyRadio_TracklistItem.php index c20554538..8d0128e21 100644 --- a/src/Classes/ServiceAPI/MyRadio_TracklistItem.php +++ b/src/Classes/ServiceAPI/MyRadio_TracklistItem.php @@ -106,8 +106,10 @@ public static function create($trackid, $timeslotid = null, $starttime = null, $ 403 ); } - + + $timeslot_was_null = false; if ($timeslotid == null) { + $timeslot_was_null = true; $timeslot = MyRadio_Timeslot::getCurrentTimeslot(); $timeslotid = $timeslot != null ? $timeslot->getID() : null; // will be null if jukebox etc. } else { @@ -153,6 +155,14 @@ public static function create($trackid, $timeslotid = null, $starttime = null, $ # If we've been left to work out which state we're in (confirmed or off air), let's look this up. if ($state == null) { $state = in_array($sourceid, self::getTracklistSourcesOnAirAtTime($starttime)) ? 'c': 'o'; + + // If we didn't originally supply a timeslotid, and we're tracklisting off air + // Don't attach to the current timeslot. + // This is useful for BAPS, where it doesn't know if it's tracklisting to a show, or if it's the on air studio. + // We don't want to report a track as played off air to a timeslot if it's in a different room etc. + if ($state == 'o' && $timeslot_was_null == true) { + $timeslotid == null; + } } self::$db->query('BEGIN'); diff --git a/src/Public/js/sis.js b/src/Public/js/sis.js index e5a5ffc30..2bce53eb9 100644 --- a/src/Public/js/sis.js +++ b/src/Public/js/sis.js @@ -23,7 +23,7 @@ var SIS = function (container) { dataType: "json", //The timeout here is to prevent stack overflow complete: function () { - setTimeout(connect, 100); + setTimeout(connect, 10000); }, success: handleResponse, statusCode: { diff --git a/src/Public/js/sis.tracklist.js b/src/Public/js/sis.tracklist.js index bacf90e08..3cf085725 100644 --- a/src/Public/js/sis.tracklist.js +++ b/src/Public/js/sis.tracklist.js @@ -25,7 +25,33 @@ var Tracklist = function () { ); myradio.createDialog( "Confirm removal", - "Are you sure you want to remove " + title + " by " + artist + " from the tracklist?", + "Are you sure you want to remove '" + title + " by " + artist + "' from the tracklist?", + [confirmButton, myradio.closeButton()] + ); + }; + }, + get_end_func = function (id, title, artist) { + return function () { + var confirmButton = document.createElement("button"); + confirmButton.className = "btn btn-warning"; + confirmButton.innerHTML = "End Tracklist"; + confirmButton.setAttribute("data-dismiss", "modal"); + confirmButton.addEventListener( + "click", + function () { + myradio.callAPI("PUT", "tracklistItem", "endtime", id, "", "", + function () { + let row = document.getElementById("t" + id); + let tds = row.childNodes; + let endbtn = tds[tds.length - 1].querySelectorAll('.end-btn')[0]; + row.removeChild(endbtn); + } + ); + } + ); + myradio.createDialog( + "Confirm end of track?", + "Are you sure you want to mark '" + title + " by " + artist + "' as ended in the tracklist?", [confirmButton, myradio.closeButton()] ); }; @@ -203,24 +229,33 @@ var Tracklist = function () { table = document.createElement("table"); table.setAttribute("class", "tracklist"); header = document.createElement("tr"); - header.innerHTML = "