This repository has been archived by the owner on Jul 28, 2024. It is now read-only.
forked from StuartUSA/shairport_plugin
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAIRPLAY.pm
executable file
·103 lines (74 loc) · 2.24 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
91
92
93
94
95
96
97
98
99
100
101
102
103
package Plugins::ShairTunes2::AIRPLAY;
use strict;
use warnings;
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 ) = @_;
my %metaData = Plugins::ShairTunes2::Plugin->getAirTunesMetaData();
my $metaArtist = $metaData{artist};
my $metaTitle = $metaData{title};
my $metaAlbum = $metaData{album};
my $metaBitRate = $metaData{bitrate};
my $metaCover = $metaData{cover};
my $metaDuration = $metaData{duration};
my $metaPosition = $metaData{position};
$client->streamingSong->duration( $metaDuration );
$client->playingSong()->startOffset( $metaPosition );
return {
artist => $metaArtist,
title => $metaTitle,
album => $metaAlbum,
bitrate => $metaBitRate,
cover => $metaCover,
icon => $metaCover,
type => 'ShairTunes Stream',
}
}
1;
# Local Variables:
# tab-width:4
# indent-tabs-mode:t
# End: