Am 01.06.19 um 16:05 schrieb afriend:
mherger wrote:
if you set up $log correctly
It's logging now, mostly. I guess LMS got a bit crazy from all of my
endless and quick restarting after every plugin code change.
I have some code for letting the MusicInfoScreen display a character
when the song is in my virtual library 'Favs'.
Code:
--------------------
sub checkIfInVirtualLibrary
{ my $thistrackID = ### how do I get the track_id of the
currently playing song (on the client)???
my $LibID = { library_id =>
Slim::Music::VirtualLibraries->getRealId('FAVS') }; ### this only gets me a
HASH(0x5bc123456789) value
my $sql = "SELECT COUNT(1) FROM library_track WHERE library_track.library = '2a111f4b' AND library_track.track = '1234657'"; ### the sql query with these specific values works and returns 1 if song is part of VL
my $sth = Slim::Schema->dbh->prepare( $sql );
my $result = undef;
$sth->execute();
my $IsPartOfVirtualLibrary;
$sth->bind_columns( undef, \$IsPartOfVirtualLibrary );
if($sth->fetch()) {
$log->warn("IsPartOfVirtualLibrary =
".$IsPartOfVirtualLibrary);
}else {
$log->warn("IsPartOfVirtualLibrary =
".$IsPartOfVirtualLibrary);
#$IsPartOfVirtualLibrary = 0;
}
my $string = '';
if ($IsPartOfVirtualLibrary == 1) {
$string='*';
}else {
$string='';
}
$sth->finish();
return $string;
}
--------------------
1) I need to -get the trackID- of the currently playing song for the sql
query. I couldn't get this to work.
Depending on where you do this you might need to get the currently
playing song from the $client object, then the corresponding track
object, from which you'd get the id. Something like:
$client->playingSong()->currentTrack()->id()
I haven't tested this. If it doesn't work, I suggest you investigate
what you get for the playingSong(), then the currentTrack() etc.
2) The getRealID returns a HASH value for the virtual library ID and I
That's because you define it as a hash:
my $LibID = { library_id =>
Slim::Music::VirtualLibraries->getRealId('FAVS') };
That's how you create a hash ref with one value with the key
"library_id". What you need obviously is the result of getRealId() only:
my $LibID = Slim::Music::VirtualLibraries->getRealId('FAVS');
--
Michael
_______________________________________________
discuss mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/discuss