Subtitle API

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

On Tue, Jun 29, 2010 at 11:45 PM, Martin Sandsmark
<sandsmark at>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);

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");
    case MediaSource::File:
      properties.insert("type", "file");

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

A long time ago I proposed a patch to uniformize the API inside
If setCurrentSubtitle() takes a Phonon::SubtitleDescription, then
setCurrentChapter() should take a Phonon::ChapterDescription,
setCurrentTitle() a Phonon::TitleDescription ect...
This gives more flexibility.
Unfortunately this patch breaks binary compatibility and needs to be


Tanguy Krotoff <tkrotoff at>
+33 6 68 42 70 24
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
kde-multimedia mailing list
kde-multimedia at

More information about the kde-multimedia mailing list