Autoplay dynamically created playlist

You have a question or need an advice about how to do something? Ask it here!
Post Reply
benjavides
Posts: 16
Joined: 15 Sep 2023 20:47
Autoplay dynamically created playlist

Post by benjavides »

I would like to create an OSC command: /audio/playlist/dynamic/new
which receives a single string indicating the path to a script library.

It should create a new playlist using that script library and start auto playing it. Ideally it should behave like this:
  • If there is no music playing:
    1. Start playing the new playlist immediately
  • If there is another playlist playing:
    1. Fade out the current player in the playlist
    2. Fade in the new playlist
    3. Close the playlist that was playing originally so that the new playlist is the only one opened.
First I tried this:
Image
And the string I was sending was:
C:\\Users\\Benjavides\\AppData\\Roaming\\radio42\\ProppFrexx ONAIR\\4.0\\scripts\\Musica_Clasica.pfs
But the program showed me a pop up saying “Please Wait. Loading Playlist…” forever. Probably because that command is meant to be used with playlists, not scripts.
Image

Then I tried this:
Image
which creates the playlist as intended, fades out the playlist that was playing, but doesn’t autoplay.

I tried adding a SLEEP 3000 between the PROGRAM_STARTSCRIPT and PLS_CURRENT_AUTOPLAY_ON but it didn’t work.

I even tried adding an execute line that turns on the autoplay to the script but it didn’t work either.
Image

How can I autoplay a dynamically created playlist from a script?
User avatar
radio42
Site Admin
Posts: 8565
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Autoplay dynamically created playlist

Post by radio42 »

First, yes, the LOAD_PLAYLIST command is of course only to be used with playlist and not with scripts.

The PROGRAM_STARTSCRIPT command expects the name of the script (in your case "Musica_Clasica" and not the filename of the script).
But however, it starts the related script (in a new playlist window if no existing playlist name is given, as you do in your case) and also automatically sets AutoPlay to ON (if the Scheduler is running or the Scheduler Stop Option is set to DontStopAutoPlay).
So in such case, there is no need issue any extra command for it!
I just tested it here and it works like it should be.

If however the Scheduler is OFF and the Scheduler Stop Option is not set to DontStopAutoPlay - you would need to issue the AUTOPLAY command.
You already did that, but the issue is, that the PROGRAM_STARTSCRIPT command is executed asychoniously, ie. the next command sequence is executed before the PROGRAM_STARTSCRIPT command finally finished.
As such the SLEEP time must be big enough. In my case 12 or 13 seconds worked perfectly.E.g. I used:

Code: Select all

ASYNC
PROGRAM_STARTSCRIPT |Musica_Clasica|${now}|False
SLEEP 13
PLS_CURRENT_AUTOPLAY_ON

So overall, in your use case, I suggest to simply set the Scheduler Stop Option and set it to DontStopAutoPlay.
benjavides
Posts: 16
Joined: 15 Sep 2023 20:47
Re: Autoplay dynamically created playlist

Post by benjavides »

I forgot to mention that when using PROGRAM_STARTSCRIPT I was sending the playlist name and not the path, so that was not the problem.
I'll try your suggestion today and let you know. 13 seconds is a bit much for the use case so I'll try DontStopAutoPlay.

Thanks for your answer!
benjavides
Posts: 16
Joined: 15 Sep 2023 20:47
Re: Autoplay dynamically created playlist

Post by benjavides »

It worked by setting the Scheduler Stop Option to DontStopAutoPlay. Thanks!

I have a question regarding how the history works. In the case of creating dynamic playlists with scripts, when are tracks added to the history?
  1. When the track starts being played
  2. When the track finishes playing
  3. When the track is added to a playlist by the script
I think it's 3. because if I look at the global history in "Tools/Show Global-History" I see all the tracks that have been added to the playlist even if they haven't played.
Image

I understand why this is the case. They need to be in the history in order to not repeat them while creating the playlist with the script.

The problem I have is that I won't playback all the tracks in the playlist, but they will be added to the history regardless. Temporally removing them from the selection pool. This wouldn't be a problem if the pool for each script was very large. But this won't be the case with some scripts.

