Load playlist and start at the correct item...

Hi everybody,

I made searches about a script but, as I didn’t found something like that, I ask you the question.

I have M3U playlists generated by hour (untitled like “20090211_10_00.m3u”, “20090211_11_00.m3u” …).
While launching mairlist, it is possible (I think) to load the correct playlist, corresponding to the hour it is.

For example, if it’s 8.15, mairlist will load “20090211_08_00.m3u” playlist.

BUT

how should I do for telling the script to begin to load audio from the item near 8.15…?
By the way, at 8.15, I don’t want to begin playback by the right first item of the playlist…

For being more precise, I would like a script that load the correct playlist (I think I can do that), and BEFORE BEGINNING TO PLAY SOUND, the script will try to find the nearest audio item to the time it is and begin to play from this item…

For example : it’s 8.15 and the loaded playlist is :
Item#1 (4 min )
Item#2 (4 min)
Item#3 (5 min)
Item#4 (3 min)
Item#5 (4 min)

Before beginning to play sound, the first item should be Item#5 because it’s near to 8.15…(4+4+5+3 = 16 min -> The four first item will take 16 min from 8 to be played…).

Is it possible according to your script knowledge ? Someone could help me ?

Thanks.


Theo

Hi Theo, these 2 scripts (both from Charlie) should help:

http://forum.mairlist.com/index.php/topic,2750.0.html

http://forum.mairlist.com/index.php/topic,1127.0.html

Rather than load playlist I prefer append playlist as anything (except if in the players) in the current playlist before the script runs is cleared.

Kind regards tony

Yes, Theo, this is possible using scripting!

The technique is to look through each (existing) Item in the Playlist and check its expected start time. I cannot remember precisely how to do this at the moment, because I am at work (NOT radio work!). It is something like .GetStartTime but don’t quote me!

Based on those Item start times, you can load your M3U File at the correct point (i.e. after the correct Item).

To use your example, the M3U file would be loaded after Item#4. My question to you is: what should we do with Item#5 (and any other existing Items which are after your start time of 8:15)? Should Item#5 (etc.) be deleted from the Playlist, or should your M3U file be inserted, so that Item#5 (etc.) will play AFTER your loaded M3U Items have all played?

I am assuming (?) that you are using mAirList in AUTO mode? If you are in ASSIST mode, the Playlist times cannot be relied upon, because live presenters always talk too much ::), and so your ‘injected’ Playlist may be late by several minutes! :o

Does that help for the moment?

BFN
CAD

Thanks Tony for the scripts. I will try to adapt them to meet my need.

Cad, I’m happy to know that there is a method (called or not “GetStarttime”) that will allow me to calculate the exact item my playlist should begin to play.

To answer to your question : here is why I expect to have.

  • mAirlist launch
  • load hourly playlist (or 24h playlist, no matter) from its first item.
  • script runs and checks all the items, calculating the start time from the begin of the playlist.
  • when script find the best item, nearest to the hour it is, playback begin from this item (load it in the 1st player, and the next in the 2nd player). All previous item should not be played (go to History for example, no matter)
  • And playlist continue from these item to the next… All the previous should be ignored.

Yes, it’s for 100 % AUTO MODE. Maybe a little bit of live assist, but it’s not the goal.

Could not make test because each time I try to load a M3U file, mairlist tells me
“Error opening C:…\playlist.m3u: Access violation at address 004D26c6 in module “mairlist.exe”. Read of address 000000000”


I think I will downgrade to v2… because no m3u files succeeds to load in this version of mAirlist (m3u files generated by winamp). And, when it’s not this kind of error, I have a “whitespaces not allowed…” error where there are “&” symbol in song title…

Quite disappointing.

No, Theo: the GetStartTime method is for ITEMS ALREADY IN THE PLAYLIST and IS NOT the time a new Playlist would start to play.

- when script find the best item, nearest to the hour it is, playback begin from this item (load it in the 1st player, and the next in the 2nd player). All previous item should not be played (go to History for example, no matter)
I think I have misunderstood what you need.

