jaseg / python-mpv

Python interface to the awesome mpv media player
https://git.jaseg.de/python-mpv.git
Other
547 stars 68 forks source link

Inability to handle files over SFTP? #56

Closed seanpianka closed 6 years ago

seanpianka commented 6 years ago
import sys
import os
import subprocess

import mpv

# list of remote paths to songs, prepended with sftp protocol/address
# Example: sftp://sean@192.168.1.3/home/sean/folder/Hille/craz.mod
with open(os.path.expanduser("~/remote_music.txt")) as f:
    music = [''.join(["sftp://sean@192.168.1.3", song_path])
             for song_path in f.readlines()]

player = mpv.MPV()
if len(sys.argv) == 1 or sys.argv[1] == "*":
    for song in music:
        player.playlist_append(song)
else:
    pass # add grep/search, curate songs added to playlist

player.playlist_pos = 0
player.wait_for_playback()

With this code, it should create a playlist using a list of remote file paths, then play them after the call to wait. However, the player simply hangs on its call to wait as no song is ever played. Similarly, the following main loop also rapidly prints each song, while not actually playing any of the songs in the list:

player = mpv.MPV()
if len(sys.argv) == 1 or sys.argv[1] == "*":
    for song in music:
        print(song)
        player.play(song)

However, if any of the full remote paths are copy and pasted into normal invocation of mpv, such as:

mpv "sftp://sean@192.168.1.3/home/sean/folder/Jogeir Liljedahl/overture.mod" --volume=35

plays the song as expected (using the exact same string that was printed to stdout by the program above).

jaseg commented 6 years ago

Could you try capturing some debug log output and post that here?

def my_log(loglevel, component, message):
    print('[{}] {}: {}'.format(loglevel, component, message))

player = mpv.MPV(log_handler=my_log, loglevel='debug')
jaseg commented 6 years ago

I'm closing this for now. Feel free to re-open.