Skip to content

Commit

Permalink
mpv: fix gapless playback with versions >=0.28.0
Browse files Browse the repository at this point in the history
`tracks-changed` event fires more frequently since 0.28, breaking the
logic here so that all track changes are treated as user-initiated.
The event has also been deprecated for some time, so its behavior is
officially undefined, and we're not supposed to use it.

Instead, we now use the `file-loaded` event which always neatly fires
once per track transition.

Changes should be backwards-compatible (tested with mpv 0.27)
  • Loading branch information
bucaneer authored and squentin committed Apr 17, 2019
1 parent 98ed857 commit 6789521
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions gmusicbrowser_mpv.pm
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,16 @@ sub _remotemsg
elsif (my $event=$msg->{event})
{ if ($event eq 'property-change' && $msg->{name} eq 'path') { $mpv_file= $msg->{data}||""; } # doesn't happen when previous file is same as new file
elsif ($event eq 'start-file') { $File_is_current=0 if $File_is_current<1; }
elsif ($event eq 'tracks-changed' && $File_is_current>=0)
elsif ($event eq 'file-loaded')
{ $File_is_current= $mpv_file eq $gmb_file;
SkipTo(undef,$initseek) if $initseek;
$initseek=undef;
last if $eof; #only do eof now to catch log-message that are only sent after end-file and start-file
}
elsif ($File_is_current<1) {} #ignore all other events unless file is current
elsif ($event eq 'property-change' && $msg->{name} eq 'playback-time' && defined $msg->{data})
{ ::UpdateTime($msg->{data}); }
elsif ($event eq 'end-file') { $eof=1; } # ignore EOF signal on user-initiated track change as $File_is_current is not true in those cases
elsif ($event eq 'file-loaded') { SkipTo(undef,$initseek) if $initseek; $initseek=undef; }
elsif ($event eq 'log-message')
{ my $error= $msg->{text};
chomp $error;
Expand Down

0 comments on commit 6789521

Please sign in to comment.