Load playlist and start at the correct item...

...just load the file, set the CUE IN point to minutes/seconds past the hour "now," and …
Good idea! Some hours are individual tracks and some are one big file so that will take some thought but I like the idea ...

I think both CAD and Torben’s solutions would work but Theo’s idea of using ‘AutomationJump’ does sound the neatest option.

Theo, what parameter do you use for GetStartTime? It should be sttEstimated. This should be the same value as displayed in the playlist when all players are idle.

The first item will have a value of either 00:00:00 or - if you have switched on the playlist option “update backtiming with current time when idle” - the current time. This is why I propose to use a temporary playlist first in which the first item will always be zero-based. You can identify the item to jump to within the temporary playlist, then copy the items over to the main playlist, and then use AutomationJump if you prefer :wink:

By the way, we’re talking about mAirList 2.2 here, right? Because in v3.0, the backtiming routines have slightly changed. You need to use the function IPlaylist.GetBacktiming to get the estimated time there. (This is because, internally, an item can be in multiple playlists at the same time. For example, when you drag an item into a player, it is put into a temporary “transport playlist” object. Each playlists keeps track of the backtiming for all of its items, so I had to make the estimated start for each item time a property of the playlist rather than a property of the playlist item.)

Oh, and the time format needs to be “hh:nn:ss”. “mm” would be the month. http://www.delphibasics.co.uk/RTL.asp?Name=FormatDateTime

Hi guys,

Thanks a lot for your help, it’s great !! I like your ideas and the help you give me.

At the moment, I made test with mAirlist v3. But, I think I would downgrade to v2.2. And, in v3 version, the sttEstimated constant doesn’t work.
Oh no, I will first try to use IPlaylist.GetBacktiming for the estimated time, like you suggest to. And if it’s too difficult for me (It’s my first mAirlist script !!), I will downgrade to use the GetStartTime with the sttEstimated constant variable.

And globally, I think I will do what you say : use a temporary playlist first and load the m3u into it, in order to identify the item to jump to, and after, load all the items in the main playlist and use AutomationJump (I like this method lol).

Very powerful mAirlist scripting ! it’s wondered what mAirlist can’t do ^^.

How do I have to do for creating temporary playlist, and loading the m3u into it ?

I tried

var tmp_playlist: IPlaylist; begin tmp_playlist.LoadFromM3U('C:\Playlist.m3u'); end;

… but it doesn’t work fine.

Oh no. this can not work because mairlist don’t know the variable “tmp_playlist”.
the best thing is, that you save manuall a empty playlist and load this playlist with a script :slight_smile:

CurrentPlaylist.LoadFromM3U(‘Pfad’)

lg mike

I don’t want to load the file in CurrentPlaylist at the very first !

As I said previously, I would like to load the m3u in a temporary playlist, execute the position search on it, and after, load all the items in CurrentPlaylist object (in order to point on the correct position). Torben explained that it’s the best way for GetBackTiming method to have a zero-based position…

PS : I still kept on working with mAirlist v3. All is ok at the moment… The temporary playlist miss me, but the algorithm for finding position is done. And it works fine ^^

A temporary playlist can easily be created. Just declare a new variable of the “IPlaylist” type and use the factory to create a new playlist:

var 
  pl: IPlaylist;

begin
  pl := Factory.CreatePlaylist;
end.

I will try tomorrow Torben.

Will LoadFromM3U method work fine on this IPlaylist variable ? Because, in .chm documentation, I didn’t see this method included in this interface…

In v3.0, you just use LoadFromFile. It will look at the file extension and pick the correct import “plugin”.

This is the case for both the “real” playlist (from CurrentPlaylist) and any temporary playlist created by the Factory.

Guys,

Here is the first version of the script. It’s my first mAirlist script, so some things could be improved I think.

[code]{-------------------------------------------------------------------------------
LoadCorrectItem.mls - Launch Script for mAirlist

In hourly playlist, identify the item from which the playlist should begin to
to respect playlist timing.

Date: 2008-02-15
Version : design for mAirlist v3.0

See http://www.mAirList.com for further information.
-------------------------------------------------------------------------------}

var
Temporary_playlist: IPlaylist;
First_item_pos: integer;
First_item: IPlaylistItem;

function Search_playlistItem_position(pCurrent_playlist: IPlaylist): integer;
var
current_item: IPlaylistItem;
current_starttime: TDateTime;
curr_hour, curr_min, curr_sec, curr_ms: Word;
hour, min, sec, ms: Word;
exit_status: Boolean;
pos, real_position: integer;
diff_before, diff_after: ShortInt;
begin
DecodeTime(now, hour, min, sec, ms);

pos := 0;
diff_before := 0;
diff_after := 0;
exit_status := False;

repeat
	current_item:=pCurrent_playlist.GetItem(pos);
	current_starttime := pCurrent_playlist.GetBackTiming(pos, btEstimated);
	DecodeTime(current_starttime, curr_hour, curr_min, curr_sec, curr_ms);

	diff_after:= min - curr_min;

	if diff_after <= 0 then
		begin
			// Comparing...
			if diff_after = 0 
			then real_position:= pos
			else 	if Abs(diff_before) < Abs(diff_after) 
					then real_position:= pos-1 
					else real_position:= pos;
			exit_status:= True;
		end;
		
	diff_before:= diff_after;
	pos := pos+1;

until (exit_status = True) or (pos = pCurrent_playlist.GetCount);

Result:= real_position;
end;

begin
Temporary_playlist := Factory.CreatePlaylist;
Temporary_playlist.LoadFromFile(‘playlist_tmp.m3u’);
First_item_pos:= Search_playlistItem_position(Temporary_playlist);

