From 68abdc5bb2042a0f896e822eecd5ed49350c0c43 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Tue, 12 Dec 2017 13:33:34 +0100 Subject: 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 --- examples/multimedia/audiorecorder/audiorecorder.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'examples/multimedia') 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 #include #include +#include static qreal getPeakValue(const QAudioFormat &format); static QVector 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; } -- cgit v1.2.3