>I think it would therefore be safe to assume that Dynamic Playlist
>functionality doesnt work ;)
I've had a quick look through the code patched it up, so it seems to be working
for me.
I think my changes are limited to the getNextDynamicPlayListTracks method that
Erland pointed me at.
I've added some debug logging.
I changed the line that searches for a random song so that when there's no seed
track it only finds a mixable song from the database (via
'musicmagic_mixable'=>1). I guess you don't want this, as your SugarCube
plugin doesn't rely on the MusicIP plugin having retrieved mixable status?
However, I think this means that it could end up selecting a track that is not
mixable in MIP, and therefore would stop after one song (or does it then select
another random song? Not sure how this works regarding the chosen
filter/recipe settings, i.e. a totally random song may not be a song for the
desired SugarCube settings (filter set to "Rated 5*" for example, and random
song could be anything).
I changed the logic so that it doesn't try to select a similar song for the
random chosen song, as selecttrack only works based on the currently playing
song, but the random song isn't playing yet.
sub getNextDynamicPlayListTracks {
my ($client,$dynamicplaylist,$limit,$offset,$parameters) = @_;
my $song = undef;
my $currentSongTrack = undef;
my $track;
$log->debug("getNextDynamicPlayListTracks");
# If this isn't the first time
if($offset) {
# Base mix of last returned song for this player
$song = $lastDynamicPlaylistTrack{$client};
}
# If this is the first time or no suitable song has been selected yet
if(!defined($song)) {
# Base mix of currently playing song
$currentSongTrack = Slim::Player::Playlist::song($client);
if(defined($currentSongTrack) &&
Slim::Music::Info::isFileURL($currentSongTrack->url)) {
$song = $currentSongTrack->url;
}else {
$currentSongTrack = undef;
}
}
# If no suitable start track was found, base start of mix of a random
track
if(!defined($song)) {
$log->info("no current song, so find a random song");
# Only search for local songs that we know are mixable
$track =
Slim::Schema->rs('Track')->search({'audio'=>1,'remote'=>0,'musicmagic_mixable'=>1},{
'order_by' => \'RAND()'})->first;
$song = $track->url;
$log->info("selected random song is $song");
}
else
{
my $mytitle = SaveMyCurrentTrack($client,$song);
# Strip and Store played track Latin1 format
my $mypageurl = buildMIPReq($client, $mytitle);
# Routine to get MIP settings and build MIP request
my $diditwork = SendtoMIPSync($client,$mypageurl);
if ($diditwork eq 1)
{
$log->debug("SendtoMIPSync worked");
$track = selecttrack($client, \...@unique);
# Randomly select track
$#unique = -1; #
Finished with our Unique Tracks Array, wipe it for reuse
}
else
{
$log->debug("SendtoMIPSync didn't work");
}
}
my @result = ();
if($track) {
$log->debug("returning to Dynamic Playlist $track");
$lastDynamicPlaylistTrack{$client} = $track->url;
# If we started on currently playing song we need to return
that song first
if(defined($currentSongTrack)) {
push @result,$currentSongTrack,
}
# Add new song retreived from MusicIP
push @result,$track;
} else {
$log->error("Couldn't find track for: $track");
}
return \...@result;
}
If you're interested, I can send you my modified Sugarcube 2.03 Plugin.pm file
(or try to make a diff).
_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins