Results 1 to 2 of 2

Thread: set raw data buffer to QMediaPlayer

  1. #1
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default set raw data buffer to QMediaPlayer

    I want to get a screen shot of the widget application and then set its raw data buffer to QMeidaPlayer with setMedia(). If anyone tried this before, I would thank if you tell me how to do that:

    Qt Code:
    1. QPixmap originalPixmap = QPixmap::grabWidget(this);
    2.  
    3. QImage *image = new QImage(originalPixmap.toImage());
    4.  
    5.  
    6. QBuffer buffer(&ba);
    7.  
    8. buffer.setBuffer(&ba);
    9.  
    10. buffer.open(QIODevice::WriteOnly);
    11.  
    12. image->save(&buffer); // writes image into ba in PNG format
    13.  
    14. image->save("/home/saman/Desktop/myImage", "PNG");
    15.  
    16. mediaPlayer.setMedia(QUrl::fromLocalFile("/home/saman/Desktop/png/images08.jpeg")); //I want this to read from raw data
    17.  
    18. mediaPlayer.play();
    To copy to clipboard, switch view to plain text mode 

    I note again, what i have done is to receive the image, SAVE it, and then read from it. However, I would like to ask you how to read raw data directly without saving it into media player.

    Qt Code:
    1. // saving
    2. counter = 1;
    3. image.save("/home/saman/image", "JPG");
    4. counter = 0;
    To copy to clipboard, switch view to plain text mode 

    somewhere else, reading
    Qt Code:
    1. if(counter == 0)
    2. {
    3. mediaPlayer.setMedia(QUrl::fromLocalFile("/home/saman/image"));
    4. mediaPlayer.play();
    5. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by saman_artorious; 19th August 2013 at 14:23.

  2. #2
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: set raw data buffer to QMediaPlayer

    Quote Originally Posted by saman_artorious View Post
    I want to get a screen shot of the widget application and then set its raw data buffer to QMeidaPlayer with setMedia(). If anyone tried this before, I would thank if you tell me how to do that:

    Qt Code:
    1. QPixmap originalPixmap = QPixmap::grabWidget(this);
    2.  
    3. QImage *image = new QImage(originalPixmap.toImage());
    4.  
    5.  
    6. QBuffer buffer(&ba);
    7.  
    8. buffer.setBuffer(&ba);
    9.  
    10. buffer.open(QIODevice::WriteOnly);
    11.  
    12. image->save(&buffer); // writes image into ba in PNG format
    13.  
    14. image->save("/home/saman/Desktop/myImage", "PNG");
    15.  
    16. mediaPlayer.setMedia(QUrl::fromLocalFile("/home/saman/Desktop/png/images08.jpeg")); //I want this to read from raw data
    17.  
    18. mediaPlayer.play();
    To copy to clipboard, switch view to plain text mode 

    I note again, what i have done is to receive the image, SAVE it, and then read from it. However, I would like to ask you how to read raw data directly without saving it into media player.

    Qt Code:
    1. // saving
    2. counter = 1;
    3. image.save("/home/saman/image", "JPG");
    4. counter = 0;
    To copy to clipboard, switch view to plain text mode 

    somewhere else, reading
    Qt Code:
    1. if(counter == 0)
    2. {
    3. mediaPlayer.setMedia(QUrl::fromLocalFile("/home/saman/image"));
    4. mediaPlayer.play();
    5. }
    To copy to clipboard, switch view to plain text mode 
    What I did is to use:
    Qt Code:
    1. QMediaResource rsrc(QUrl::fromUserInput(image.text()));
    2. QMediaContent ctnt(rsrc);
    3. mediaPlayer.setMedia(ctnt);
    4. mediaPlayer.play();
    To copy to clipboard, switch view to plain text mode 
    but this, does not show anything. I need help over here, give me advice please.

Similar Threads

  1. Appending data to the buffer of a QAudioOutput
    By PLM in forum Qt Programming
    Replies: 6
    Last Post: 19th August 2013, 03:01
  2. Replies: 13
    Last Post: 10th March 2011, 07:35
  3. Clear QTcpSocket buffer before using receiving new data
    By tbscope in forum Qt Programming
    Replies: 2
    Last Post: 26th February 2011, 06:50
  4. Replies: 2
    Last Post: 29th September 2008, 00:08
  5. setting data of buffer to QTreeWidget column
    By thomasjoy in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 17:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.