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. [C++] Playing stream with QMediaPlayer app not responding

[C++] Playing stream with QMediaPlayer app not responding

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 577 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.
  • B Offline
    B Offline
    Bossa
    wrote on last edited by Bossa
    #1

    I using visual studio 2019 qt5.12.3 I use ffmpeg.exe to stream my pc screen and show it inside my app.

    Its playing the video stream but if my stream down or stop and ill try to lets say i start ffmpeg.exe and i can see my screen in my app, then ill kill the ffmpeg.exe and try to delete or reload new url its will crash or stuck

    delete QMediaPlayer;
    

    or

    QMediaPlayer->deleteLater();
    

    and not even

    QMediaPlayer->setMedia();
    

    working if the stream stop its will crash the app or nor respond. this is my code to play the stream

    void Stream::LoadStream() {
        QUrl StreamUrl = QUrl("https://example.com:2083/live/stream.flv");
        vWidget = new QVideoWidget(this);
        vWidget->setObjectName("vWidget");
        vPlayer = new QMediaPlayer(this, QMediaPlayer::StreamPlayback);
        vPlayer->setObjectName("vPlayer");
        vPlayer->setVideoOutput(vWidget);
        vPlayer->setMedia(StreamUrl);
        vPlayer->play();
        vWidget->show();
    }
    
    void Stream::StopStream() {
        vWidget->deleteLater();
        //vPlayer->setPosition(0); //tried but not helped
        vPlayer->stop();
        vPlayer->deleteLater(); // this crash the app if StreamUrl stoped streaming ..
        delete vPlayer; // this crash the app if StreamUrl stoped streaming ..
    }
    
    void Stream::ChangeUrl(QString Url) {
        vPlayer->setMedia(QUrl(Url););
    }
    

    how i can delete or remove the player ?

    jsulmJ 1 Reply Last reply
    0
    • B Bossa

      I using visual studio 2019 qt5.12.3 I use ffmpeg.exe to stream my pc screen and show it inside my app.

      Its playing the video stream but if my stream down or stop and ill try to lets say i start ffmpeg.exe and i can see my screen in my app, then ill kill the ffmpeg.exe and try to delete or reload new url its will crash or stuck

      delete QMediaPlayer;
      

      or

      QMediaPlayer->deleteLater();
      

      and not even

      QMediaPlayer->setMedia();
      

      working if the stream stop its will crash the app or nor respond. this is my code to play the stream

      void Stream::LoadStream() {
          QUrl StreamUrl = QUrl("https://example.com:2083/live/stream.flv");
          vWidget = new QVideoWidget(this);
          vWidget->setObjectName("vWidget");
          vPlayer = new QMediaPlayer(this, QMediaPlayer::StreamPlayback);
          vPlayer->setObjectName("vPlayer");
          vPlayer->setVideoOutput(vWidget);
          vPlayer->setMedia(StreamUrl);
          vPlayer->play();
          vWidget->show();
      }
      
      void Stream::StopStream() {
          vWidget->deleteLater();
          //vPlayer->setPosition(0); //tried but not helped
          vPlayer->stop();
          vPlayer->deleteLater(); // this crash the app if StreamUrl stoped streaming ..
          delete vPlayer; // this crash the app if StreamUrl stoped streaming ..
      }
      
      void Stream::ChangeUrl(QString Url) {
          vPlayer->setMedia(QUrl(Url););
      }
      

      how i can delete or remove the player ?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @Bossa said in [C++] Playing stream with QMediaPlayer app not responding:

      its will crush or stuck

      Then use debugger please and provide stack trace after crash.
      Also: why do you delete the widget and player and create new instances if you want to load new stream?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Bossa said in [C++] Playing stream with QMediaPlayer app not responding:

        its will crush or stuck

        Then use debugger please and provide stack trace after crash.
        Also: why do you delete the widget and player and create new instances if you want to load new stream?

        B Offline
        B Offline
        Bossa
        wrote on last edited by
        #3

        @jsulm i tried to delete i tried to reload new media with vPlayer->setMedia(QUrl(Url)); but after the stream link is down its look like the player is stuck (no responding)
        i dont get any errors its just stuck for 1-2 min

        jsulmJ 1 Reply Last reply
        0
        • B Bossa

          @jsulm i tried to delete i tried to reload new media with vPlayer->setMedia(QUrl(Url)); but after the stream link is down its look like the player is stuck (no responding)
          i dont get any errors its just stuck for 1-2 min

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Bossa In debugger you could still see where it is stuck

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          B 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Bossa In debugger you could still see where it is stuck

            B Offline
            B Offline
            Bossa
            wrote on last edited by Bossa
            #5

            @jsulm as i said its stuck on this vPlayer->deleteLater(); and delete vPlayer; and vPlayer->setMedia(QUrl(Url)); and vPlayer->play();

            if i do only vPlayer->deleteLater(); its stuck
            if i do only delete vPlayer; its stuck
            if i do only vPlayer->setMedia(QUrl(Url)); its stuck
            if i do only vPlayer->play(); its stuck

            lets say like that ..
            i open my app ..
            i run in my cmd ffmpeg.exe to stream my screen to my rmtp server and now i have link to my stream like that https://example.com:2083/live/stream.flv
            i call the function LoadStream() and its working i can see the video
            now i close the cmd with the ffmpeg to stop sharescreen
            the video is black ..
            now if ill try to remove or to reload QMediaPlayer its stuck ..
            lets say i open again the cmd and run ffmpeg and run vPlayer->play(); its stuck if ill try to reload the link vPlayer->setMedia(QUrl(Url)); its stuck ....

            all this happend only if i close the stream before i remove or stop the QMediaPlayer ..

            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