I want to use a Video
/MediaPlayer
QML element in my app, and have it play a video from a custom stream. QMediaPlayer
seems to support this since you can tell it to read from a QIODevice
which can do anything you want. But MediaPlayer
only supports a URL.
Is there any way I can register my own URL scheme that uses my own streaming protocol? For example, say I wanted to make rtsp2://...
, could I do something vaguely like:
class Rtsp2 : public QIODevice
{
// open, read, seek, close, etc.
}
QCoreApplication::registerUrlProtocol("rtsp2", Rtsp2);
I haven't looked at the details, but the QML engine has a QNetworkAccessManager it uses for connectivity. You can add your own protocols at the QNAM layer by subclassing and hooking createRequest. However I suspect QMediaPlayer might not uses this QNAM for media loading, because the underlying media layer often provides its own IO abstraction.
(Also, adding custom protocols to QNAM isn't exactly trivial - ideally it would be a simple 'registerProtocolFor' call but sadly this is not the case)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With