Subtitle API

Tanguy Krotoff tkrotoff at gmail.com
Wed Jun 30 00:46:04 BST 2010


On Tue, Jun 29, 2010 at 11:45 PM, Martin Sandsmark
<sandsmark at samfundet.no>wrote:

>  On Tuesday 29 June 2010 22:59:13 Ian Monroe wrote:
>
> > setAutoDetectSubtitles should be setAutoDetectSubtitle I think. Or all
>
> > the API should say "subtitles".
>
> Well, setAutoDetectSubtitles might possibly detect several possible
> subtitles, no?
>

Usually works as follow: if the player detects a subtitle file that matches
the video filename, then this subtitle file is loader automatically. Several
possible subtitles means the user still must choose the right subtitle.

This feature can be very easily coded outside phonon (using
QDir::entryList() + MediaController::setCurrentSubtitle()). If you add these
functions to Phonon then all the backends should implement them. Kind of
complete/complex API vs small/simple for me.

  > I'm worried that setSubtitleEncoding is a bit Xine-specific. But text
>
> > codecs suck, so perhaps there's no way around it.
>
> I can't find any libvlc API to specify it either, but I think it might
> warrant an addition.
>

I don't remember MPlayer offering this feature.


About setFileSubtitle(const MediaSource &subtitle), I already use
setCurrentSubtitle(const Phonon::SubtitleDescription &stream) to load a
subtitle file:

QHash<QByteArray, QVariant> properties;
properties.insert("type", "file");
properties.insert("name", fileName);
Phonon::SubtitleDescription newSubtitle(newSubtitleId, properties);
mediaController->setCurrentSubtitle(newSubtitle);

Later on inside the backend I read Phonon::SubtitleDescription, find the
type and name and load the subtitle. "name" matching a fileName and "type"
specifying a file is not normalized/documented.
One could imagine to overload setCurrentsSubtitle with parameter MediaSource
and let it build the right SubtitleDescription then no new function is added
to the API. This would give something like this:

void setCurrentsSubtitle(const MediaSource & media) {
  QHash<QByteArray, QVariant> properties;

  switch (media.type()) {
    case MediaSource::Url:
      properties.insert("type", "url");
      break;
    case MediaSource::File:
      properties.insert("type", "file");
      break;
    [...]
  }

  properties.insert("name", media.fileName());
  Phonon::SubtitleDescription newSubtitle(newSubtitleId, properties);
  setCurrentSubtitle(newSubtitle);
}


A long time ago I proposed a patch to uniformize the API inside
MediaController.
If setCurrentSubtitle() takes a Phonon::SubtitleDescription, then
setCurrentChapter() should take a Phonon::ChapterDescription,
setCurrentTitle() a Phonon::TitleDescription ect...
This gives more flexibility.
See http://mail.kde.org/pipermail/phonon-backends/2008-April/000194.html
Unfortunately this patch breaks binary compatibility and needs to be
reworked.

Regards,

-- 
Tanguy Krotoff <tkrotoff at gmail.com>
+33 6 68 42 70 24
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-multimedia/attachments/20100630/84d7f28b/attachment.htm>
-------------- next part --------------
_______________________________________________
kde-multimedia mailing list
kde-multimedia at kde.org
https://mail.kde.org/mailman/listinfo/kde-multimedia


More information about the kde-multimedia mailing list