diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-08-28 00:38:33 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-08-29 16:32:22 +0200 |
commit | 09c041c8ac40d2d3608c7224614fde69e1e4f08b (patch) | |
tree | b606a260d7f22a703684e186a0af9d8215be734d /resources/qml/delegates | |
parent | Remove CC-BY as main project license (diff) | |
download | nheko-09c041c8ac40d2d3608c7224614fde69e1e4f08b.tar.xz |
Use in memory media player instead of storing unencrypted files on disk
Diffstat (limited to 'resources/qml/delegates')
-rw-r--r-- | resources/qml/delegates/PlayableMediaMessage.qml | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml index 73c74ec0..94c058ab 100644 --- a/resources/qml/delegates/PlayableMediaMessage.qml +++ b/resources/qml/delegates/PlayableMediaMessage.qml @@ -3,9 +3,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later import "../" -import QtMultimedia 5.6 -import QtQuick 2.12 -import QtQuick.Controls 2.1 +import QtMultimedia 5.15 +import QtQuick 2.15 +import QtQuick.Controls 2.15 import QtQuick.Layouts 1.2 import im.nheko 1.0 @@ -55,7 +55,8 @@ Rectangle { VideoOutput { anchors.fill: parent fillMode: VideoOutput.PreserveAspectFit - source: media + flushMode: VideoOutput.FirstFrame + source: mxcmedia } } @@ -93,15 +94,15 @@ Rectangle { return hh + ":" + mm + ":" + ss; } - positionText.text = formatTime(new Date(media.position)); - durationText.text = formatTime(new Date(media.duration)); + positionText.text = formatTime(new Date(mxcmedia.position)); + durationText.text = formatTime(new Date(mxcmedia.duration)); } Layout.fillWidth: true - value: media.position + value: mxcmedia.position from: 0 - to: media.duration - onMoved: media.seek(value) + to: mxcmedia.duration + onMoved: mxcmedia.position = value onValueChanged: updatePositionTexts() palette: Nheko.colors } @@ -132,15 +133,15 @@ Rectangle { onClicked: { switch (button.state) { case "": - room.cacheMedia(eventId); + mxcmedia.eventId = eventId; break; case "stopped": - media.play(); + mxcmedia.play(); console.log("play"); button.state = "playing"; break; case "playing": - media.pause(); + mxcmedia.pause(); console.log("pause"); button.state = "stopped"; break; @@ -172,29 +173,22 @@ Rectangle { cursorShape: Qt.PointingHandCursor } - MediaPlayer { - id: media + MxcMedia { + id: mxcmedia + roomm: room onError: console.log(errorString) - onStatusChanged: { - if (status == MediaPlayer.Loaded) + onMediaStatusChanged: { + if (status == MxcMedia.LoadedMedia) { progress.updatePositionTexts(); - + button.state = "stopped"; + } } - onStopped: button.state = "stopped" - } - - Connections { - function onMediaCached(mxcUrl, cacheUrl) { - if (mxcUrl == url) { - media.source = cacheUrl; + onStateChanged: { + if (state == MxcMedia.StoppedState) { button.state = "stopped"; - console.log("media loaded: " + mxcUrl + " at " + cacheUrl); } - console.log("media cached: " + mxcUrl + " at " + cacheUrl); } - - target: room } } |