Closed galgot closed 1 year ago
Ok, let me make precisions about reading with MPlayer after some tests. It doesn't read exactly 1 mn. It's more that it just doesn't finish the track, stops before the end. Sometime it reads the whole track, but it's completely random...
Edit: Same problem as reported in #1117
Only, MPV can't come to the rescue in my case ... :/
I have the same problem. After the 2 or 3 attempts, the video plays.
@galgot Hi there, I believe I solved the issue with mpv-related audio playback.
The (very small) fix has to be done across two files: $PATH_TO_PYTHON_LIB/python3.9/site-packages/mps_youtube/player.py $PATH_TO_PYTHON_LIB/python3.9/site-packages/mps_youtube/mpris.py
In player.py, BEFORE line 530, which shows the following snippet:
...
if resp.get('event') == 'property-change' and resp['id'] == 1:
if resp['data'] is not None:
elapsed_s = int(resp['data'])
...
Add this snippet:
if 'data' in resp:
In mpris.py, BEFORE line 224, which shows the following snippet:
...
if resp.get('event') == 'property-change':
self.setproperty(resp['name'], resp['data'])
...
Add this snippet:
if 'data' in resp:
The code must look like this:
(player.py)
...
try:
observe_full = False
cmd = {"command": ["observe_property", 1, "time-pos"]}
s.send(json.dumps(cmd).encode() + b'\n')
volume_level = elapsed_s = None
for line in s.makefile():
resp = json.loads(line)
# deals with bug in mpv 0.7 - 0.7.3
if resp.get('event') == 'property-change' and not observe_full:
cmd = {"command": ["observe_property", 2, "volume"]}
s.send(json.dumps(cmd).encode() + b'\n')
observe_full = True
if 'data' in resp:
if resp.get('event') == 'property-change' and resp['id'] == 1:
if resp['data'] is not None:
elapsed_s = int(resp['data'])
elif resp.get('event') == 'property-change' and resp['id'] == 2:
volume_level = int(resp['data'])
if(volume_level and volume_level != g.volume):
g.volume = volume_level
...
(mpris.py)
...
try:
observe_full = False
self._sendcommand(["observe_property", 1, "time-pos"])
for line in self.socket.makefile():
resp = json.loads(line)
# deals with bug in mpv 0.7 - 0.7.3
if resp.get('event') == 'property-change' and not observe_full:
self._sendcommand(["observe_property", 2, "volume"])
self._sendcommand(["observe_property", 3, "pause"])
self._sendcommand(["observe_property", 4, "seeking"])
observe_full = True
if 'data' in resp:
if resp.get('event') == 'property-change':
self.setproperty(resp['name'], resp['data'])
except socket.error:
self.socket = None
self.mpv = False
def bindfifo(self, fifopath, mpv=False):
...
I believe this problem happened as a result of bugfixes to mpv (0.7.x). Do tell if this solves your problem or not.
There's another related issue with mpv, where the following error message comes every time you try playing a track:
Error parsing commandline option title: option requires parameter Make sure you're using e.g. '--title=value' instead of '--title value'
Aren't you facing this?I have a fix for this too, I'll post the patch in the proper issuetracker page.
Side note, I installed mps-youtube via pip.
(Sorry for the reposting, I encountered another error and wan't sure whether this patch was correct)
This is a duplicate of this issue. Apply the changes mentioned in that commit and it should start working as intended.
Hi, as the title says, setting mpv as player and trying to read a track makes mpsyt quit with this error :
If setting player to MPlayer, it reads only 1 minute of the track. I also get this msg before it reads :
This is on a MacBook Pro running Mac OS X 10.11.6. Here infos on the mpsyt install : mpsyt version : 0.2.8 notes : released 17 February 2018 pafy version : 0.5.5 (youtube-dl backend) youtube-dl version : 2020.11.26 Python version : 3.8.5 (default, Sep 9 2020, 23:31:58) [Clang 8.0.0 (clang-800.0.42.1)] Processor : i386 Machine type : x86_64 Architecture : 64bit, Platform : macOS-10.11.6-x86_64-i386-64bit sys.stdout.enc : utf-8 default enc : utf-8 Config dir : /Users/galgot/.config/mps-youtube env:TERM : xterm env:SHELL : /bin/bash env:LANG : fr_FR.UTF-8
MPV is version 0.33.0 and MPlayer is 1.3.0-4.2.1 these are Macports installed.