JuliusCode / MP4MUSEUM

MP4MUSEUM.org Media Player
GNU General Public License v3.0
32 stars 8 forks source link

V5 - Not playing playlist files #3

Closed AngusF22 closed 3 years ago

AngusF22 commented 3 years ago

When I put a playlist pointing to a stream on my USB stick, the V5 script won't play either an m3u8 or xspf playlist that's aiming at a local rtsp stream. I can play it through cvlc without any issues, both directly and by loading the playlist on my USB drive.

JuliusCode commented 3 years ago

Hi, could you try to increase the wait time in line 37, before the state of the player is checked? the player might exit before even playing.

J.

Am 18.02.2021 um 19:32 schrieb AngusF22 notifications@github.com:

 When I put a playlist pointing to a stream on my USB stick, the V5 script won't play either an m3u8 or xspf playlist that's aiming at a local rtsp stream. I can play it through cvlc without any issues, both directly and by loading the playlist on my USB drive.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

AngusF22 commented 3 years ago

I tried bumping it up to 10 seconds, and it still won't play the stream. If I hardcode the Python script to call vlc_play with the URL to the stream, it works, but of course that defeats the purpose of mp4museum.

If I hardcode the filename of the .m3u8 playlist, it just fails. The glob code finds the playlist, so it seems to be something to do with the Python code not working with playlist files.

AngusF22 commented 3 years ago

This rather cryptic forum post suggests that VLC for Python may need special handling for playlist files.

https://forum.videolan.org/viewtopic.php?t=137163

JuliusCode commented 3 years ago

the solution offered in the forum would need the mp4museum script to read and process the playlist file. while i am sure that it can be done, i will have to see if i can do it any time soon, or somebody else has some code to share?

Am 27.02.2021 um 01:05 schrieb AngusF22 notifications@github.com:

 This rather cryptic forum post suggests that VLC for Python may need special handling for playlist files.

https://forum.videolan.org/viewtopic.php?t=137163

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

AngusF22 commented 3 years ago

This is a bit hacky, but it's working for me. Obviously audio device config is ignored, as is GPIO input.

# play media
def vlc_play(source):
    if source.endswith('.m3u8'):
        os.system('cvlc --play-and-exit --no-osd '+source)
        time.sleep(1)
    elif source.endswith('.xspf'):
        os.system('cvlc --play-and-exit --no-osd '+source)
        time.sleep(1)
    else:
        vlc_instance = vlc.Instance('-q -A alsa --alsa-audio-device hw:' + audiodevice)
        global player
        player = vlc_instance.media_player_new()
        media = vlc_instance.media_new(source)
        player.set_media(media)
        player.play()
        time.sleep(1)
        current_state = player.get_state()
        while current_state == 3 or current_state == 4:
            time.sleep(0.1)
            current_state = player.get_state()
        media.release()
        player.release()

Edit: Added --play-and-exit, because the mp4museum intro video isn't reliably long enough to bring up the network.

JuliusCode commented 3 years ago

after looking at your code, and the page related to playlist formats in vlc ( https://wiki.videolan.org/Playlist ) the xspf format seems very useful for using it as a more advanced signage system

maybe a way forward would be to check for a certain playlist (like "mp4museum.xspf"), which is then kind of replacing the indexing of files. this way, when doing so, you also would know that your buttons will not work.

handling it like any other file seems counter-intuitive when you put media and playlist on the same drive- it would do correct playback from the playlist, and then play everything again in alphabetical order..