Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to make a QMediaPlayer/QML MediaPlayer send a token in header or query of requests?
Forum Updated to NodeBB v4.3 + New Features

How to make a QMediaPlayer/QML MediaPlayer send a token in header or query of requests?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 312 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ADZol
    wrote on last edited by
    #1

    In order to acquire an access to remotely stored video, I need to send a user token in header of HTTP request. I am using QMediaPlayer to stream it.

    m_player = new QMediaPlayer(this);
    

    I tried to use setRawHeader(QByteArray("Token"), QByteArray("123456"));, on QNetworkRequest and feed it to my QMediaPlayer. No result.

    QNetworkRequest testRequest(QUrl("http://urltovideo/playlist.m3u8"));
    testRequest.setRawHeader(QByteArray("Token"), QByteArray("123456"));
    m_player->setMedia(testRequest);
    

    I tried to put it in QMediaContent and than feed it to QMediaPlayer. Again, no result.

    QNetworkRequest testRequest(QUrl("http://urltovideo/playlist.m3u8"));
    testRequest.setRawHeader(QByteArray("Token"), QByteArray("123456"));
    QMediaContent testMediaContent(testRequest);
    m_player->setMedia(testMediaContent);
    

    Even if I add a query to the request, it have an effect only on first request of the QMediaPlayer, then it requests chunk, no result.

    QUrl mediaUrl("http://urltovideo/playlist.m3u8");
    QUrlQuery testQuery;
    testQuery.addQueryItem("Token", "123456");
    mediaUrl.setQuery(testQuery);
    m_player->setMedia(mediaUrl);
    

    In all examples the video plays as it should (if token verification disabled).

    How can I do that? Maybe there is a way to amend this field after request was formed?

    I tried to make it work with QML MediaPlayer component.

    Use of setNetworkAccessManagerFactory() was not fruitful as well, like it shown here, works with Image, but it still does not work with MediaPlayer. Apperantely, MediaPlayer does not using QNetworkAccessManager.

    How can I do that?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved