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 use the multimedia module in Qt6 to play network media that requires http headers to be set
Forum Updated to NodeBB v4.3 + New Features

How to use the multimedia module in Qt6 to play network media that requires http headers to be set

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 710 Views 3 Watching
  • 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.
  • P Offline
    P Offline
    pbvpdMin
    wrote on last edited by
    #1

    Hi, I'm a QT beginner. I want to try to use QMediaPlayer to play web media that may require setting HTTP headers such as cookies.
    I found that I can use QMediaPlayer::setMedia in Qt5 to solve the problem. But QMediaContent has been removed in Qt6, how do I implement similar functionality in Qt6?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Can your show how you are doing it with Qt 5 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        Can your show how you are doing it with Qt 5 ?

        P Offline
        P Offline
        pbvpdMin
        wrote on last edited by
        #3

        @SGaist
        Maybe like this

        QMediaPlayer player;
        QNetworkRequest req(QUrl("https://example.com/xxx.mp3"));
        req.setRawHeader("Cookie", "uid=123456");
        player.setMedia(req);
        player.play();
        

        I don't have the Qt5.X SDK installed on my computer and haven't verified that the code is available

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mchinand
          wrote on last edited by
          #4

          In Qt6, there's no version of setSource() that takes a network request like setMedia() in Qt5. It might work if you add a QUrlQuery to your QUrl; e.g.

          QMediaPlayer player;
          QUrl mediaUrl("https://example.com/xxx.mp3");
          mediaUrl.setQuery({"uid", "123456"});
          player.setSource(mediaUrl);
          player.play();
          
          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