Do you mean “if I launch mAirList during an hour, and load an M3U file containing one hour of music, I want to SKIP OVER the Items at the start of the loaded Playlist”? For example, you launch mAirList at (say) 20:17 and load the 20:00 M3U file. Do you now want mAirList to try to ‘skip’ Items so that only the final 43 minutes of Items in the 20:00 M3U file are played out?

BFN
CAD

Yes, I understood getstarttime is allowed only for item already in the playlist… No pb.

And my sentence means that, whent the correct item is detected, automation should begin by this item. All the previous should be ignore (or delete, no matter) and all the items after the selected item will be played by automation !!

A jump to time script like this would be neat.

Firstly it would need to load or append the next playlist and perhaps jump to hour, to skip any unplayed audio in the playlist finishing.

Next look at the start tart of each item and then get system time and begin playback from the nearest start time in the playlist just loaded.

Beyond my scripting abilities, something for Cad or Charlie.

Kind regards tony

Cad, you’re right with your example at 20:17…

The script should find the best item for playing the 43 min remaining of the playlist… It won’t find the item that begin exactly at 20:17, but choose the best between the one who begin, for example, at 20:15 and the one who begin, also for example, at 20:18…

All the previous item (displayed) will be marked as played (go to history) and the remaining items will be played.

You got it now ;D ?
I guess I’m not good in English and that it’s difficult for you to understand clearly what I mean. Sorry for that.

Hmm … tricky!

What this would need in practice is a method of working out times BEFORE loading the new Playlist.

I can think of a way to do this*, but I must ask another question! Will this ‘load and skip forward’ script ONLY be run when mAirList is launched, or will the script be run every hour? (HINT: The ‘correct’ answer is “only when mAirList launches!” :D)

I also apologise that I do not speak your language … or at least, I don’t think so: what is your native language, Theo?

(*for those interested: select ASSIST mode, then load the M3U and use the mAirList expected start times to delete ‘extraneous’ Items from top of Playlist, then go into AUTO and PLAY ;))

BFN
CAD

Cad,

I wonder why you insits on “before loading”. It could be after loading the playlist.
The playlist loads totally and after, the script goes throught the items and marked as played the item and stop to the correct item… It could be “after” loading the playlist. Not before. But, if you have an idea to make it before, it could be a other solution ^^

This script is only aim to be launched when mAirlist is launched !! After playback beginning, all the items should be played without jump action !! This is only for the mAirlist launch, and playback begins at the correct item for not delaying all the following items…

But, I need something automatic. I don’t want to have to manually delete the items and click “PLAY”. I prefer a script that, place automatically the automation on the correct item and begin playback from it.

My native language is french Cad :wink: I correctly read english, but I experiment difficulties to speak english well.

Hello all

Can I add my vote for this functionality.

If the PC returns after a power failure then this would allow it to quickly get back to ‘normal’ so it would only be needed when mAirList is launched.

Our current (homebrew) playout system will jump to the correct point in the scheduled hour (often the middle of a song) when started. I don’t know if you were planning for your solution to do this or just start at the begining of the next scheduled item. Midway through a song does not sound that good but as this only happens in the event of a reboot/restart following a problem then it is probably better than yet more silence!

Ron.

p.s. CAD - your ‘workaround’ sounds good to me!

Theo: Ah oui, tu as raison. Ce n’est pas necessaire de calculer les temps en avant de charger le fichier M3U. Mais c’est necessaire de calculer les temps avant de jouer les ‘Items,’ oui? Le problème est ceci: les temps de commencement serait incorrect après charger le fichier M3U. Le temps de commencement du premier ‘Item’ devrait être (par exemple) 20h00, mais le temp de commencement actuellement sera (aussitot par exemple) 20h17.

Par conséquent, c’est impossible de utliiser les temps de commencement par les ‘Items.’ Je penserai plus à ce sujet et je vais te laisser savoir quand j’ai une réponse pour toi!

Theo, j’espère que tu pourra lire mon très mauvais français?

(For the benefit of Tony etc.: The problem is that all Item start times are ‘wrong’ when an hour’s Items are loaded during the hour. Hence I need to devise a RELIABLE method to remove the correct number of Items.)

BFN
CAD

Your french is quite approximate, but like my english, isn’t it ? lol.

