Hi Halley, I'm keeping in mind the subtitles support case, currently for subtitles embedded into the stream or connected to the stream (like DVD, DVB stream, mkv files, etc) backend may load and render subtitles itself, and provide QMediaStreamsControl to allows application to select which subtitles or audio tracks to render.
We don't currently have an API to specify the external subtitles url, I expect to extend the QMediaContent to add optional subtitle url, but this is not decided yet. Regards Dmytro. On 29/06/2010, at 10:25 AM, ext Zhao, Halley wrote: Hi Dmytro & Justin: Some customers request subtitle features, we need it support from QtMobility. How is your plan to support it? Thanks ________________________________ From: [email protected]<mailto:[email protected]> [mailto:[email protected]] On Behalf Of Chen, Jacob Sent: 2010年6月24日 14:23 To: [email protected]<mailto:[email protected]> Subject: [Qt-mobility-feedback] Subtitle support in Qt-mobility Hi here, I’m looking for a way to render subtitle file with video playback in qt-mobility. I found that qt-mobility is lack of subtitle/APIs support. Qt-mobility is using gstream playbin as the back-end of media player, but the subtitle functions haven’t been enabled. I made a simple patch to enable gstreamer plug-in to find and render the subtitle file which has same name as the media file automatically. ------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp b/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp index 58ba160..7510be6 100644 --- a/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp +++ b/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp @@ -286,7 +286,7 @@ void QGstreamerPlayerControl::setMedia(const QMediaContent &content, QIODevice * m_seekToStartPending = false; QUrl url; - + if (m_stream) { if (m_stream->isReadable() && openFifo()) { url = QUrl(QString(QLatin1String("fd://%1")).arg(m_fifoFd[0])); @@ -296,7 +296,7 @@ void QGstreamerPlayerControl::setMedia(const QMediaContent &content, QIODevice * } m_session->load(url); - + if (m_fifoFd[1] >= 0) { m_fifoCanWrite = true; @@ -304,6 +304,20 @@ void QGstreamerPlayerControl::setMedia(const QMediaContent &content, QIODevice * } if (!url.isEmpty()) { + QString subtitle_file = ".srt"; + QFileInfo fi(url.toLocalFile ()); + subtitle_file.prepend(fi.baseName()); + subtitle_file.prepend("/"); + subtitle_file.prepend(fi.absolutePath()); + + QFile file(subtitle_file); + if (file.exists()) { + subtitle_file.prepend("file://"); + m_session->set_sub_encoding("UTF"); + m_session->set_sub_font_desc("san bold 20"); + m_session->load_subtitle(QUrl(subtitle_file)); + } + if (m_mediaStatus != QMediaPlayer::LoadingMedia) emit mediaStatusChanged(m_mediaStatus = QMediaPlayer::LoadingMedia); m_session->pause(); diff --git a/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.cpp b/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.cpp index 942a8ba..5c6aa77 100644 --- a/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.cpp +++ b/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.cpp @@ -151,6 +151,26 @@ void QGstreamerPlayerSession::load(const QUrl &url) } } + +void QGstreamerPlayerSession::load_subtitle(const QUrl &url) +{ + m_url = url; + + if (m_playbin) + g_object_set(G_OBJECT(m_playbin), "suburi", m_url.toEncoded().constData(), NULL); +} + + +void QGstreamerPlayerSession::set_sub_encoding(const QString &encoding_String) { + if (m_playbin) + g_object_set(G_OBJECT(m_playbin), "subtitle-encoding", encoding_String.toLatin1().constData(), NULL); + } + +void QGstreamerPlayerSession::set_sub_font_desc(const QString &font_desc_String) { + if (m_playbin) + g_object_set(G_OBJECT(m_playbin), "subtitle-font-desc", font_desc_String.toLatin1().constData(), NULL); +} + qint64 QGstreamerPlayerSession::duration() const { return m_duration; diff --git a/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.h b/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.h index 17f17bd..9550f38 100644 --- a/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.h +++ b/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.h @@ -102,6 +102,9 @@ public: public slots: void load(const QUrl &url); + void load_subtitle(const QUrl &url); + void set_sub_encoding(const QString &encoding_String); + void set_sub_font_desc(const QString &font_desc_String); bool play(); bool pause(); ------------------------------------------------------------------------------------------------------------------------------------------------------------------ I think the right way is to let QMediaplayer support subtitle APIs like, set_subtitle(), set_subtitle_encoding() and set_subtitle_font(), the application could have fully control of subtitle. Any suggestion? Jacob
_______________________________________________ Qt-mobility-feedback mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt-mobility-feedback
