Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qmediaenginetimedtextnotify.cpp
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QtMultimedia/private/qcomtaskresource_p.h>
7#include <QtCore/qstring.h>
8#include <QtCore/private/qcomptr_p.h>
9
11
12void STDMETHODCALLTYPE QMediaEngineTimedTextNotify::TrackAdded(DWORD trackId)
13{
14 emit trackAdded(trackId);
15}
16
17void STDMETHODCALLTYPE QMediaEngineTimedTextNotify::TrackRemoved(DWORD) { }
18
19void STDMETHODCALLTYPE QMediaEngineTimedTextNotify::TrackSelected(DWORD, BOOL) { }
20
21void STDMETHODCALLTYPE QMediaEngineTimedTextNotify::TrackReadyStateChanged(DWORD) { }
22
23void STDMETHODCALLTYPE QMediaEngineTimedTextNotify::Error(MF_TIMED_TEXT_ERROR_CODE, HRESULT, DWORD)
24{
25}
26
27void STDMETHODCALLTYPE QMediaEngineTimedTextNotify::Cue(MF_TIMED_TEXT_CUE_EVENT cueEvent,
28 double /*currentTime*/,
29 IMFTimedTextCue *cue)
30{
31 // Extract text on the MF thread while the cue is still valid.
32 QString text;
33 if (cue && cueEvent == MF_TIMED_TEXT_CUE_EVENT_ACTIVE) {
34 const DWORD lineCount = cue->GetLineCount();
35 for (DWORD l = 0; l < lineCount; ++l) {
36 ComPtr<IMFTimedTextFormattedText> line;
37 if (SUCCEEDED(cue->GetLine(l, &line)) && line) {
38 QComTaskResource<WCHAR> str;
39 if (SUCCEEDED(line->GetText(str.address())) && str) {
40 if (!text.isEmpty())
41 text += u'\n';
42 text += QString::fromWCharArray(str.get());
43 }
44 }
45 }
46 }
47 // cueEvent == INACTIVE → empty text (clear subtitle)
48 emit subtitleTextChanged(text);
49}
50
51void STDMETHODCALLTYPE QMediaEngineTimedTextNotify::Reset() { }
52
53QT_END_NAMESPACE
Combined button and popup list for selecting options.