-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSquairPlay.pm
executable file
·89 lines (57 loc) · 1.91 KB
/
SquairPlay.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package Plugins::SquairPlay::SquairPlay;
# SquairPlay URL protocol handler
use strict;
use Slim::Utils::Misc;
use Slim::Utils::Log;
use Slim::Utils::Prefs;
use base qw(Slim::Player::Pipeline);
my $log = logger('plugin.squairplay');
my $prefs = preferences('server');
# register protocol handler
$log->info( "SquairPlay - register protocol");
Slim::Player::ProtocolHandlers->registerHandler("squairplay", __PACKAGE__);
# new is called by openRemoteStream() for URLs with "squairplay:" protocol prefix
sub isRemote { 1 }
sub new {
$log->info( "SquairPlay - new openRemoteStream begin...");
my $class = shift;
my $args = shift;
my $transcoder = $args->{'transcoder'};
my $url = $args->{'url'} ;
my $client = $args->{'client'};
Slim::Music::Info::setContentType($url, 'squairplay');
my $quality = preferences('server')->client($client)->get('lameQuality');
my $command = Slim::Player::TranscodingHelper::tokenizeConvertCommand2( $transcoder, $url, $url, 1, $quality );
#$log->info("SquairPlay command: $command");
my $self = $class->SUPER::new(undef, $command);
${*$self}{'contentType'} = $transcoder->{'streamformat'};
$log->info("SquairPlay - new openRemoteStream ...end");
return $self;
}
sub canHandleTranscode {
my ($self, $song) = @_;
return 1;
}
sub getStreamBitrate {
my ($self, $maxRate) = @_;
return Slim::Player::Song::guessBitrateFromFormat(${*$self}{'contentType'}, $maxRate);
}
sub contentType
{
my $self = shift;
return ${*$self}{'contentType'};
}
sub isAudioURL { 1 }
# XXX - I think that we scan the track twice, once from the playlist and then again when playing
sub scanUrl {
my ( $class, $url, $args ) = @_;
Slim::Utils::Scanner::Remote->scanURL($url, $args);
}
sub canDirectStream {
return 0;
}
sub contentType {
my $self = shift;
return ${*$self}{'contentType'};
}
1;