9#include "qmediaplaylist.h"
16#include "qcameraviewfinder.h"
17#include "qaudiorecorder.h"
21class MediaExample :
public QObject {
27 void recorderSettings();
32 QVideoWidget *videoWidget;
35 QAudioOutput *audioOutput;
36 QMediaPlaylist *playlist;
38 QMediaRecorder *recorder;
40 QCameraViewfinder *viewfinder;
41 QImageCapture *imageCapture;
49void MediaExample::MediaControl()
54void MediaExample::recorderSettings()
57 QMediaFormat format(QMediaFormat::MPEG4);
58 format.setVideoCodec(QMediaRecorder::VideoCodec::H264);
59 format.setAudioCodec(QMediaRecorder::AudioCodec::MP3);
61 recorder->setMediaFormat(settings);
65void MediaExample::imageSettings()
68 imageCapture->setFileFormat(QImageCapture::JPEG);
69 imageCapture->setResolution(1600, 1200);
73void MediaExample::MediaPlayer()
76 player =
new QMediaPlayer;
77 audioOutput =
new QAudioOutput;
78 player->setAudioOutput(audioOutput);
79 connect(player, &QMediaPlayer::positionChanged,
this, &MediaExample::positionChanged);
80 player->setSource(QUrl::fromLocalFile(
"/Users/me/Music/coolsong.mp3"));
81 audioOutput->setVolume(0.5);
86 player =
new QMediaPlayer;
87 audioOutput =
new QAudioOutput;
88 player->setAudioOutput(audioOutput);
90 player->setSource(QUrl::fromLocalFile(
"/Users/me/Music/coolsong.mp3"));
91 audioOutput->setVolume(0.5);
96void MediaExample::MediaRecorder()
99 QMediaCaptureSession session;
100 QAudioInput audioInput;
101 session.setAudioInput(&input);
103 session.setRecorder(&recorder);
104 recorder.setQuality(QMediaRecorder::HighQuality);
105 recorder.setOutputLocation(QUrl::fromLocalFile(
"test.mp3"));