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::MediaSource from QBuffer
Forum Updated to NodeBB v4.3 + New Features

Phonon::MediaSource from QBuffer

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 4.1k 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.
  • M Offline
    M Offline
    MiGryz
    wrote on last edited by
    #1

    Hello, I'm new to Phonon and came across the following problem.

    I need to play mp3 file. If I use Phonon::MediaSource( "./mediafile.mp3" ) and pass it to Phonon::MediaObject, then everything works ok. But the problem is that I have serialized contents of mediafile in the form of QByteArray. I am trying to play it the following way:

    @
    Phonon::AudioOutput audioOutput( Phonon::MusicCategory, NULL );
    Phonon::MediaObject mediaObject( NULL );
    Phonon::createPath( &mediaObject, &audioOutput );

    QFile file( "./about_hackers.mp3" );
    file.open( QIODevice::ReadOnly );

    QByteArray ss( file.readAll( ) );
    QBuffer buff( &ss, NULL );
    buff.open( QIODevice::ReadOnly );

    Phonon::MediaSource source( &buff );

    QObject::connect( &mediaObject, SIGNAL(finished()), &app, SLOT(quit()) );

    mediaObject.setCurrentSource( source );
    mediaObject.play( );

    return app.exec();
    @

    However while using this code, I get the following error:
    @xine is asking to seek behind the end of the data stream@

    Can someone help me solve this problem? or just give a better idea how to play serialized audio (different formats possible).

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jim_kaiser
      wrote on last edited by
      #2

      Okay... from documentation:

      bq. MediaSource::MediaSource ( QIODevice * ioDevice )
      Creates a MediaSource object for the QIODevice specified by ioDevice.
      This constructor can be very handy in the combination of QByteArray and QBuffer.
      If you need to fetch multimedia data from a source that is not supported by MediaSource, you should subclass QIODevice and use this MediaSource constructor. It is important that you reimplement QIODevice::isSequential(), as it is used by MediaSource to determine if the media source is seekable.

      So, guessing you're missing the isSequential()?

      Also, by default Phonon uses the GStreamer backend on linux, so you could get support for other formats by just installing the appropriate GStreamer plugin..

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MiGryz
        wrote on last edited by
        #3

        Thank you for reply, but isn't QBuffer already a QIODevice that has isSequential implemented?

        I guess that at this point, problem is that Phonon recognizes this media source as a video stream and by some reason tries to play it with Xine.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          grio
          wrote on last edited by
          #4

          [quote author="jim_kaiser" date="1308302390"]Okay... from documentation:
          So, guessing you're missing the isSequential()?
          [/quote]

          I'm try to use QFile as MediaSource to access to mp3 files in Qt Resource (qrc). And I have the same problem as MiGryz.
          Reimplement isSequential() in QFile with a 'false' result have no effect.
          Mp3 sometimes playing, sometimes not, sometimes breaks in the middle.

          If I open the same mp3 as local files(not from qrc) - no problem.

          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