+ _content_connections.push_back ((*i)->Changed.connect (bind (&Playlist::content_changed, this, _1, _2, _3)));
+ }
+}
+
+Time
+Playlist::video_end () const
+{
+ Time end = 0;
+ for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
+ if (dynamic_pointer_cast<const VideoContent> (*i)) {
+ end = max (end, (*i)->end ());
+ }
+ }
+
+ return end;
+}
+
+void
+Playlist::set_sequence_video (bool s)
+{
+ _sequence_video = s;
+}
+
+bool
+ContentSorter::operator() (shared_ptr<Content> a, shared_ptr<Content> b)
+{
+ return a->position() < b->position();
+}
+
+/** @return content in an undefined order */
+ContentList
+Playlist::content () const
+{
+ return _content;
+}
+
+void
+Playlist::repeat (ContentList c, int n)
+{
+ pair<Time, Time> range (TIME_MAX, 0);
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ range.first = min (range.first, (*i)->position ());
+ range.second = max (range.second, (*i)->position ());
+ range.first = min (range.first, (*i)->end ());
+ range.second = max (range.second, (*i)->end ());
+ }
+
+ Time pos = range.second;
+ for (int i = 0; i < n; ++i) {
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ shared_ptr<Content> copy = (*i)->clone ();
+ copy->set_position (pos + copy->position() - range.first);
+ _content.push_back (copy);
+ }
+ pos += range.second - range.first;