fade out to commercial block

He guys

Question is where can i set the fade out of a mp3 to the commercial block. Now do i have the following problem that it is not verry nice to hear . It skips the first 10 sec.

<?xml version="1.0" encoding="utf-8"?> Reclame blok 1-12 1-31 1-7 0-23 58 37 2011-05-06 22:58:37 E:\Jingles Pop Rock 2011\Reclame voorjaar\Reclame bok.mp3

Maybe i did something wrong…

Regards

Goos

Hi Goos,

this is what we do:

[code]var
i, f : integer;
activePlayer: integer;
newItem, activeItem: IPlaylistItem;
filename: Array[0…2] of string;
curpos: TTimeValue;

begin

filename[0] := ‘Werbung~c.mp3’;
filename[1] := ‘Werbung_2~c.mp3’;
filename[2] := ‘Werbung_3~c.mp3’;

f := Random(3);

CurrentPlaylist.BeginUpdate;
try
activePlayer := -1;
for i := 0 to CurrentPlaylist.GetPlayerCount - 1 do
if CurrentPlaylist.GetPlayer(i).GetState = psPlaying then begin
activePlayer := i;
break;
end;

if activePlayer = -1 then begin
  //SystemLog('No player is active!');
  newItem := Factory.CreateFilePlaylistItem('D:\EzDJPro_Radio_mp3s\Werbung\' + filename[f], []);
  CurrentPlaylist.Insert(0, newItem);

  //assign Icon to Playlistitem
  newItem.SetIconFilename('C:\MyMairlistPics\Werbung.ico');
  newItem.GetIconData.Clear;

  //Playlist will grab and play item automatically if automation is active,
  //as automation is inactive, we start AutomationNext here and exit but only for MainPlayoutSystem
  //for Backup System comment next line out
  CurrentPlaylist.AutomationNext;

  exit;
end;

// Index of item that is currently playing
activeItem := CurrentPlaylist.GetPlayer(activePlayer).GetItem;

// Insert new item below
newItem := Factory.CreateFilePlaylistItem('D:\EzDJPro_Radio_mp3s\Werbung\' + filename[f], []);
CurrentPlaylist.Insert(CurrentPlaylist.IndexOf(activeItem) + 1, newItem);

//assign Icon to Playlistitem
newItem.SetIconFilename('C:\MyMairlistPics\Werbung.ico');
newItem.GetIconData.Clear;

if not activeItem.IsCueable then begin
  //SystemLog('Active item is not cueable!');
  //If we have a stream running (example) no cue point can be set therefore we decide to kick the current item
  //and perform automation next to get the advertisement played
  //Depending on what action is required (stream takes care of playing advertisement) we could simply exit here.
  CurrentPlaylist.AutomationNext;
  exit;
end;

// Retrieve current playback position
curpos := ICueableAudioSource(CurrentPlaylist.GetPlayer(activePlayer).GetSource).GetPosition;

if activeItem.GetEffectivePlaybackEnd - curpos < SecondsToTimeValue(60) then begin
  //SystemLog('Remaining time is below one minute.');
  exit;
end;

if curpos > SecondsToTimeValue(60) then begin
  //SystemLog('Current player has played for at least one minute');
  CurrentPlaylist.AutomationNext;
  exit;
end;

//SystemLog('Remaining time is over one minute, and current position is under one minute, setting cue point.');
//Do not set cue point to exactly 60 seconds but a bit later. If the script gets triggered at exactly 00:01:00
//the system will set the cue point and might (due to program execution delay) already have passed it.
//So the song would continue to play... Here we give additional 2 seconds to avoid this.
activeItem.SetCuePosition(ptFadeOut, activeItem.GetCuePosition(ptCueIn) + SecondsToTimeValue(62));

finally
CurrentPlaylist.EndUpdate;
end;

end.

[/code]

I believe the code is well documented and self-explaining.
We have 3 different commercials so they are picked out randomly.

What we want to achieve is not to kick a song that has just begun to play. So we give it at least 1 Minute to play. In worst case the News will start 1 minute later…

regards:
-Serge-

The beginning of a file should never be skipped unless a Cue In point is set.

The “Play file” action does nothing but: Insert the file behind the currently playing on, simulate a click on the automation NEXT button.

Is the part also skipped when you do these steps manually?

Hi Torben

I was forgotten to make the cuein point indeed. I will check it at 10 am this morning if it runs smootly .

Thanks for helping

Goos

You don’t need a Cue In point. My point was that mAirList will always play the file from the very beginning, and never skip any part at the beginning, unless you have Cue In set.

So if you say that 10s are skipped, there must be a Cue In point set, perhaps by accident.

Try to insert the file manually and check what the cue dialog says.

It is going well now . But what i wanted to know is how do we get a faster overlap from music to commercial block. It is now that the music fades away in 6 sec so it is in the first commercial .

Regards

Goos

OK, forget my posting I missed this:

It skips the first 10 sec

regards:
-Serge-

Tricky. One could write a script that overrides the default fade time for the currently playing item before inserting the news.

If it could it would be great. Because i find a little bit disturbend to hear the record in the 3 seconds of a commercial break

Goos

I find your default fade time setting of 6 seconds pretty long, actually. I would have used something like 2 seconds or so. Then a good opener jingle for the commercial block, and everything is fine.

Anyway, here’s the script:

var
  i: integer;
  pi: IPlaylistItem;

begin
  for i := 0 to CurrentPlaylist.GetPlayerCount - 1 do begin
    if CurrentPlaylist.GetPlayer(i).GetState = psPlaying then begin
      pi := CurrentPlaylist.GetPlayer(i).GetItem;
      if pi <> nil then // player state may have changed, so check again!
        pi.SetFadeDuration(SecondsToTimeValue(2));
    end;
  end;
end.

It sets the fade duration of all playing items to 2 seconds. Value can be tweaked as needed. Save the script as e.g. SetFadeDuration.mls, and add it to your event using a Run Script action, before the Play File action.

Set up the script

Thanks will check it out tomorrow morning …
Saw from the log file no errors so it should be going ok

Goos

It is working fine now. Topic can be closed

Regards

Goos

Torben, could you please explain this to me:

 if pi <> nil then // player state may have changed, so check again!

nil = undetermined? ???

regards:
-Serge-

nil = null pointer = item not set = player not loaded

Although the script checks for the player state (must be loaded) first, it could happen that the player is unloaded just in between the two calls, due to multithreading. The usual way would be wrap the calls into a BeginRead…EndRead block in order to lock the player, but check for “<> nil” serves the same purpose, and is much easier to read and understand here.

He Torben

For me it is working fine now by the way

Regards

Goos