Home of the Squeezebox™ & Transporter® network music players.
Page 3 of 27 FirstFirst 1234513 ... LastLast
Results 21 to 30 of 263
  1. #21
    Senior Member Philip Meyer's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    5,596

    Announce: Spicefly SugarCube Version 2.03 – (Automatic MusicIP DJ) for 7.x

    >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,$paramete rs) = @_;
    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_mixabl e'=>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).

  2. #22
    Senior Member Philip Meyer's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    5,596

    Announce: Spicefly SugarCube Version 2.03 – (Automatic MusicIP DJ) for 7.x

    >I've had a quick look through the code patched it up, so it seems to be working for me.

    I also notice errors trying to read sugarcube prefs:

    [00:50:08.9656] Slim::Control::Request::notify (2132) Error: Failed notify: Can't call method "get" on an undefined value at P:/Music/SlimServer/trunk/server/Plugins/SugarCube/Plugin.pm line 670.
    [00:50:08.9707] Slim::Control::Request::notify (2132) Error: Failed notify: Can't call method "get" on an undefined value at P:/Music/SlimServer/trunk/server/Plugins/SugarCube/Plugin.pm line 670.

    Seems to work though.

  3. #23
    Senior Member Philip Meyer's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    5,596

    Announce: Spicefly SugarCube Version 2.03 – (Automatic MusicIP DJ) for 7.x

    Another adjustment needed - after calling selecttrack to choose the next track from MIP matches, it needs to get a track object from the url:

    my $seltrack = selecttrack($client, \@unique);
    $track = Slim::Schema->rs('Track')->objectForUrl($seltrack);

  4. #24
    Senior Member Philip Meyer's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    5,596

    Announce: Spicefly SugarCube Version 2.03 – (Automatic MusicIP DJ) for 7.x

    Another thing I've noticed is that if I am playing a song with one song queued up, if I don't like the next song and delete it from the dynamic playlist, it tries to add a new one to play next, but most of the time it picks the same song.

    I think this is because it is building the MIP mix from the last track that was selected, which is the one I'm deleting, and it always includes this seed track at the top of the mix, which is the one that gets selected.

    So, I may tweak the code to make it mix from the currently playing track, or have some fallback logic to choose a different song if it matches the last selected song, or tell musicIP to not include seed song in the mix.

    However, I can't find the MusicIP http api help pages anymore - I thought there was a query string param to include/exclude the seed track, but can't find it.

    Maybe I just avoid using the first song returned in the mix?

  5. #25
    Senior Member erland's Avatar
    Join Date
    Dec 2005
    Location
    Sweden
    Posts
    11,295
    Quote Originally Posted by Philip Meyer View Post
    However, I can't find the MusicIP http api help pages anymore
    Oh, that's bad, it just redirect you to the AmpliFIND Music Services home page.

    I've sent them a mail asking if it's available somewhere, if someone has it in the web browser cache or something similar, please save it.

    The documentation could earlier be found here:
    http://mixer.musicip.com/http
    Erland Isaksson (My homepage)
    Developer of many plugins/applets
    Starting with LMS 8.0 I no longer support my plugins/applets (see here for more information )

  6. #26
    Senior Member Philip Meyer's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    5,596

    Announce: Spicefly SugarCube Version 2.03 – (Automatic MusicIP DJ) for 7.x

    >Another thing I've noticed is that if I am playing a song with one song queued up, if I don't like the next song and delete it from the dynamic playlist, it tries to add a new one to play next, but most of the time it picks the same song.

    I found the bugs that were causing this too.

    It doesn't keep track of previously played tracks correctly - i.e. mine is configured to remember the last 5 songs to avoid repeating them. It is storing tracks into the prefs file, but doesn't honour the limit correctly. i.e. I had over 100 songs stored, and it was only ignoring the first 5 that had been stored. Therefore when it fetches a mix based on the last chosen song, that song is top of the list, is not ignored, and thus just selects that song again.

    I changed the code to record the last n tracks, shuffling the historic tracks, such that the oldest song is dropped, and the newest song gets added.

    Looking further through the code, there is at least one global variable (list of songs returned from MIP for the seed, with historic songs removed), which means the plugin is unsafe when more than one player has SugarCube enabled. This needs to either be passed around through function calls, or hold a list of songs per-client.

    My modified SugarCube code is now working well as a Dynamic Playlist, if anyone has an interest in it. Only one small issue - sometimes Dynamic Playlist queues up 2 future tracks instead of just one (only when starting the dynamic playlist with a song in the current playlist to be used as the starting seed track). Still, I find this much better than SugarCube, which can cause many future tracks to get added through various events (such as fast-forward, etc). DynamicPlaylist seems to handle this side of things much better.

    I need to test normal SugarCube operating mode now, in case any of my changes have affected that.

  7. #27
    Senior Member cparker's Avatar
    Join Date
    Oct 2005
    Location
    Hampshire, United Kingdom
    Posts
    629
    Quote Originally Posted by Philip Meyer View Post
    Looking further through the code, there is at least one global variable (list of songs returned from MIP for the seed, with historic songs removed), which means the plugin is unsafe when more than one player has SugarCube enabled. This needs to either be passed around through function calls, or hold a list of songs per-client.
    Can you release your revised code for review and explain your comments regarding unsafe. I assume you refering to the unique array? Which is used temporarily during the selection and then wiped once the track is selected. I think it would be pretty impressive if this caused an issue in use but happy to be proved wrong.

    Cheers
    www.spicefly.com - ** Spicefly SugarCube ** - A hassle free acoustic journey through your music library using MusicIP. Plus the finest MusicIP installation guides, enhanced MIP Interface and SpyGlass MIP the Windows Automated MusicIP Headless Installer.

  8. #28
    Senior Member Philip Meyer's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    5,596

    Announce: Spicefly SugarCube Version 2.03 – (Automatic MusicIP DJ) for 7.x

    >Can you release your revised code for review and explain your comments
    >regarding unsafe. I assume you refering to the unique array? Which is
    >used temporarily during the selection and then wiped once the track is
    >selected. I think it would be pretty impressive if this caused an issue
    >in use but happy to be proved wrong.


    Thanks for releasing your update to this plugin - it is most appreciated. Sorry if I sounded ungrateful - I was just trying to help, and I seem to be one of minority that use it with DynamicPlaylists. I realise that this part of your plugin was not really being maintained; I didn't want to make it sound like I thought it wasn't very good.

    @unique is used within commandCallback when processing a newsong event, and also getNextDynamicPlayListTracks. The code writes to the array, processes it, and then clears it. I was thinking that there could be some time between writing the array and clearing it, that some other player that is also processing a newsong/DynamicPlaylist event would be in contention with that data. However, if the server is all single-threaded (another player event not being processed until the first command callback has finished being processed), then I guess it's safe. In other cases, data from functions is returned and then passed them into other functions, rather than using a global variable, so I just thought at first glance that it looked like a problem.

    I've seen a few unexplained occurances in the past where it's stopped queuing up songs for no reason (pressing play on the same track then causes a new track to start), but that was with a previous version of the plugin. This is the first time I've looked at the code though (because I wanted to get DynamicPlaylist processing working again). I wasn't really looking for other issues, but it was just a passing thought when I was trying to understand how it worked, that it looked unsafe (could return the unique array instead of diditwork indicator - empty array=not worked).

    I haven't done a diff to see what changes I actually made in the end. I played around quite a bit with debug statement changes to understand how it worked (moved some code around, then moved it back!); I think the changes to get it to work were actually minimal.

    I've tried SugarCube in it's usual playback mode since making the changes, and it still seems to work, but haven't done extensive testing (eg. haven't looked to see if remembered tracks is working to remove played tracks from future choices). I cleared my prefs file down to start afresh - not sure what would happen with existing prefs file.

  9. #29
    Senior Member Philip Meyer's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    5,596
    Here's my edited plugin.pm

  10. #30
    Junior Member humboldt's Avatar
    Join Date
    Feb 2009
    Location
    The Netherlands
    Posts
    8

    Similar issues

    I'm on 7.4.2 with only the plugin CustomBrowse installed (DynamicPlaylists is not installed) and I'm having similar issues. When I pick a song SugarCube nicely adds the next one. But when I skip the song SugarCube keeps adding the same songs over and over again. Also when I use fast forward SugarCube adds the same songs (in my opinion no song should be added). If I generate a playlist with MusicIP, SugarCube adds the next one to the end of the playlist, but when I go to that song and hit the playbutton, again the same songs are added.
    Last edited by humboldt; 2010-01-18 at 14:41.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •