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. Phonon: play video from a buffer

Phonon: play video from a buffer

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.7k Views 1 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.
  • Q Offline
    Q Offline
    Qt_User
    wrote on last edited by
    #1

    Hello,

    Here is the general idea of the projet:

    • I read a video stream from a QUdpSocket
    • I append the data to a buffer (actually to a QByteArray)
    • I wait 10 seconds so that I have enough data in the buffer
    • I set the buffer as a Phonon::MediaSource to be played by a Phonon::VideoPlayer

    And here is the problem:
    I would like to append data continuously to the buffer, and I want these data to be read by the VideoPlayer but the player plays well the first 10 seconds of the video and stops (while data are still added to the buffer from the QUdpSocket).

    How can I make the VideoPlayer read the continuously ?

    Complementary info:

    • The video stream is generated by vlc from a local file.
    • When I set the local file directlty as a MediaSource (instead of the buffer), the player works correctly.

    Some code:
    @
    datagram = new QByteArray();
    bufferCam = new QBuffer(datagram);
    ...
    udpSocket = new QUdpSocket(this);
    udpSocket->bind(QHostAddress("10.1.153.126"), mSocket);
    connect(udpSocket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
    ...
    /* wait 10s */
    player->mediaObject()->setCurrentSource(Phonon::MediaSource(bufferCam));
    player->play();

    ...

    void VideoView::readPendingDatagrams() {
    while (udpSocket->hasPendingDatagrams()) {
    char *data = new char[udpSocket->pendingDatagramSize()];
    QHostAddress sender;
    quint16 senderPort;

        int len = udpSocket->readDatagram(data, udpSocket->pendingDatagramSize(),
                                &sender, &senderPort);
    
        datagram->append(data, len);
        /* process data */
    }
    

    }
    @

    I hope I gave you enough info so that you can help me. Thanks
    excuse me if my english is bad

    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