2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-21 07:56:03 +00:00

98_MediaList.pm: new readings: sortby and status for better

integration in FTUI


git-svn-id: https://svn.fhem.de/fhem/trunk@17958 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Tobias.Faust 2018-12-12 10:55:37 +00:00
parent c1e2ce3a42
commit 56835f794c
2 changed files with 31 additions and 17 deletions

View File

@ -1,5 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- feature: 98_MediaList.pm: new readings: sortby and status for better
integration in FTUI
- change: 49_SSCamSTRM: V2.1.0, change get popupStream to set popupStream - change: 49_SSCamSTRM: V2.1.0, change get popupStream to set popupStream
- feature: 49_SSCam: V7.7.0, autocreateCams command added to SVS device, - feature: 49_SSCam: V7.7.0, autocreateCams command added to SVS device,
SSCamSTRM devices have get popupStream command, pls. SSCamSTRM devices have get popupStream command, pls.

View File

@ -237,7 +237,11 @@ sub MediaList_Set($@)
return "no currentdir_playlist available, please select one" if($json eq "[]"); return "no currentdir_playlist available, please select one" if($json eq "[]");
$json = MediaList_playlist_sort($json, $par, "asc"); $json = MediaList_playlist_sort($json, $par, "asc");
readingsSingleUpdate($hash, "currentdir_playlist", $json, 1); readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "currentdir_playlist", $json);
readingsBulkUpdate($hash, "sortby", $par);
readingsEndUpdate($hash, 1);
return undef; return undef;
} }
} }
@ -426,6 +430,11 @@ sub MediaList_PlayListDel($$) {
#################################### ####################################
sub MediaList_call_playlistinfo($$) { sub MediaList_call_playlistinfo($$) {
my ($hash, $object) = @_; my ($hash, $object) = @_;
readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "status", "gathering filelist");
readingsEndUpdate($hash, 1);
#Log 3 , "$device: MediaList_call_playlistinfo"; #Log 3 , "$device: MediaList_call_playlistinfo";
$hash->{helper}{RUNNING_PID} = BlockingCall("MediaList_CollectID3Tags", $hash->{NAME}."|".$object, "MediaList_done_playlistinfo", 120); #, "MediaList_AbortFn", $hash $hash->{helper}{RUNNING_PID} = BlockingCall("MediaList_CollectID3Tags", $hash->{NAME}."|".$object, "MediaList_done_playlistinfo", 120); #, "MediaList_AbortFn", $hash
return undef; return undef;
@ -453,6 +462,8 @@ sub MediaList_done_playlistinfo($) {
readingsBeginUpdate($hash); readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "currentdir_playlist", $playlist); readingsBulkUpdate($hash, "currentdir_playlist", $playlist);
readingsBulkUpdate($hash, "currentdir_playlistduration", $playlistduration); readingsBulkUpdate($hash, "currentdir_playlistduration", $playlistduration);
readingsBulkUpdate($hash, "sortby", "File");
readingsBulkUpdate($hash, "status", "idle");
readingsEndUpdate($hash, 1); readingsEndUpdate($hash, 1);
@ -516,26 +527,27 @@ sub MediaList_CollectID3Tags ($) {
while(my $filename = readdir($dh)) { while(my $filename = readdir($dh)) {
#undef($cover); $cover darf nicht gelöscht werden, das erste gefundene Cover für diesen Folder soll für den Rest weiterverwendet werden #undef($cover); $cover darf nicht gelöscht werden, das erste gefundene Cover für diesen Folder soll für den Rest weiterverwendet werden
if($filename !~ m/^[\.]+/) { if($filename !~ m/^[\.]+/) {
#Log3 $device, 3, "$device -> Datei: ".$filename; #Log3 $device, 3, "$device -> Datei: ".$filename;
$content = MediaList_GetMP3Tags($device, $object."/".$filename); $content = MediaList_GetMP3Tags($device, $object."/".$filename);
if($content) { if($content) {
Log3 $device, 4, "MP3-Tags für \"".$object."/".$filename."\" gefunden: ".$content->{Artist}. " , " .$content->{Album}; Log3 $device, 4, "MP3-Tags für \"".$object."/".$filename."\" gefunden: ".$content->{Artist}. " , " .$content->{Album};
$cover = $covers{uri_escape($content->{Artist}.$content->{Album})} if($covers{uri_escape($content->{Artist}.$content->{Album})}); $cover = $covers{uri_escape($content->{Artist}.$content->{Album})} if($covers{uri_escape($content->{Artist}.$content->{Album})});
if (!$cover) { if (!$cover) {
Log3 $device, 4, "Lade Cover: ".$content->{Artist}. " , " .$content->{Album}; Log3 $device, 4, "Lade Cover: ".$content->{Artist}. " , " .$content->{Album};
$cover = MediaList_GetCover($device, $content->{File}, $content->{Artist}, $content->{Album}); $cover = MediaList_GetCover($device, $content->{File}, $content->{Artist}, $content->{Album});
$cover="images/cd-empty.png" if(!$cover); $cover="images/cd-empty.png" if(!$cover);
$covers{uri_escape($content->{Artist}.$content->{Album})} = $cover; $covers{uri_escape($content->{Artist}.$content->{Album})} = $cover;
} }
$content->{Cover}=$cover; $content->{Cover}=$cover;
Log3 $device, 5, "CollectID3Tags: ".Dumper($content); Log3 $device, 5, "CollectID3Tags: ".Dumper($content);
push(@data, $content); push(@data, $content);
# informiere Parent, aktualisiere playlist wenn Ausführung > 1sek # informiere Parent, aktualisiere playlist wenn Ausführung > 1sek
if(time() - $time >= 1) { if(time() - $time >= 1) {
BlockingInformParent("MediaList_readingsSingleUpdateByName", [$device, "currentdir_playlist", JSON::XS->new->encode(\@data)], 0); # manchmal wird danach die gesamte Liste nicht nochmal erneuert sodass diese unvollständig bleibt :(
$time = time(); #BlockingInformParent("MediaList_readingsSingleUpdateByName", [$device, "currentdir_playlist", JSON::XS->new->encode(\@data)], 0);
} $time = time();
} }
}
} }
} }
closedir($dh); # nicht vergessen closedir($dh); # nicht vergessen