~hristoast/mousikofidi

e5fb0acc82b4a1cef818ae78f5bc264eb20509ee — Hristos N. Triantafillou a month ago da4f012
Don't try to set the title too early on the queue page

Also set a nicer default "playing text", so at least folks with a
bigger queue know stuff is loading and will update.
3 files changed, 31 insertions(+), 22 deletions(-)

M mousikofidi/static/js/player.js
M mousikofidi/templates/audio_player.html
M test_mousikofidi.py
M mousikofidi/static/js/player.js => mousikofidi/static/js/player.js +24 -15
@@ 214,7 214,7 @@ function setRandomOrder(trackType) {
}

function setStatusTexts(mediaType, nowPlayingP, _playingTitleSpan, actionText,
                        nowPlayingNum, trackTitle, siteName, titleElement) {
                        nowPlayingNum, trackTitle, totalTracks, siteName, titleElement) {
    var arrows;

    if (mediaType === "audio") {


@@ 243,7 243,7 @@ function setStatusTexts(mediaType, nowPlayingP, _playingTitleSpan, actionText,
        playingTitleSpan,
        trackTitle,
        Number(nowPlayingNum) + 1,
        arrows.length
        totalTracks
    );
}



@@ 645,6 645,7 @@ function paused(_, event, trackType) {
            "Now Playing:",
            nowPlayingTrackNum,
            playingText,
            totalTracks,
            siteName,
            pageTitle
        );


@@ 659,6 660,7 @@ function paused(_, event, trackType) {
            "Paused:",
            nowPlayingTrackNum,
            playingText,
            totalTracks,
            siteName,
            pageTitle
        );


@@ 941,16 943,18 @@ function FidiAudioPlayerSetup(audioElement, currentTrackNum, trackServeUrl, play
    audioElement.src = trackServeUrl;
    // Wait for "canplay", for whatever reason this isn't needed for videos...
    audioElement.addEventListener("canplay", function() {
        setStatusTexts(
            "audio",
            audioNowPlayingTextP,
            playingTitleSpan,
            "Paused:",
            currentTrackNum,
            playingText,
            siteName,
            pageTitle
        );
        if (!queueHeaderDiv)
            setStatusTexts(
                "audio",
                audioNowPlayingTextP,
                playingTitleSpan,
                "Paused:",
                currentTrackNum,
                playingText,
                playArrows.length,
                siteName,
                pageTitle
            );
    });

    // Finally, add the ended listener to continue playback


@@ 987,14 991,19 @@ function FidiAudioPlayerSetup(audioElement, currentTrackNum, trackServeUrl, play
}

function FidiVideoPlayerSetup(videoElement, trackServeUrl, playingText) {
    var siteName = pageTitle.getAttribute("data-sitename");
    videoElement.src = trackServeUrl;
    videoElement.addEventListener("canplay", function() {
        if (!queueHeaderDiv)
            updateNowPlayingTitle(
            setStatusTexts(
                "video",
                videoNowPlayingTextP,
                videoPlayingTitleSpan,
                "Paused:",
                0,  // TODO: Don't hardcode zero here
                playingText,
                1,
                videoArrows.length
                videoArrows.length,
                siteName
            );

        videoElement.addEventListener("ended", endedVideoListener);

M mousikofidi/templates/audio_player.html => mousikofidi/templates/audio_player.html +1 -1
@@ 1,5 1,5 @@
<div class="center{% if page_name == "Your Queue" %} hidden{% endif %}" id="player">
  <p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it"></span></p>
  <p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it">( Loading ... )</span></p>
  <div data-nowplaying-num="0" id="now-playing-num"></div>
  <div data-randorder="none" id="randorder"></div>
  <div data-playback-ended="false" id="audio-playback-ended"></div>

M test_mousikofidi.py => test_mousikofidi.py +6 -6
@@ 1665,7 1665,7 @@ def test_dir_detail_found(client):
    assert bytes('<div class="center" id="player">', "utf8") in rv.data
    assert (
        bytes(
            '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it"></span></p>',
            '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it">( Loading ... )</span></p>',
            "utf8",
        )
        in rv.data


@@ 2391,7 2391,7 @@ def test_playlist_with_audio_and_video(client):
    # assert bytes('<div class="center" id="player">', "utf8") in rv.data
    # assert (
    #     bytes(
    #         '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it"></span></p>',
    #         '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it">( Loading ... )</span></p>',
    #         "utf8",
    #     )
    #     in rv.data


@@ 2715,7 2715,7 @@ def test_playlist_with_audio_no_video(client):
    # assert bytes('<div class="center" id="player">', "utf8") in rv.data
    # assert (
    #     bytes(
    #         '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it"></span></p>',
    #         '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it">( Loading ... )</span></p>',
    #         "utf8",
    #     )
    #     in rv.data


@@ 3042,7 3042,7 @@ def test_playlist_no_audio_with_video(client):
    # assert bytes('<div class="center" id="player">', "utf8") not in rv.data
    # assert (
    #     bytes(
    #         '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it"></span></p>',
    #         '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it">( Loading ... )</span></p>',
    #         "utf8",
    #     )
    #     not in rv.data


@@ 3279,7 3279,7 @@ def test_playlist_detail_real_with_bad(client):
    )
    assert (
        bytes(
            '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it"></span></p>',
            '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it">( Loading ... )</span></p>',
            "utf8",
        )
        in rv.data


@@ 3442,7 3442,7 @@ def test_playlist_detail_real(client):
    )
    assert (
        bytes(
            '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it"></span></p>',
            '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track; click to jump to it">( Loading ... )</span></p>',
            "utf8",
        )
        in rv.data