findthisdevice: Add audio playback
Similar to the C++ kcm
This commit is contained in:
parent
20bba74b0b
commit
9832f380dc
3 changed files with 24 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
QString FindThisDeviceHelper::defaultSound()
|
QString FindThisDeviceHelper::defaultSound()
|
||||||
|
@ -48,3 +49,8 @@ QString FindThisDeviceHelper::defaultSound()
|
||||||
}
|
}
|
||||||
return soundURL.toLocalFile();
|
return soundURL.toLocalFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FindThisDeviceHelper::pathExists(const QString &path)
|
||||||
|
{
|
||||||
|
return QFileInfo::exists(path);
|
||||||
|
}
|
||||||
|
|
|
@ -17,4 +17,5 @@ class FindThisDeviceHelper : public QObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Q_INVOKABLE QString defaultSound();
|
static Q_INVOKABLE QString defaultSound();
|
||||||
|
bool pathExists(const QString &path);
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,9 +52,25 @@ Kirigami.ScrollablePage {
|
||||||
QQC2.Button {
|
QQC2.Button {
|
||||||
text: i18nc("@action:button", "Choose file")
|
text: i18nc("@action:button", "Choose file")
|
||||||
display: QQC2.Button.IconOnly
|
display: QQC2.Button.IconOnly
|
||||||
icon.name: "document-open"
|
icon.name: "document-open-symbolic"
|
||||||
onClicked: fileDialog.open()
|
onClicked: fileDialog.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QQC2.Button {
|
||||||
|
text: i18nc("@action:button", "Play")
|
||||||
|
display: QQC2.Button.IconOnly
|
||||||
|
icon.name: playMusic.playing ? "media-playback-stop-symbolic" : "media-playback-start-symbolic"
|
||||||
|
enabled: FindThisDevice.FindThisDeviceHelper.pathExists(path.text)
|
||||||
|
onClicked: {
|
||||||
|
playMusic.source = path.text;
|
||||||
|
playMusic.playing ? playMusic.stop() : playMusic.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
MediaPlayer {
|
||||||
|
id: playMusic
|
||||||
|
audioOutput: AudioOutput {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue