-
Notifications
You must be signed in to change notification settings - Fork 3
/
LocalFile.pm
39 lines (25 loc) · 1.14 KB
/
LocalFile.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package Plugins::LocalPlayer::LocalFile;
# Subclass of file: protocol handler to allow Squeezelite local players to open the file from disk directly
# When Squeezelite is directly connected it will advertise 'loc' as a format indicating local playback is possible
use strict;
use base qw(Slim::Player::Protocols::File);
use Slim::Utils::Prefs;
my $prefs = preferences('plugin.localplayer');
sub canDirectStreamSong {
my ($class, $client, $song) = @_;
# local player only for players supporting 'loc' and non sync, non seek case, non virtual track (from CUE sheet)
if ($prefs->get('loc') && $client->can('myFormats') && $client->myFormats->[-1] eq 'loc' &&
!$client->isSynced && !$song->seekdata && !$song->track->virtual) {
return "file://127.0.0.1:3483/" . $song->track->url;
}
# fall through to normal server based playback
return 0;
}
sub requestString {
# not implemented in the base class as method is not normally called for file, so no need to fall through
my ($class, $client, $url, undef, $seekdata) = @_;
$url =~ s{^file://127\.0\.0\.1:3483/}{};
my $filepath = Slim::Utils::Misc::pathFromFileURL($url);
return $filepath;
}
1;