Why am I creating a playlist with tracks that won't be played? I need to dynamically create playlists that fill a certain amount of time. I don't see a way in the script to do that. So instead, if I need to fill 15 minutes, I create a playlist with at least 15 random songs because I know that on average they are each longer than 1 minute. An external software is going to pause the playback at exactly 15 minutes and request the creation of another playlist.

Is there a way to dynamically create a playlist that in total lasts approximately a certain duration? Otherwise is there a way to programatically remove songs from history? Or to only add songs to history once they are played?

If I do this
Image
Will it be possible to get repeated tracks in those 30 songs?
Will those songs that weren't added to history on the playlist creation be added to history once they are played?
User avatar
radio42
Site Admin
Posts: 8565
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Autoplay dynamically created playlist

Post by radio42 »

It is 3.
But all tracks not played (but already scheduled) are removed from the history automatically, when that program/playlist closes. So nothing to do on your side.

You can use the script option TryEnsureExactLength, so that the last track ends with the given program end time (enough tracks in your media lib are necessary to achieve this).

I would however avoid using the global and script history for other reasons.
Use the LastRecentlyPlayed script line mode instead of the Ramdom mode (as random is really random, eg. the same track might get picked again). While the LeastRecentlyPlayed mode first tries to pick a track not played and varies only for the tracks almost not played for the same past time.
benjavides
Posts: 16
Joined: 15 Sep 2023 20:47
Re: Autoplay dynamically created playlist

Post by benjavides »

But all tracks not played (but already scheduled) are removed from the history automatically, when that program/playlist closes. So nothing to do on your side.
Oh great!
You can use the script option TryEnsureExactLength, so that the last track ends with the given program end time (enough tracks in your media lib are necessary to achieve this).
Hadn't noticed this, I'll try it.
Use the LastRecentlyPlayed script line mode instead of the Ramdom mode (as random is really random, eg. the same track might get picked again). While the LeastRecentlyPlayed mode first tries to pick a track not played and varies only for the tracks almost not played for the same past time.
Makes sense and fits my use case.

Thanks a lot!
benjavides
Posts: 16
Joined: 15 Sep 2023 20:47
Re: Autoplay dynamically created playlist

Post by benjavides »

Hello, I have a follow-up question regarding the LeastRecentlyPlayed mode. If I consistently create dynamic playlists with this mode, wouldn’t the tracks eventually play in the same order after each has been played once?

Is there a way to introduce some variation to avoid a repetitive sequence in playback, while still prioritizing tracks that haven’t been played recently?

Thanks for your help!
User avatar
radio42
Site Admin
Posts: 8565
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Autoplay dynamically created playlist

Post by radio42 »

Theoretically yes, BUT ProppFrexx uses the nearest 6 hour block for the comparison. I.e. the tracks with the same played date in the last 6 hour block are again randomized to not give exactly the same result.

If you need more variation, you can also add a standard 'Random' script line for the same media lib. This will also add some variation on top. The same is true, if you manually play a track are pull tracks differently from the library.
benjavides
Posts: 16
Joined: 15 Sep 2023 20:47
Re: Autoplay dynamically created playlist

Post by benjavides »

Hi Bernd,

Thanks again for the previous clarifications.

I have a follow-up question regarding the "LeastRecentlyPlayed" mode. If my music library is considerably larger than 6 hours and I consistently create dynamic playlists in this way, when it picks the "LeastRecentlyPlayed" track, it will likely go back further than the nearest 6-hour block. Wouldn't this result in playing back the entire library in the same order each time?

While I understand that I can add "Random" lines to the script to introduce some variation, the downside is that the same track might get selected twice, and there would also be no variation within the tracks in a line that is not set to "Random."

Is there a way to randomize the order of a playlist after it is created? This would help me achieve my goal of dynamically creating playlists with tracks that meet specific criteria, without always maintaining the same sequence. The concern is that listeners might start associating certain tracks together if the sequence remains consistent over time.

My original plan was to just select "Random" songs that met the filters and use the History system to avoid repetitions within a certain range of time (ideally 1 week). Would this work?

Thanks for your help!
User avatar
radio42
Site Admin
Posts: 8565
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Autoplay dynamically created playlist

Post by radio42 »

No.
A track from in the last 6 hour block is always selected randomly. So it will never be the same order.

When adding sometimes a random track, it can not be the same track selected again or twice due to the global history.

Randomizing a playlist after would not really help, sanity would not change the order in which tracks are selected next.

Post Reply