What "Break" item is?
A break is a way to interrupt the playback of playlist item to play another element (live, file or sub-playlist) and return back to the place of interruption in the interrupted playlist, for example, ad-block. Also, a break is used to run a command in a specified file position.
Any element of a playlist (a command is an exception) can have break items. To set breaks to a playlist item, you should use IMBreaks interface of MItem object. MPlaylist does not support this interface.
MBreaks is MItem object with all properties and methods of MItem - but you can't add a new break to the current break.
The only difference is a position of breaks. A position of breaks is a position in seconds (NOT a time) from the in-point (if a position is positive) or back from out-point (if a position is negative). This position does not match to the time of the break that is calculated from the start of playback.
Example
You have a file with in-point in=10 and 2 breaks:
- The 1st break appears on 5th second of the file and continues 10 seconds;
- The 2nd break appears on 10th seconds of the file and continues 15 seconds.
In this case:
Time |
0..5 |
5..10 |
10...15 |
15..20 |
20..25 |
25..30 |
30..35 |
35... |
Item |
File (10..15 seconds of the file because of in-point) |
1st break |
File (15..20 seconds) |
2nd break |
File (from 20th second to the end) |
To set a break in a file you should set the break position but not a time for each control of all breaks in a playlist. You don’t need to recalculate all break times if you remove one of them.
ItemTimesGet is used to get a playlist item start and stop absolute time (according to the example above: 5..15 for the 1st break and 20..35 for the 2nd break).
string name;
double offset;
MItem myItem;
m_objPlaylist.PlaylistGetByIndex(0, out offset, out name, out myItem);
MItem myBreak;
((IMBreaks)myItem).BreaksAdd(10.0, null, @"d:\test.mkv", "", out myBreak);