PlaybackControl(0).SetAutomation(true);
CurrentPlaylist.Assign(Temporary_playlist);	
First_item:= CurrentPlaylist.GetItem(First_item_pos);

//PlaybackControl(0).AutomationJump(iFirst_item);
PlaybackControl(0).AutomationJumpSoft(First_item);

end.[/code]

If you have any comments, don’t hesitate to tell me.

Hi,

As everybody suggested to me, I tried to create mairlist v2.2 scripts (instead of v3 scripts).
I updated the one I gave you previously. But there are still problems with the GetStartTime(sttEstimated).

I loaded the playlist in a temporary one. And I made the loop. But all items returns 00:00:00…

Here is the code :

[code]{-------------------------------------------------------------------------------
Load the correct playlist and pointe to the correct item to play.

Author: Sylvain Michelizza
Date: 2007-03-??

See http://www.mAirList.com for further information.
-------------------------------------------------------------------------------}
const
LOGS_PATH = ‘D:\RADIO_LOGS’;
var
Temporary_playlist: IPlaylist;
First_item_pos: integer;
First_item: IPlaylistItem;

function Search_playlistItem_position(pCurrent_playlist: IPlaylist): integer;
var
current_item: IPlaylistItem;
current_starttime: TDateTime;
curr_hour, curr_min, curr_sec, curr_ms: Word;
hour, min, sec, ms: Word;
exit_status: Boolean;
pos, real_position: integer;
diff_before, diff_after: ShortInt;
begin
DecodeTime(now, hour, min, sec, ms);

pos := 0;
diff_before := 0;
diff_after := 0;
exit_status := False;

repeat
	current_item:=pCurrent_playlist.GetItem(pos);
	//current_starttime := pCurrent_playlist.GetBackTiming(pos, btEstimated);
	current_starttime := current_item.GetStartTime(sttEstimated);
	DecodeTime(current_starttime, curr_hour, curr_min, curr_sec, curr_ms);
	SystemLog(current_item.GetTitle);
	SystemLog(IntToStr(curr_hour)+':'+IntToStr(curr_min)+':'+IntToStr(curr_sec));
	
	diff_after:= min - curr_min;

	if diff_after <= 0 then
	begin
		// Comparing...
		if diff_after = 0 
		then real_position:= pos
		else 	if Abs(diff_before) < Abs(diff_after) 
				then real_position:= pos-1 
				else real_position:= pos;
		exit_status:= True;
	end;

	diff_before:= diff_after;
	pos := pos+1;

until (exit_status = True) or (pos = pCurrent_playlist.GetCount);

Result:= real_position;
end;

procedure OnStartup;
begin
//Playlist(0).LoadFromM3U(‘C:\Playlists’ + FormatDateTime(‘ddd dd mm - hh’, now) + ‘.m3u’);
Temporary_playlist := Factory.CreatePlaylist;
Temporary_playlist.LoadFromFile(LOGS_PATH + FormatDateTime(‘yyyymmdd’, now) + ‘.m3u’);
First_item_pos:= Search_playlistItem_position(Temporary_playlist);
SystemLog(IntToStr(First_item_pos));

{PlaybackControl(0).SetAutomation(true);
CurrentPlaylist.Assign(Temporary_playlist);	

First_item:= CurrentPlaylist.GetItem(First_item_pos);

PlaybackControl(0).AutomationJump(iFirst_item);
PlaybackControl(0).AutomationJumpSoft(First_item);

//PlaybackControl(0).AutomationPlay;}
end;

begin
end.[/code]

At the end, I made a display of the calculated position (unlikely always 0). I commented remaining instructions at the moment for test.

Is there something wrong with my script ?

In mAirList 2.2, there is no backtiming information available in temporary playlists. GetStartTime will always return 0.

Right.
So, I should load the m3u in the Playlist(0) and GetStartTime would be ok ? I will try that.

Thanks torben.

Yes, that should work.

I’m searching for a V3 version of this script.

It’s been a long time since someone put some information about it.

Is there already an updated script for V3 that runs smoothly?

Best regards

Hi,

I think I will be able to check the v3 version of the script and improve it. It will take me a few weeks to re-install all my system.
I will let you know when it is okay.

See you soon.

Not sure this script will interest somebody, but from today to I-don’t-know, I will rewrite this script for v4 version.
If somebody is interested, just let me know.

See you soon.

PS : I know I previously told that I take the time to upgrade the v2 version to v3 version and I admit : I totally forgot. But, at this time, I was completely far away from radio and mAirlist. I bought the v4 for a private project and I need to upgrade this version. So… :slight_smile:

Re-write finished and functional in v4.2.

Features:

  • Load the playlist regarding the current date and time (format “AAAAMMDD_HH_00.m3u”)
  • Jump to the audio item, in this hour, nearest of the real start time.
    Exemple :
    07:00 Item 1
    07:03 Item 2
    07:07 Item 3
    07:11 Item 4.
    If you load the playlist at 07:04, script will load the playlist and start playback from Item 2. If it’s 07:06, script will choose starting playback from Item 3 (nearest from Item 3 than Item 2)… and so on.

Extra features : scripts detects “dummy” item if they are at the very beginning of the playlists loaded. It replaces the “dummy” item to rename it “Exact time marker”, with hour, and soft mix.

If somebody’s interested, let me know.

Next step to my project : new layout and background…

[quote=“Theoorl45, post:39, topic:5764”]…

If somebody’s interested, let me know.

…[/quote]

Sure Theo,

why not post the script in this thread, so it would be available for everybody.

regards:
-Serge-