I understood what you mean. It’s true that when playlist is loaded, the getstarttime of the first item will be the hour, not the beginning of the hour…
The way I imagine is that script can access (I hope) to the item duration. Does he ?
If it does, we can make the sum of the items duration and when the sum is near to the minute of the hour, we stop and automation begins.

For example, it’s 20:17.
We make the sum of the items (3min20 + 3min10 +…) and when minutes is near to 17 (for example 17min44), we select the item and begin to play sound…

What do you think about it : scripting with duration instead of starttime ?
It would be quite effective because in hourly playlist, we have less than 30 items (about 15 songs and 14 non-songs item, like jingles, news…).

Ron, I don’t think it’s a good things if we begin playing directly in the middle of the song. If playout system breaks, I think it’s better if it begins to play at the beginning of the item, or the beginning of the next item… It think listeners won’t appreciate if a song begins at the middle after a silence.

Ron, I don't think it's a good things if we begin playing directly in the middle of the song. If playout system breaks, I think it's better if it begins to play at the beginning of the item, or the beginning of the next item.... It think listeners won't appreciate if a song begins at the middle after a silence.
I agree with you - however my concern would be that we often have whole programs recorded as one 56 minute block so if the PC resets at 5 minutes past the hour then the next junction might not be until 59 minutes past so that is a lot of silence!

I think one of the features of v3 is (or will be) volume control so perhaps it could fade in?

Anyway, thankfully this should not happen too often but whatever way it is implemented being able to start mid-hour is a very useful feature.

OK Theo, I’ll give up on my attempt at French! :-[

I have a better idea than using duration. Here is the concept.

Imagine it is (to use your example) 20h17 and mAirList has just restarted and loaded the 20h00 one-hour Playlist file. The expected start times of all items will therefore be 17 minutes ‘late.’

Hence, to find the correct Item to begin AUTO playback, the script searches for the Item with a start time ‘near’ 20h34 (20h17 + 17 minute ‘delay’). This will take only a second or two. The script then deletes all the Items before the new ‘first Item,’ puts the Playlist into AUTO mode, and ‘presses PLAY.’

So the ‘magic formula’ is: take the time “now,” and add the current number of minutes past the hour to find the start time the script should be looking for.

This could be quite difficult to actually write, but if the concept sounds correct, I can start working on it.

Can everyone interested please think about this and let me know if it sounds ‘right’ to you as well?

PS: I will write the script for mAirList V2.2.2 because I don’t have the time to get an up-to-date V3 working here (too busy trying to find a job! :’().

PPS: Ron, this method obviously isn’t intended for big ‘one-hour’ programmes. To do that is ironically much easier: just load the file, set the CUE IN point to minutes/seconds past the hour “now,” and … ;).

BFN
CAD

It seems to be a good idea Cad.

You can try to write something, but I will also try on my side. I think I could write something like the algorythm you describe… ^^

Thanks a lot for your help, it’s great !!! mAirlist community will always surprise me :slight_smile:

I propose you first load the playlist into a temporary IPlaylist object. The “estimated” start times will then be zero-based. Delete items as needed and then copy it over to the main playlist with CurrentPlaylist.Assign(…).

Why do we delete the previous items ? :smiley: It could be useful to see the items that had been skipped…I think.

I’ve juste discovered the AutomationJump & AutomationJumpSoft methods that points to a IPlaylistItem and marks all the previous item as played. I’m currently trying to design a script like this. You could try on your own with the IPlaylist and the delete process…

PS : In .Chm files, I didn’t find a method to “delete” a playlistItem from a playlist…

I progress…

But I experiment problem with the GetStartTime method. I tried the 4 constant variables given in .chm files (sttFixed, sttEffectiveFixed, sttPlanned and sttReal) and none works.

At the moment, I tried this code :

for cpt:=0 to CurrentPlaylist.GetCount -1 do begin current_item:=CurrentPlaylist.GetItem(cpt); current_starttime:=current_item.GetStartTime(xxxx); SystemLog(FormatDateTime('hh:mm:ss', current_starttime)); end;

And I only have for result, in all cases : 00:00:00

Could you explain me where I’m wrong ?