2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

contrib/98_SB_PLAYER.pm: fixes and performance improvements for TabletUI readings

git-svn-id: https://svn.fhem.de/fhem/trunk@14963 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
ChrisD 2017-08-26 19:46:07 +00:00
parent 2605c44b4e
commit 0c8cc529d5

View File

@ -174,7 +174,7 @@ sub SB_PLAYER_Initialize( $ ) {
$hash->{AttrList} .= "updateReadingsOnSet:true,false "; # CD 0017 $hash->{AttrList} .= "updateReadingsOnSet:true,false "; # CD 0017
$hash->{AttrList} .= "statusRequestInterval "; # CD 0037 $hash->{AttrList} .= "statusRequestInterval "; # CD 0037
$hash->{AttrList} .= "syncedNamesSource:LMS,FHEM "; # CD 0055 $hash->{AttrList} .= "syncedNamesSource:LMS,FHEM "; # CD 0055
$hash->{AttrList} .= "ftuiSupport:1,0 "; # CD 0065 $hash->{AttrList} .= "ftuiSupport:multiple-strict,1,0,medialist,favorites,playlists "; # CD 0065 neu # CD 0086 Auswahl hinzugefügt
$hash->{AttrList} .= $readingFnAttributes; $hash->{AttrList} .= $readingFnAttributes;
# CD 0036 aus 37_sonosBookmarker # CD 0036 aus 37_sonosBookmarker
@ -348,22 +348,34 @@ sub SB_PLAYER_Attr( @ ) {
my $dodelete=0; my $dodelete=0;
if( $cmd eq "set" ) { if( $cmd eq "set" ) {
if ($args[1] eq "0") { # CD 0086 Readings einzeln aktivierbar
$dodelete=1; my @options=split(',',$args[1]);
} elsif ($args[1] eq "1") { delete($hash->{helper}{ftuiSupport}) if(defined($hash->{helper}{ftuiSupport}));
$hash->{helper}{ftuiSupport}{enable}=($args[1] eq '0')?0:1;
for my $opt (@options) {
$hash->{helper}{ftuiSupport}{favorites}=1 if($opt=~ m/favorites/)||($opt eq '1');
$hash->{helper}{ftuiSupport}{playlists}=1 if($opt=~ m/playlists/)||($opt eq '1');
$hash->{helper}{ftuiSupport}{medialist}=1 if($opt=~ m/medialist/)||($opt eq '1');
}
if(defined($hash->{helper}{ftuiSupport})) {
# CD 0082 Readings setzen (kein manueller statusRequest mehr nötig) # CD 0082 Readings setzen (kein manueller statusRequest mehr nötig)
readingsBeginUpdate( $hash ); readingsBeginUpdate( $hash );
my $t=$hash->{FAVSTR}; if(defined($hash->{helper}{ftuiSupport}{favorites})) {
$t=~s/,/:/g; my $t=$hash->{FAVSTR};
readingsBulkUpdate( $hash, "ftuiFavoritesItems", $t ); $t=~s/,/:/g;
$t=~s/_/ /g; readingsBulkUpdate( $hash, "ftuiFavoritesItems", $t );
readingsBulkUpdate( $hash, "ftuiFavoritesAlias", $t ); $t=~s/_/ /g;
readingsBulkUpdate( $hash, "ftuiFavoritesAlias", $t );
$t=$hash->{SERVERPLAYLISTS}; }
$t=~s/,/:/g; if(defined($hash->{helper}{ftuiSupport}{playlists})) {
readingsBulkUpdate( $hash, "ftuiPlaylistsItems", $t ); my $t=$hash->{SERVERPLAYLISTS};
$t=~s/_/ /g; $t=~s/,/:/g;
readingsBulkUpdate( $hash, "ftuiPlaylistsAlias", $t ); readingsBulkUpdate( $hash, "ftuiPlaylistsItems", $t );
$t=~s/_/ /g;
readingsBulkUpdate( $hash, "ftuiPlaylistsAlias", $t );
}
if( AttrVal( $name, "donotnotify", "false" ) eq "true" ) { if( AttrVal( $name, "donotnotify", "false" ) eq "true" ) {
readingsEndUpdate( $hash, 0 ); readingsEndUpdate( $hash, 0 );
} else { } else {
@ -372,23 +384,35 @@ sub SB_PLAYER_Attr( @ ) {
# CD 0082 end # CD 0082 end
delete($hash->{SONGINFOQUEUE}) if(defined($hash->{SONGINFOQUEUE})); # CD 0072 delete($hash->{SONGINFOQUEUE}) if(defined($hash->{SONGINFOQUEUE})); # CD 0072
if(defined($hash->{helper}{playlistIds})) { $hash->{helper}{songinfoquery}=''; # CD 0084
$hash->{helper}{playlistInfoRetries}=5; # CD 0076 $hash->{helper}{songinfocounter}=0; # CD 0084
my @ids=split(',',$hash->{helper}{playlistIds}); $hash->{helper}{songinfopending}=0; # CD 0084
foreach(@ids) { if(defined($hash->{helper}{ftuiSupport}{medialist})) {
IOWrite( $hash, $hash->{PLAYERMAC}." songinfo 0 100 track_id:".$_." tags:acdltuxNK\n" ) unless((defined($hash->{helper}{playlistInfo}{$_}) && !defined($hash->{helper}{playlistInfo}{$_}{remote})) || ($_==0)); if(defined($hash->{helper}{playlistIds})) {
$hash->{helper}{playlistInfoRetries}=5; # CD 0076
my @ids=split(',',$hash->{helper}{playlistIds});
foreach(@ids) {
# CD 0084 verzögert abfragen, ansonsten Probleme bei schwacher Hardware
SB_PLAYER_SonginfoAddQueue($hash,$_,0) unless((defined($hash->{helper}{playlistInfo}{$_}) && !defined($hash->{helper}{playlistInfo}{$_}{remote})) || ($_==0));
}
SB_PLAYER_SonginfoAddQueue($hash,0,0);
} }
IOWrite( $hash, $hash->{PLAYERMAC}." FHEMupdatePlaylistInfoDone\n" );
} }
} }
} else { } else {
delete($hash->{helper}{ftuiSupport}) if(defined($hash->{helper}{ftuiSupport}));
$hash->{helper}{ftuiSupport}{enable}=0;
$dodelete=1; $dodelete=1;
} }
# CD 0068 start # CD 0068 start
if($dodelete==1) { if(($dodelete==1)||!defined($hash->{helper}{ftuiSupport}{medialist})) {
delete($hash->{READINGS}{ftuiMedialist}) if defined($hash->{READINGS}{ftuiMedialist}); delete($hash->{READINGS}{ftuiMedialist}) if defined($hash->{READINGS}{ftuiMedialist});
}
if(($dodelete==1)||!defined($hash->{helper}{ftuiSupport}{playlists})) {
delete($hash->{READINGS}{ftuiPlaylistsItems}) if defined($hash->{READINGS}{ftuiPlaylistsItems}); delete($hash->{READINGS}{ftuiPlaylistsItems}) if defined($hash->{READINGS}{ftuiPlaylistsItems});
delete($hash->{READINGS}{ftuiPlaylistsAlias}) if defined($hash->{READINGS}{ftuiPlaylistsAlias}); delete($hash->{READINGS}{ftuiPlaylistsAlias}) if defined($hash->{READINGS}{ftuiPlaylistsAlias});
}
if(($dodelete==1)||!defined($hash->{helper}{ftuiSupport}{favorites})) {
delete($hash->{READINGS}{ftuiFavoritesItems}) if defined($hash->{READINGS}{ftuiFavoritesItems}); delete($hash->{READINGS}{ftuiFavoritesItems}) if defined($hash->{READINGS}{ftuiFavoritesItems});
delete($hash->{READINGS}{ftuiFavoritesAlias}) if defined($hash->{READINGS}{ftuiFavoritesAlias}); delete($hash->{READINGS}{ftuiFavoritesAlias}) if defined($hash->{READINGS}{ftuiFavoritesAlias});
} }
@ -713,6 +737,10 @@ sub SB_PLAYER_Define( $$ ) {
$hash->{helper}{lmsvolume}=0; # CD 0065 $hash->{helper}{lmsvolume}=0; # CD 0065
} }
$hash->{helper}{songinfoquery}=''; # CD 0084
$hash->{helper}{songinfocounter}=0; # CD 0084
$hash->{helper}{songinfopending}=0; # CD 0084
# do and update of the status # do and update of the status
InternalTimer( gettimeofday() + 10, InternalTimer( gettimeofday() + 10,
"SB_PLAYER_GetStatus", "SB_PLAYER_GetStatus",
@ -1124,26 +1152,28 @@ sub SB_PLAYER_Parse( $$ ) {
} }
# CD 0039 end # CD 0039 end
} elsif( $args[ 0 ] eq "shuffle" ) { } elsif( $args[ 0 ] eq "shuffle" ) {
if( $args[ 1 ] eq "0" ) { if(defined($args[ 1 ])) { # CD 0086
readingsBulkUpdate( $hash, "shuffle", "off" ); if( $args[ 1 ] eq "0" ) {
} elsif( $args[ 1 ] eq "1") { readingsBulkUpdate( $hash, "shuffle", "off" );
readingsBulkUpdate( $hash, "shuffle", "song" ); } elsif( $args[ 1 ] eq "1") {
} elsif( $args[ 1 ] eq "2") { readingsBulkUpdate( $hash, "shuffle", "song" );
readingsBulkUpdate( $hash, "shuffle", "album" ); } elsif( $args[ 1 ] eq "2") {
} else { readingsBulkUpdate( $hash, "shuffle", "album" );
readingsBulkUpdate( $hash, "shuffle", "?" ); } else {
} readingsBulkUpdate( $hash, "shuffle", "?" );
# CD 0039 Änderung am Master, gesyncte Player aktualisieren }
if ($hash->{PLAYERMAC} eq $hash->{SYNCMASTER}) { # CD 0039 Änderung am Master, gesyncte Player aktualisieren
if (defined($hash->{SYNCGROUP}) && ($hash->{SYNCGROUP} ne '?') && ($hash->{SYNCMASTER} ne 'none')) { if ($hash->{PLAYERMAC} eq $hash->{SYNCMASTER}) {
my @pl=split(",",$hash->{SYNCGROUP}); if (defined($hash->{SYNCGROUP}) && ($hash->{SYNCGROUP} ne '?') && ($hash->{SYNCMASTER} ne 'none')) {
foreach (@pl) { my @pl=split(",",$hash->{SYNCGROUP});
IOWrite( $hash, "$_ playlist shuffle ?\n" ); foreach (@pl) {
IOWrite( $hash, "$_ playlist shuffle ?\n" );
}
} }
} }
# CD 0039 end
SB_PLAYER_GetStatus( $hash ); # CD 0014
} }
# CD 0039 end
SB_PLAYER_GetStatus( $hash ); # CD 0014
} elsif( $args[ 0 ] eq "name" ) { } elsif( $args[ 0 ] eq "name" ) {
# CD 0014 start # CD 0014 start
$queryMode=0; $queryMode=0;
@ -1202,6 +1232,10 @@ sub SB_PLAYER_Parse( $$ ) {
} elsif( $args[ 0 ] eq "clear" ) { } elsif( $args[ 0 ] eq "clear" ) {
readingsBulkUpdate( $hash, "currentPlaylistName", "none" ); readingsBulkUpdate( $hash, "currentPlaylistName", "none" );
readingsBulkUpdate( $hash, "playlists", "none" ); readingsBulkUpdate( $hash, "playlists", "none" );
readingsBulkUpdate( $hash, "playlistTracks", 0 ); # CD 0084
readingsBulkUpdate( $hash, "duration", 0 ); # CD 0084
$hash->{helper}{playlistIds}='0'; # CD 0084
readingsBulkUpdate( $hash, "ftuiMedialist", '[{"Artist":"-","Title":"-","Album":"-","Time":"0","File":"-","Track":"0","Cover":"-"}]') if(defined($hash->{helper}{ftuiSupport}{medialist})); # CD 0084
# CD 0009 end # CD 0009 end
SB_PLAYER_GetStatus( $hash ); # CD 0014 SB_PLAYER_GetStatus( $hash ); # CD 0014
} elsif( $args[ 0 ] eq "url" ) { } elsif( $args[ 0 ] eq "url" ) {
@ -1311,10 +1345,18 @@ sub SB_PLAYER_Parse( $$ ) {
} elsif( $cmd eq "title" ) { } elsif( $cmd eq "title" ) {
readingsBulkUpdate( $hash, "currentTitle", join( " ", @args ) ); readingsBulkUpdate( $hash, "currentTitle", join( " ", @args ) );
SB_PLAYER_ftuiMedialist( $hash ) if(AttrVal($name,"ftuiSupport","") eq "1"); # CD 0082 RemoveInternalTimer( "ftuiMedialist:$name"); # CD 0085
InternalTimer( gettimeofday() + 0.01, # CD 0085
"SB_PLAYER_tcb_ftuiMedialist",
"ftuiMedialist:$name",
0 ) if(defined($hash->{helper}{ftuiSupport}{medialist})); # CD 0082
} elsif( $cmd eq "artist" ) { } elsif( $cmd eq "artist" ) {
readingsBulkUpdate( $hash, "currentArtist", join( " ", @args ) ); readingsBulkUpdate( $hash, "currentArtist", join( " ", @args ) );
SB_PLAYER_ftuiMedialist( $hash ) if(AttrVal($name,"ftuiSupport","") eq "1"); # CD 0082 RemoveInternalTimer( "ftuiMedialist:$name");
InternalTimer( gettimeofday() + 0.01,
"SB_PLAYER_tcb_ftuiMedialist",
"ftuiMedialist:$name",
0 ) if(defined($hash->{helper}{ftuiSupport}{medialist})); # CD 0082
} elsif( $cmd eq "album" ) { } elsif( $cmd eq "album" ) {
readingsBulkUpdate( $hash, "currentAlbum", join( " ", @args ) ); readingsBulkUpdate( $hash, "currentAlbum", join( " ", @args ) );
@ -1761,7 +1803,8 @@ sub SB_PLAYER_Parse( $$ ) {
my $flush=0; my $flush=0;
#Log3( $hash, 3, "SB_PLAYER_Parse: $name: parsing songinfo: $msg" ); # CD 0072 #Log3( $hash, 3, "SB_PLAYER_Parse: $name: parsing songinfo: $msg" ); # CD 0072
$hash->{helper}{songinfopending}--; # CD 0084
foreach( @args ) { foreach( @args ) {
$flush=0; $flush=0;
if( $_ =~ /^(id:)(-?[0-9]*)/ ) { if( $_ =~ /^(id:)(-?[0-9]*)/ ) {
@ -1839,7 +1882,12 @@ sub SB_PLAYER_Parse( $$ ) {
# if (rand() > 0.4) {delete $hash->{helper}{playlistInfo}{$trackid}}; # if (rand() > 0.4) {delete $hash->{helper}{playlistInfo}{$trackid}};
# TEST # TEST
} elsif( $cmd eq "FHEMupdatePlaylistInfoDone" ) { } elsif( $cmd eq "FHEMupdatePlaylistInfoDone" ) {
SB_PLAYER_ftuiMedialist( $hash ); $hash->{helper}{songinfopending}=0; # CD 0084
RemoveInternalTimer( "ftuiMedialist:$name"); # CD 0085
InternalTimer( gettimeofday() + 0.01, # CD 0085
"SB_PLAYER_tcb_ftuiMedialist",
"ftuiMedialist:$name",
0 );
# CD 0065 end # CD 0065 end
} elsif( $cmd eq "NONE" ) { } elsif( $cmd eq "NONE" ) {
# we shall never end up here, as cmd=NONE is used by the server for # we shall never end up here, as cmd=NONE is used by the server for
@ -1864,6 +1912,38 @@ sub SB_PLAYER_Parse( $$ ) {
return( $name ); return( $name );
} }
# CD 0085
# ----------------------------------------------------------------------------
# delay building ftuiMedialist reading
# ----------------------------------------------------------------------------
sub SB_PLAYER_tcb_ftuiMedialist( $ ) {
my($in ) = shift;
my(undef,$name) = split(':',$in);
my $hash = $defs{$name};
if(defined($hash->{helper}{ftuiSupport}{medialist})) {
my $t31=time;
readingsBeginUpdate( $hash );
if((time-$t31)>0.5) {
Log3($hash,3,"SB_PLAYER_tcb_ftuiMedialist($name), time:".int((time-$t31)*1000)."ms cmd: prepare FHEM event handling");
}
$t31=time;
SB_PLAYER_ftuiMedialist($hash);
if((time-$t31)>0.5) {
Log3($hash,3,"SB_PLAYER_tcb_ftuiMedialist($name), time:".int((time-$t31)*1000)."ms cmd: SB_PLAYER_ftuiMedialist");
}
$t31=time;
if( AttrVal( $name, "donotnotify", "false" ) eq "true" ) {
readingsEndUpdate( $hash, 0 );
} else {
readingsEndUpdate( $hash, 1 );
}
if((time-$t31)>0.5) {
Log3($hash,3,"SB_PLAYER_tcb_ftuiMedialist($name), time:".int((time-$t31)*1000)."ms cmd: execute FHEM event handling");
}
}
}
# CD 0082 # CD 0082
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# build ftuiMedialist reading # build ftuiMedialist reading
@ -1917,24 +1997,29 @@ sub SB_PLAYER_ftuiMedialist($) {
} }
} else { } else {
$ftuimedialist.="{\"Artist\":\"-\","; $ftuimedialist.="{\"Artist\":\"-\",";
if($hash->{helper}{playlistInfoRetries}>0) { # CD 0076
SB_PLAYER_SonginfoAddQueue($hash,$_,$wait) unless ($_==0); # CD 0072 # CD 0076
$wait=0;
# CD 0084 start
if(ReadingsVal($name,'playlistTracks',0) eq '0') {
$ftuimedialist.="\"Title\":\"-\",";
} else {
# CD 0084 end
$ftuimedialist.="\"Title\":\"loading...\",";
}
} else {
$ftuimedialist.="\"Title\":\"no data\","; # CD 0076
Log3( $hash, 3, "SB_PLAYER_Parse: $name: no songinfo for id $_" ); # CD 0072
}
$ftuimedialist.="\"Album\":\"-\","; $ftuimedialist.="\"Album\":\"-\",";
$ftuimedialist.="\"Time\":\"0\","; $ftuimedialist.="\"Time\":\"0\",";
$ftuimedialist.="\"File\":\"-\","; $ftuimedialist.="\"File\":\"-\",";
$ftuimedialist.="\"Track\":\"0\","; $ftuimedialist.="\"Track\":\"0\",";
$ftuimedialist.="\"Cover\":\"-\"},"; $ftuimedialist.="\"Cover\":\"-\"},";
if($hash->{helper}{playlistInfoRetries}>0) { # CD 0076
SB_PLAYER_SonginfoAddQueue($hash,$_,$wait) unless ($_==0); # CD 0072 # CD 0076
$wait=0;
$ftuimedialist.="\"Title\":\"loading...\",";
} else {
$ftuimedialist.="\"Title\":\"no data\","; # CD 0076
Log3( $hash, 3, "SB_PLAYER_Parse: $name: no songinfo for id $_" ); # CD 0072
}
} }
$trackcounter+=1; # CD 0082 $trackcounter+=1; # CD 0082
} }
$ftuimedialist=~s/,$/]/; $ftuimedialist=~s/,$/]/;
#Log 0,$ftuimedialist;
readingsBulkUpdate( $hash, "ftuiMedialist", $ftuimedialist ); readingsBulkUpdate( $hash, "ftuiMedialist", $ftuimedialist );
} }
# CD 0082 end # CD 0082 end
@ -2221,6 +2306,11 @@ sub SB_PLAYER_Notify( $$ ) {
# CD 0077 unbenutzte Attribute entfernen # CD 0077 unbenutzte Attribute entfernen
$modules{$hash->{TYPE}}{AttrList} =~ s/serverautoon.//; $modules{$hash->{TYPE}}{AttrList} =~ s/serverautoon.//;
$modules{$hash->{TYPE}}{AttrList} =~ s/idismac.//; $modules{$hash->{TYPE}}{AttrList} =~ s/idismac.//;
# CD 0084
InternalTimer( gettimeofday() + 1.0,
"SB_PLAYER_tcb_SonginfoHandleQueue",
"SonginfoHandleQueue:$name",
0 );
} }
# CD 0036 start # CD 0036 start
@ -3052,14 +3142,20 @@ sub SB_PLAYER_Set( $@ ) {
# CD 0065 start # CD 0065 start
} elsif( $cmd eq "updateFTUImedialist" ) { } elsif( $cmd eq "updateFTUImedialist" ) {
delete($hash->{SONGINFOQUEUE}) if(defined($hash->{SONGINFOQUEUE})); # CD 0072 delete($hash->{SONGINFOQUEUE}) if(defined($hash->{SONGINFOQUEUE})); # CD 0072
$hash->{helper}{songinfoquery}=''; # CD 0084
$hash->{helper}{songinfocounter}=0; # CD 0084
$hash->{helper}{songinfopending}=0; # CD 0084
if(defined($hash->{helper}{playlistIds})) { if(defined($hash->{helper}{ftuiSupport}{medialist})) {
$hash->{helper}{playlistInfoRetries}=5; # CD 0076 if(defined($hash->{helper}{playlistIds})) {
my @ids=split(',',$hash->{helper}{playlistIds}); $hash->{helper}{playlistInfoRetries}=5; # CD 0076
foreach(@ids) { my @ids=split(',',$hash->{helper}{playlistIds});
IOWrite( $hash, $hash->{PLAYERMAC}." songinfo 0 100 track_id:".$_." tags:acdltuxNK\n" ) unless(defined($hash->{helper}{playlistInfo}{$_}) && !defined($hash->{helper}{playlistInfo}{$_}{remote}) || ($_==0)); # CD 0076 id 0 ignorieren foreach(@ids) {
# CD 0084 verzögert abfragen, ansonsten Probleme bei schwacher Hardware
SB_PLAYER_SonginfoAddQueue($hash,$_,0) unless(defined($hash->{helper}{playlistInfo}{$_}) && !defined($hash->{helper}{playlistInfo}{$_}{remote}) || ($_==0)); # CD 0076 id 0 ignorieren
}
SB_PLAYER_SonginfoAddQueue($hash,0,0);
} }
IOWrite( $hash, $hash->{PLAYERMAC}." FHEMupdatePlaylistInfoDone\n" );
} }
} elsif( $cmd eq "clearFTUIcache" ) { } elsif( $cmd eq "clearFTUIcache" ) {
delete $hash->{helper}{playlistInfo} if defined($hash->{helper}{playlistInfo}); delete $hash->{helper}{playlistInfo} if defined($hash->{helper}{playlistInfo});
@ -3755,29 +3851,25 @@ sub SB_PLAYER_GetStatus( $ ) {
$hash->{helper}{lastGetStatus}=gettimeofday(); $hash->{helper}{lastGetStatus}=gettimeofday();
# we fire the respective questions and parse the answers in parse # we fire the respective questions and parse the answers in parse
IOWrite( $hash, "$hash->{PLAYERMAC} artist ?\n" ); IOWrite( $hash, "$hash->{PLAYERMAC} artist ?\n".
IOWrite( $hash, "$hash->{PLAYERMAC} album ?\n" ); "$hash->{PLAYERMAC} album ?\n".
IOWrite( $hash, "$hash->{PLAYERMAC} title ?\n" ); "$hash->{PLAYERMAC} title ?\n".
IOWrite( $hash, "$hash->{PLAYERMAC} playlist url ?\n" ); "$hash->{PLAYERMAC} playlist url ?\n".
IOWrite( $hash, "$hash->{PLAYERMAC} remote ?\n" ); "$hash->{PLAYERMAC} remote ?\n".
IOWrite( $hash, "$hash->{PLAYERMAC} status 0 500 tags:Kcu\n" ); # CD 0030 u added to tags "$hash->{PLAYERMAC} status 0 500 tags:Kcu\n". # CD 0030 u added to tags
#IOWrite( $hash, "$hash->{PLAYERMAC} alarm playlists 0 200\n" ) if (!defined($hash->{helper}{alarmPlaylists})); # CD 0016 get available elements for alarms before querying the alarms # CD 0026 wird über Server verteilt #IOWrite( $hash, "$hash->{PLAYERMAC} alarm playlists 0 200\n" ) if (!defined($hash->{helper}{alarmPlaylists})); # CD 0016 get available elements for alarms before querying the alarms # CD 0026 wird über Server verteilt
IOWrite( $hash, "$hash->{PLAYERMAC} alarms 0 200 tags:all filter:all\n" ); # CD 0015 filter added "$hash->{PLAYERMAC} alarms 0 200 tags:all filter:all\n". # CD 0015 filter added
# MM 0016 start # MM 0016 start
IOWrite( $hash, "$hash->{PLAYERMAC} playerpref alarmsEnabled ?\n" ); "$hash->{PLAYERMAC} playerpref alarmsEnabled ?\n".
IOWrite( $hash, "$hash->{PLAYERMAC} playerpref alarmDefaultVolume ?\n" ); "$hash->{PLAYERMAC} playerpref alarmDefaultVolume ?\n".
IOWrite( $hash, "$hash->{PLAYERMAC} playerpref alarmTimeoutSeconds ?\n" ); "$hash->{PLAYERMAC} playerpref alarmTimeoutSeconds ?\n".
IOWrite( $hash, "$hash->{PLAYERMAC} playerpref alarmSnoozeSeconds ?\n" ); "$hash->{PLAYERMAC} playerpref alarmSnoozeSeconds ?\n".
IOWrite( $hash, "$hash->{PLAYERMAC} playerpref alarmfadeseconds ?\n" ); # CD 0082 "$hash->{PLAYERMAC} playerpref alarmfadeseconds ?\n". # CD 0082
# MM 0016 end # MM 0016 end
# CD 0007 "$hash->{PLAYERMAC} playerpref syncVolume ?\n". # CD 0007
IOWrite( $hash, "$hash->{PLAYERMAC} playerpref syncVolume ?\n" ); "$hash->{PLAYERMAC} playlist name ?\n". # CD 0009
# CD 0009 "$hash->{PLAYERMAC} playlist path 0 ?\n". # CD 0048
IOWrite( $hash, "$hash->{PLAYERMAC} playlist name ?\n" ); "$hash->{PLAYERMAC} duration ?\n" ); # CD 0014
# CD 0048
IOWrite( $hash, "$hash->{PLAYERMAC} playlist path 0 ?\n" );
# CD 0014
IOWrite( $hash, "$hash->{PLAYERMAC} duration ?\n" );
SB_PLAYER_QueryElapsedTime($hash); SB_PLAYER_QueryElapsedTime($hash);
} # CD 0014 end } # CD 0014 end
@ -3894,7 +3986,7 @@ sub SB_PLAYER_RecBroadcast( $$@ ) {
# CD 0064 # CD 0064
# CD 0068 start # CD 0068 start
if(AttrVal($name,"ftuiSupport","") eq "1") { if(defined($hash->{helper}{ftuiSupport}{favorites})) {
my $t=$hash->{FAVSTR}; my $t=$hash->{FAVSTR};
$t=~s/,/:/g; $t=~s/,/:/g;
readingsSingleUpdate( $hash, "ftuiFavoritesItems", $t, 1 ); readingsSingleUpdate( $hash, "ftuiFavoritesItems", $t, 1 );
@ -3938,7 +4030,7 @@ sub SB_PLAYER_RecBroadcast( $$@ ) {
} else { } else {
$hash->{FAVSTR} = $favs; $hash->{FAVSTR} = $favs;
} }
if(AttrVal($name,"ftuiSupport","") eq "1") { if(defined($hash->{helper}{ftuiSupport}{favorites})) {
my $t=$hash->{FAVSTR}; my $t=$hash->{FAVSTR};
$t=~s/,/:/g; $t=~s/,/:/g;
readingsSingleUpdate( $hash, "ftuiFavoritesItems", $t, 1 ); readingsSingleUpdate( $hash, "ftuiFavoritesItems", $t, 1 );
@ -4016,7 +4108,7 @@ sub SB_PLAYER_RecBroadcast( $$@ ) {
# CD 0064 # CD 0064
# CD 0068 start # CD 0068 start
if(AttrVal($name,"ftuiSupport","") eq "1") { if(defined($hash->{helper}{ftuiSupport}{playlists})) {
my $t=$hash->{SERVERPLAYLISTS}; my $t=$hash->{SERVERPLAYLISTS};
$t=~s/,/:/g; $t=~s/,/:/g;
readingsSingleUpdate( $hash, "ftuiPlaylistsItems", $t, 1 ); readingsSingleUpdate( $hash, "ftuiPlaylistsItems", $t, 1 );
@ -4062,7 +4154,7 @@ sub SB_PLAYER_RecBroadcast( $$@ ) {
$hash->{SERVERPLAYLISTS}=$pls; $hash->{SERVERPLAYLISTS}=$pls;
} }
if(AttrVal($name,"ftuiSupport","") eq "1") { if(defined($hash->{helper}{ftuiSupport}{playlists})) {
my $t=$hash->{SERVERPLAYLISTS}; my $t=$hash->{SERVERPLAYLISTS};
$t=~s/,/:/g; $t=~s/,/:/g;
readingsSingleUpdate( $hash, "ftuiPlaylistsItems", $t, 1 ); readingsSingleUpdate( $hash, "ftuiPlaylistsItems", $t, 1 );
@ -4813,16 +4905,20 @@ sub SB_PLAYER_ParsePlayerStatus( $$ ) {
$hash->{helper}{playerStatusOK}=1; # CD 0042 $hash->{helper}{playerStatusOK}=1; # CD 0042
# CD 0065 start # CD 0065 start
if(AttrVal($name,"ftuiSupport","") eq "1") { if(defined($hash->{helper}{ftuiSupport}{medialist})) {
delete($hash->{SONGINFOQUEUE}) if(defined($hash->{SONGINFOQUEUE})); # CD 0072 delete($hash->{SONGINFOQUEUE}) if(defined($hash->{SONGINFOQUEUE})); # CD 0072
$hash->{helper}{songinfoquery}=''; # CD 0084
$hash->{helper}{songinfocounter}=0; # CD 0084
$hash->{helper}{songinfopending}=0; # CD 0084
if(defined($hash->{helper}{playlistIds})) { if(defined($hash->{helper}{playlistIds})) {
$hash->{helper}{playlistInfoRetries}=5; # CD 0076 $hash->{helper}{playlistInfoRetries}=5; # CD 0076
my @ids=split(',',$hash->{helper}{playlistIds}); my @ids=split(',',$hash->{helper}{playlistIds});
foreach(@ids) { foreach(@ids) {
IOWrite( $hash, $hash->{PLAYERMAC}." songinfo 0 100 track_id:".$_." tags:acdltuxNK\n" ) unless((defined($hash->{helper}{playlistInfo}{$_}) && !defined($hash->{helper}{playlistInfo}{$_}{remote})) || ($_==0)); # CD 0071, id 0 ignorieren # SB_PLAYER_SonginfoAddQueue($hash,$_,0) unless ($_==0); # CD 0083
SB_PLAYER_SonginfoAddQueue($hash,$_,0) unless((defined($hash->{helper}{playlistInfo}{$_}) && !defined($hash->{helper}{playlistInfo}{$_}{remote})) || ($_==0)); # CD 0084
} }
IOWrite( $hash, $hash->{PLAYERMAC}." FHEMupdatePlaylistInfoDone\n" ); SB_PLAYER_SonginfoAddQueue($hash,0,0);
} }
} }
# CD 0065 end # CD 0065 end
@ -5103,10 +5199,12 @@ SB_PLAYER_SonginfoAddQueue($$$) ################################################
$hash->{SONGINFOQUEUE} = [ $id ]; $hash->{SONGINFOQUEUE} = [ $id ];
push(@{$hash->{SONGINFOQUEUE}}, $id); push(@{$hash->{SONGINFOQUEUE}}, $id);
RemoveInternalTimer( "SonginfoHandleQueue:$name"); RemoveInternalTimer( "SonginfoHandleQueue:$name");
InternalTimer( gettimeofday() + ($wait==1?2.0:0.01), if ($init_done>0) { # CD 0084
"SB_PLAYER_tcb_SonginfoHandleQueue", InternalTimer( gettimeofday() + ($wait==1?2.0:0.01),
"SonginfoHandleQueue:$name", "SB_PLAYER_tcb_SonginfoHandleQueue",
0 ); "SonginfoHandleQueue:$name",
0 );
}
} else { } else {
push(@{$hash->{SONGINFOQUEUE}}, "wait") if ($wait==1); push(@{$hash->{SONGINFOQUEUE}}, "wait") if ($wait==1);
push(@{$hash->{SONGINFOQUEUE}}, $id); push(@{$hash->{SONGINFOQUEUE}}, $id);
@ -5121,24 +5219,45 @@ SB_PLAYER_SonginfoHandleQueue($) ###############################################
my $arr = $hash->{SONGINFOQUEUE}; my $arr = $hash->{SONGINFOQUEUE};
if(defined($arr) && @{$arr} > 0) { if(defined($arr) && @{$arr} > 0) {
shift(@{$arr}); if($hash->{helper}{songinfopending}<50) {
if(@{$arr} == 0) { shift(@{$arr});
IOWrite( $hash, $hash->{PLAYERMAC}." FHEMupdatePlaylistInfoDone\n" ); if(@{$arr} == 0) {
delete($hash->{SONGINFOQUEUE}); if($hash->{helper}{songinfocounter}>0) {
return; IOWrite( $hash, $hash->{helper}{songinfoquery});
} $hash->{helper}{songinfopending}+=$hash->{helper}{songinfocounter};
my $id = $arr->[0]; $hash->{helper}{songinfoquery}='';
if($id ne "wait") { $hash->{helper}{songinfocounter}=0;
if(($id eq "") || ($id==0)) { # CD 0076 id 0 ignorieren }
SB_PLAYER_SonginfoHandleQueue($hash); IOWrite( $hash, $hash->{PLAYERMAC}." FHEMupdatePlaylistInfoDone\n" );
} else { delete($hash->{SONGINFOQUEUE});
IOWrite( $hash, $hash->{PLAYERMAC}." songinfo 0 100 track_id:".$id." tags:acdltuxNK\n" ); return;
} }
my $id = $arr->[0];
if($id ne "wait") {
if(($id eq "") || ($id==0)) { # CD 0076 id 0 ignorieren
SB_PLAYER_SonginfoHandleQueue($hash);
} else {
# CD 0084 Abfragen zusammenfassen
$hash->{helper}{songinfoquery}=$hash->{helper}{songinfoquery}.$hash->{PLAYERMAC}." songinfo 0 100 track_id:".$id." tags:acdltuxNK\n";
$hash->{helper}{songinfocounter}++;
if($hash->{helper}{songinfocounter}>=10) {
IOWrite( $hash, $hash->{helper}{songinfoquery});
$hash->{helper}{songinfopending}+=$hash->{helper}{songinfocounter};
$hash->{helper}{songinfoquery}='';
$hash->{helper}{songinfocounter}=0;
}
}
}
InternalTimer( gettimeofday() + (($id eq "wait")?2.0:0.01),
"SB_PLAYER_tcb_SonginfoHandleQueue",
"SonginfoHandleQueue:$name",
0 );
} else {
InternalTimer( gettimeofday() + 0.05,
"SB_PLAYER_tcb_SonginfoHandleQueue",
"SonginfoHandleQueue:$name",
0 );
} }
InternalTimer( gettimeofday() + (($id eq "wait")?2.0:0.01),
"SB_PLAYER_tcb_SonginfoHandleQueue",
"SonginfoHandleQueue:$name",
0 );
} }
} }
@ -5168,6 +5287,7 @@ sub SB_PLAYER_RemoveInternalTimers($) {
RemoveInternalTimer( "TriggerPlaylistStop:$name"); RemoveInternalTimer( "TriggerPlaylistStop:$name");
RemoveInternalTimer( "TriggerTTSDone:$name"); RemoveInternalTimer( "TriggerTTSDone:$name");
RemoveInternalTimer( "recallPause:$name"); RemoveInternalTimer( "recallPause:$name");
RemoveInternalTimer( "ftuiMedialist:$name"); # CD 0085
RemoveInternalTimer( $hash ); RemoveInternalTimer( $hash );
} }
# CD 0078 end # CD 0078 end
@ -5344,8 +5464,9 @@ sub SB_PLAYER_RemoveInternalTimers($) {
Only changes in the readings currentAlbum, currentArtist, currentTitle cause an event.</li><br> Only changes in the readings currentAlbum, currentArtist, currentTitle cause an event.</li><br>
<li>fadeinsecs &lt;sec1&gt;[,&lt;sec2&gt;]<br> <li>fadeinsecs &lt;sec1&gt;[,&lt;sec2&gt;]<br>
Fade-in period in seconds. A second comma separated value optionally specifies the period to use on unpause.</li> Fade-in period in seconds. A second comma separated value optionally specifies the period to use on unpause.</li>
<li>ftuiSupport 0|1<br> <li>ftuiSupport 0|1|favorites|playlists|medialist<br>
If set to 1 additional readings for FTUI integration are created.</li> Create additional readings for FTUI integration. Warning: Using 1 or medialist may cause high cpu usage and unresponsiveness
on slower systems.</li>
<li>sortFavorites 0|1<br> <li>sortFavorites 0|1<br>
If set to 1 the favorites will be sorted alphabetically.</li> If set to 1 the favorites will be sorted alphabetically.</li>
<li>sortPlaylists 0|1<br> <li>sortPlaylists 0|1<br>
@ -5613,8 +5734,9 @@ sub SB_PLAYER_RemoveInternalTimers($) {
Fade in f&uuml;r Beginn von Playlisten und neuen Soundfiles. Bezeichnet die Dauer des Vorganges, in der die Fade in f&uuml;r Beginn von Playlisten und neuen Soundfiles. Bezeichnet die Dauer des Vorganges, in der die
Lautst&auml;rke auf den vorgegebenen Wert ansteigt und wird in Sekunden angegeben. Ein zweiter, durch Komma Lautst&auml;rke auf den vorgegebenen Wert ansteigt und wird in Sekunden angegeben. Ein zweiter, durch Komma
getrennter optionaler Wert, gibt die Dauer des Fadein beim Verlassen des Pausenzustandes an.</li> getrennter optionaler Wert, gibt die Dauer des Fadein beim Verlassen des Pausenzustandes an.</li>
<li>ftuiSupport 0|1<br> <li>ftuiSupport 0|1|favorites|playlists|medialist<br>
Wenn das Attribut den Wert 1 hat werden zus&auml;tzliche Readings f&uuml;r die Integration in FTUI erzeugt.</li> Zus&auml;tzliche Readings f&uuml;r die Integration in FTUI erzeugen. Achtung: Die Verwendung von 1 oder medialist kann kurzzeitig zu
erh&ouml;ter Systemlast und H&auml;ngern auf langsamen Systemen f&uuml;hren.</li>
<li>statusRequestInterval &lt;sec&gt;<br> <li>statusRequestInterval &lt;sec&gt;<br>
Aktualisierungsintervall der automatischen Status-Abfrage. Default: 300</li> Aktualisierungsintervall der automatischen Status-Abfrage. Default: 300</li>
<li>sortFavorites 0|1<br> <li>sortFavorites 0|1<br>