To Record audio and store it in a location and play it again?
Hi All,
I am trying to work out a prog with 3 buttons in qml,one for recording an audio,another for stopping and another for playing it. I need to record the audio and store them in a location(path) and retrieve it for playing it again.
I have seen these links but could not find any solution from it.
Link 1”:http://doc.qt.nokia.com/qtmobility-1.2/multimedia.html “
using this link i am not able to get any idea to proceed..
I have seen this similar forum”:http://developer.qt.nokia.com/forums/viewthread/14278/ “
But none replied i guess. I am expecting some solutions regarding this !!!
Can anyone help me in sorting out..
6 replies
Hi All,
I cannot Understand spectrum properly batosai..so i am trying this I have checked this link [qtforum.org] and tried some functions from those. Now i am able to play the song.. I cannot able to stop and also cannot record the song or voice on my own.Here is my code.AudioBuffer.cpp
- #include "AudioBuffer.h"
- #include <QAudio>
- #include <QMediaPlayer>
- #include <QAudioCaptureSource>
- #include <QAudioInput>
- #include <QAudiooutput>
- #include <QAudioCaptureSource>
- #include <QMediaRecorder>
- AudioBuffer::AudioBuffer()
- {
- audioSource = new QAudioCaptureSource();
- capture = new QMediaRecorder(audioSource);
- QAudioEncoderSettings es;
- es.setCodec("audio/mp3");
- es.setSampleRate(96000);
- capture->setEncodingSettings(es);
- // active = false;
- }
- AudioBuffer::~AudioBuffer()
- {
- delete audioSource;
- delete capture;
- }
- void AudioBuffer::record()
- {
- ???
- capture->record();
- ???
- }
- void AudioBuffer::stop()
- {
- ????
- QMediaPlayer *player = new QMediaPlayer;
- capture->stop();
- qDebug()<<"Player Stopped";
- ????
- }
- void AudioBuffer::play()
- {
- QMediaPlayer *player = new QMediaPlayer;
- player->setMedia(url);
- qDebug()<< url;
- player->setVolume(100);
- qDebug()<<"Player: "<< player->errorString();
- player->play();
- qDebug()<<"Player: "<< player->errorString();
- }
AudioBuffer.h
- #include <QUrl>
- #include <QObject>
- #include <QAudioFormat>
- #include <QAudioCaptureSource>
- #include <QMediaRecorder>
- {
- Q_OBJECT
- public:
- AudioBuffer();
- ~AudioBuffer();
- public slots:
- void stop();
- void play();
- void record();
- private:
- QAudioCaptureSource *audioSource;
- QMediaRecorder *capture;
- };
MainPage.Qml
- Page {
- id: mainPage
- Button {
- id: button1
- x: 16
- y: 324
- width: 100
- height: 42
- text: "Play"
- onClicked:
- AudioBuffer.play()
- }
- Button {
- id: button2
- x: 126
- y: 324
- width: 100
- height: 42
- text: "Stop"
- onClicked:
- AudioBuffer.stop()
- }
- Button {
- id: button3
- x: 247
- y: 324
- width: 100
- height: 42
- text: "Record"
- onClicked:
- AudioBuffer.record()
- }
- }
SOLVED:
Hi All,
I finally found the solution on my own.. I would like to share with you all !!!!
- #include "AudioBuffer.h"
- #include <QAudio>
- #include <QMediaPlayer>
- #include <QAudioCaptureSource>
- #include <QMediaRecorder>
- #include <QFileDialog>
- #include <QFile>
- #include <QAudioEncoderSettings>
- AudioBuffer::AudioBuffer()
- {
- audioSource = new QAudioCaptureSource();
- capture = new QMediaRecorder(audioSource);
- QAudioEncoderSettings audioSettings;
- audioSettings.setCodec("audio/vorbis");
- audioSettings.setQuality(QtMultimediaKit::HighQuality);
- capture->setEncodingSettings(audioSettings);
- }
- AudioBuffer::~AudioBuffer()
- {
- delete audioSource;
- delete capture;
- }
- void AudioBuffer::record()
- {
- capture->record();
- }
- void AudioBuffer::stop()
- {
- capture->stop();
- }
- void AudioBuffer::pause()
- {
- capture->pause();
- }
- void AudioBuffer::play()
- {
- QMediaPlayer *player = new QMediaPlayer;
- player->setMedia(url);
- player->setVolume(100);
- player->play();
- }
Thanks a Lot!!!!
I hope this works well
You must log in to post a reply. Not a member yet? Register here!



