Results 1 to 2 of 2

Thread: Read audio file while i downloading it

  1. #1
    Join Date
    Jun 2014
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Angry Read audio file while i downloading it

    Hello all the world!
    I would like to set up an application which would be able to read musics cuts out of small piece.
    Admittedly, while I download the parts in the order of a file, I wish to start to read the first pieces I wish to read these musics with the Phonon module included in my version of QT

    Thanks for reading ! if you have idea, a solution !

    Here what I have to begin has to make:
    Qt Code:
    1. Phonon::MediaObject* music;
    2.  
    3. void MainWindow::on_pushButton_clicked()
    4. {
    5. QFile* MonFichier = new QFile(QString("C:/SPLIT/ORIGINAL.wav.001"));
    6. MonFichier->open(QIODevice::ReadOnly);
    7.  
    8. QByteArray* MonArray = new QByteArray();
    9. MonArray->resize(40000000);
    10. MonArray->replace(0,MonFichier->readAll().length(),MonFichier->readAll());
    11. MonArray->resize(40000000);
    12.  
    13. QBuffer* MonBuffer = new QBuffer(MonArray);
    14. MonBuffer->open(QIODevice::ReadWrite);
    15. }
    16.  
    17. void MainWindow::on_pushButton_2_clicked()
    18. {
    19. qint64 Temp = music->currentTime();
    20.  
    21. music->seek(Temp);
    22. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Read audio file while i downloading it

    QFile::readAll() returs the file's content and moves the "file pointer", i.e. positions the seek position at the end of the file.
    So your two subsequent readAll() calls have different results.

    Something like this would probably be better
    Qt Code:
    1. // on the stack unless you really need the file to remain open after the method ends.
    2. QFile MonFichier(QString("C:/SPLIT/ORIGINAL.wav.001"));
    3. MonFichier.open(QIODevice::ReadOnly);
    4.  
    5. QByteArray MonArray = MonFichier.readlAll();
    6. MonArray->resize(40000000);
    7.  
    8. QBuffer* MonBuffer = new QBuffer(this);
    9. MonBUffer->setData(MonArray);
    10. MonBuffer->open(QIODevice::ReadWrite);
    11. }
    To copy to clipboard, switch view to plain text mode 

    If you are downloading the file using some Qt I/O classes, you might be able to skip writing to a file, i.e. write the recieved data into the buffer object directly

    Cheers,
    _

Similar Threads

  1. Concurrent file downloading
    By Alir3z4 in forum Qt Programming
    Replies: 14
    Last Post: 21st February 2012, 15:56
  2. Replies: 5
    Last Post: 11th February 2012, 22:17
  3. File size of a remote file without downloading it
    By dirkdepauw in forum Qt Programming
    Replies: 5
    Last Post: 4th November 2010, 09:48
  4. How to read RAW audio file ?
    By fitzy in forum Qt Programming
    Replies: 2
    Last Post: 6th August 2010, 13:37
  5. Read audio CD tracks as files
    By skepticalgeek in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2010, 11:25

Tags for this Thread

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.