telephant/qml/MediaPopup.qml

66 lines
1.9 KiB
QML
Raw Normal View History

2020-02-28 05:36:47 +01:00
import QtQuick 2.4
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
import QtQuick.Layouts 1.3
2020-02-28 12:14:07 +01:00
import QtMultimedia 5.9
2020-02-28 05:36:47 +01:00
Popup {
property var url
id: popup
modal: true
focus: true
2020-02-28 12:14:07 +01:00
height: mediaItem.height + 16
width: mediaItem.width + 16
2020-02-28 05:36:47 +01:00
anchors.centerIn: mainWindow.overlay
2020-02-28 12:14:07 +01:00
Item {
id: mediaItem
Image {
id: image
height: Math.min(sourceSize.height, mainWindow.height * 0.8)
width: Math.min(sourceSize.width, mainWindow.width * 0.8)
anchors.centerIn: parent
smooth: true
fillMode: Image.PreserveAspectFit
source: visible ? url : ""
visible: !(url.endsWith(".webm") || url.endsWith(".mp4"))
}
Video {
id: video
// height: Math.min(sourceSize.height, mainWindow.height * 0.8)
// width: Math.min(sourceSize.width, mainWindow.width * 0.8)
width: metaData.resolution ? Math.min(metaData.resolution.width, mainWindow.width * 0.8) : 0
height: metaData.resolution ? Math.min(metaData.resolution.height, mainWindow.height * 0.8) : 0
autoLoad: true
autoPlay: false
loops: MediaPlayer.Infinite
anchors.centerIn: parent
fillMode: VideoOutput.PreserveAspectFit
source: visible ? url : ""
visible: url.endsWith(".webm") || url.endsWith(".mp4")
onStatusChanged: {
if(status == MediaPlayer.Loaded)
video.play()
}
/*
MouseArea {
anchors.fill: parent
onClicked: {
if (video.playbackState != MediaPlayer.PausedState) {
video.play()
} else {
video.pause()
}
}
}
*/
}
2020-02-28 05:36:47 +01:00
}
}