forked from DSTMK/shairport_plugin
-
Notifications
You must be signed in to change notification settings - Fork 5
/
AIRPLAY.pm
90 lines (60 loc) · 1.53 KB
/
AIRPLAY.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
90
package Plugins::ShairTunes::AIRPLAY;
use strict;
use base qw(Slim::Player::Pipeline);
use Slim::Utils::Strings qw(string);
use Slim::Utils::Misc;
use Slim::Utils::Log;
use Slim::Utils::Prefs;
Slim::Player::ProtocolHandlers->registerHandler('airplay', __PACKAGE__);
my $log = logger('plugin.airplay');
my $prefs = preferences('plugin.airplay');
sub isRemote { 1 }
sub bufferThreshold { 20 }
sub new { undef }
sub canDoAction {
my ( $class, $client, $url, $action ) = @_;
$log->info("Action=$action");
#if (($action eq 'pause') && $prefs->get('pausestop') ) {
# $log->info("Stopping track because pref is set yo stop");
# return 0;
#}
return 1;
}
sub canHandleTranscode {
my ($self, $song) = @_;
return 1;
}
sub getStreamBitrate {
my ($self, $maxRate) = @_;
return Slim::Player::Song::guessBitrateFromFormat(${*$self}{'contentType'}, $maxRate);
}
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 {
my ($class, $client, $url) = @_;
$log->info("canDirectStream $url");
$url =~ s{^airplay://}{http://};
return $url
}
sub contentType
{
my $self = shift;
return ${*$self}{'contentType'};
}
sub getMetadataFor {
my ( $class, $client, $url, $forceCurrent ) = @_;
return {
title => 'ShairTunes',
bitrate => "CD ",
type => 'ShairTunes',
};
}
1;
# Local Variables:
# tab-width:4
# indent-tabs-mode:t
# End: