-
Notifications
You must be signed in to change notification settings - Fork 3
/
Plugin.pm
67 lines (51 loc) · 1.44 KB
/
Plugin.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
package Plugins::LocalPlayer::Plugin;
use strict;
use base qw(Slim::Plugin::Base);
use Slim::Utils::Prefs;
use Slim::Utils::Log;
my $prefs = preferences('plugin.localplayer');
$prefs->init({
autorun => 1,
output => '',
opts => '-s 127.0.0.1',
debugs => '',
logging => 0,
loc => 1,
bin => undef
});
my $log = Slim::Utils::Log->addLogCategory({
'category' => 'plugin.localplayer',
'defaultLevel' => 'WARN',
'description' => Slim::Utils::Strings::string('PLUGIN_LOCALPLAYER'),
});
sub initPlugin {
my $class = shift;
$class->SUPER::initPlugin(@_);
if ($prefs->get('loc')) {
require Plugins::LocalPlayer::LocalFile;
Slim::Player::ProtocolHandlers->registerHandler('file', 'Plugins::LocalPlayer::LocalFile');
}
if ($prefs->get('autorun')) {
require Plugins::LocalPlayer::Squeezelite;
Plugins::LocalPlayer::Squeezelite->start;
}
if (main::WEBUI) {
require Plugins::LocalPlayer::Settings;
Plugins::LocalPlayer::Settings->new;
Slim::Web::Pages->addPageFunction("^localplayer.log", \&Plugins::LocalPlayer::Squeezelite::logHandler);
}
isPCP();
}
my $pcpWarning;
sub isPCP {
return $pcpWarning if defined $pcpWarning;
my $osDetails = Slim::Utils::OSDetect::details();
$pcpWarning = lc($osDetails->{osName} || '') eq 'picore' ? 1 : 0;
$pcpWarning && $log->error(Slim::Utils::Strings::string('PLUGIN_LOCALPLAYER_PCP_DETECTED'));
}
sub shutdownPlugin {
if ($prefs->get('autorun')) {
Plugins::LocalPlayer::Squeezelite->stop;
}
}
1;