使用代码:
Phonon::VideoPlayer *player = new Phonon::VideoPlayer(Phonon::MusicCategory, NULL);
QObject::connect(player, SIGNAL(finished()), player, SLOT(deleteLater()));
player->play(Phonon::MediaSource("c:/yaodong.mkv"));
但崩溃了。 env是win7和vs2008,qt 4.7.1 windows sdk是7.1 dx sdk是Microsoft DirectX SDK(2009年3月) 我发现堆栈是 mediaobject.cpp(第233行)图为空
} else if (!m_currentWork.url.isEmpty()) {
//let's render a url (blocking call)
hr = m_currentWork.graph->RenderFile(reinterpret_cast<const wchar_t *>(m_currentWork.url.utf16()), 0);
}
然后我找到了执行该功能的步骤:
quint16 WorkerThread::addUrlToRender(const QString &url)
{
QMutexLocker locker(&m_mutex);
Work w;
w.task = Render;
//we create a new graph
w.graph = Graph(CLSID_FilterGraph, IID_IGraphBuilder);
w.url = url;
w.url.detach();
w.id = m_currentWorkId++;
m_queue.enqueue(w);
m_waitCondition.set();
return w.id;
}
行:w.graph = Graph(CLSID_FilterGraph,IID_IGraphBuilder); w.graph为空。
但我在外面写了代码:
IGraphBuilder *pGraph = NULL;
::CoCreateInstance(CLSID_FilterGraph, 0, CLSCTX_INPROC_SERVER, IID_IGraphBuilder,
reinterpret_cast<void**>(&pGraph));
pGraph不为空。
帮助。谢谢!