summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurice Kalinowski <maurice.kalinowski@qt.io>2017-12-12 13:33:34 +0100
committerMaurice Kalinowski <maurice.kalinowski@qt.io>2017-12-12 14:41:38 +0000
commit68abdc5bb2042a0f896e822eecd5ed49350c0c43 (patch)
treeb94cdf46669c13f6cf5ea5763e9eba97a896b033
parent08ff740f7d5350c8f03db95fdbfd32bf84d4c527 (diff)
downloadqtmultimedia-68abdc5bb2042a0f896e822eecd5ed49350c0c43.tar.gz
winrt: Store output to cache location
By default sandboxing does not allow to store a file outside the package. Task-number: QTBUG-60904 Change-Id: I586616713315eadafd6bb24a8f8c12eb794557f6 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
-rw-r--r--examples/multimedia/audiorecorder/audiorecorder.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/multimedia/audiorecorder/audiorecorder.cpp b/examples/multimedia/audiorecorder/audiorecorder.cpp
index 312b2d2aa..9dd3368e0 100644
--- a/examples/multimedia/audiorecorder/audiorecorder.cpp
+++ b/examples/multimedia/audiorecorder/audiorecorder.cpp
@@ -58,6 +58,7 @@
#include <QDir>
#include <QFileDialog>
#include <QMediaRecorder>
+#include <QStandardPaths>
static qreal getPeakValue(const QAudioFormat &format);
static QVector<qreal> getBufferLevels(const QAudioBuffer &buffer);
@@ -221,7 +222,17 @@ void AudioRecorder::togglePause()
void AudioRecorder::setOutputLocation()
{
+#ifdef Q_OS_WINRT
+ // UWP does not allow to store outside the sandbox
+ const QString cacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
+ if (!QDir().mkpath(cacheDir)) {
+ qWarning() << "Failed to create cache directory";
+ return;
+ }
+ QString fileName = cacheDir + QLatin1String("/output.wav");
+#else
QString fileName = QFileDialog::getSaveFileName();
+#endif
m_audioRecorder->setOutputLocation(QUrl::fromLocalFile(fileName));
m_outputLocationSet = true;
}