Hi. I have problem with QWebView and custom QNetworkAccessManager class.
I want to use html5 video function to watch encrypted local videos. My code:
QWebSecurityOrigin::addLocalScheme("courses");
m_view = new QWebView(this);
m_view->page()->setNetworkAccessManager(new NetworkAccessManager);
m_view
->load
(QUrl::fromLocalFile("index.html"));
QWebSecurityOrigin::addLocalScheme("courses");
m_view = new QWebView(this);
m_view->page()->setNetworkAccessManager(new NetworkAccessManager);
m_view->load(QUrl::fromLocalFile("index.html"));
To copy to clipboard, switch view to plain text mode
<!DOCTYPE html>
<html>
<head> <meta
charset="utf-8" /></head>
<body>
<img src="courses://test" />
<video controls>
<source src="courses://big_buck_bunny.cmp4" type="video/mp4" />
</video>
</body>
</html>
<!DOCTYPE html>
<html>
<head> <meta
charset="utf-8" /></head>
<body>
<img src="courses://test" />
<video controls>
<source src="courses://big_buck_bunny.cmp4" type="video/mp4" />
</video>
</body>
</html>
To copy to clipboard, switch view to plain text mode
#include "NetworkAccessManager.h"
#include "NetworkReply.h"
#include <QDebug>
NetworkAccessManager
::NetworkAccessManager(QObject *parent
) : QNetworkAccessManager(parent)
{
}
QNetworkReply
*NetworkAccessManager
::createRequest(Operation op,
const QNetworkRequest
&request,
QIODevice *outgoingData
){
qDebug() << request.url() << request.url().scheme();
if (op != GetOperation || request.url().scheme() != "courses")
return QNetworkAccessManager::createRequest(op, request, outgoingData);
return new NetworkReply(this, request);
}
#include "NetworkAccessManager.h"
#include "NetworkReply.h"
#include <QDebug>
NetworkAccessManager::NetworkAccessManager(QObject *parent) :
QNetworkAccessManager(parent)
{
}
QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
{
qDebug() << request.url() << request.url().scheme();
if (op != GetOperation || request.url().scheme() != "courses")
return QNetworkAccessManager::createRequest(op, request, outgoingData);
return new NetworkReply(this, request);
}
To copy to clipboard, switch view to plain text mode
QWebView is calling my NetworkAccessManager::createRequest function only for index.html and img, for video first it's says that gstreamer cannot pause - "link", and then: Error, courses URI schema is not implemented.
Could someone tell me how can I implement custom data reading for videos in webkit?
Bookmarks