linphone-desktop/Linphone/view/Control/Display/Chat/VideoFileView.qml
2025-10-23 12:39:16 +02:00

72 lines
No EOL
2.2 KiB
QML

import QtQuick
import QtQuick.Controls as Control
import QtQuick.Layouts
import QtMultimedia
import Linphone
import UtilsCpp
import 'qrc:/qt/qml/Linphone/view/Control/Tool/Helper/utils.js' as Utils
// =============================================================================
Rectangle {
id: mainItem
color: DefaultStyle.grey_1000
property ChatMessageContentGui contentGui
property string filePath: contentGui && contentGui.core.filePath
property var fillMode: playbackState === MediaPlayer.PlayingState ? VideoOutput.PreserveAspectFit : VideoOutput.PreserveAspectCrop
property alias videoOutput: output
property string source: mediaPlayer.source
MediaPlayer {
id: mediaPlayer
source: UtilsCpp.isVideo(mainItem.filePath) ? "file:///" + mainItem.filePath : ""
position: 100
videoOutput: output
}
VideoOutput {
id: output
fillMode: mainItem.fillMode
endOfStreamPolicy: VideoOutput.KeepLastFrame
width: mainItem.width
height: mainItem.height
Component.onCompleted: {
// We need to start the video so the content rect of the
// video output is updated
mediaPlayer.play()
mediaPlayer.pause()
}
Text {
z: parent.z + 1
property int timeDisplayed: mediaPlayer.playbackState === MediaPlayer.PlayingState ? mediaPlayer.position : mediaPlayer.duration
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.bottomMargin: Utils.getSizeWithScreenRatio(6)
anchors.leftMargin: Utils.getSizeWithScreenRatio(6)
text: UtilsCpp.formatDuration(timeDisplayed)
color: DefaultStyle.grey_0
font {
pixelSize: Typography.d1.pixelSize
weight: Typography.d1.weight
}
}
}
MouseArea {
propagateComposedEvents: false
enabled: mainItem.visible
anchors.fill: parent
hoverEnabled: false
acceptedButtons: Qt.LeftButton
onClicked: (mouse) => {
mouse.accepted = true
mediaPlayer.playbackState === MediaPlayer.PlayingState ? mediaPlayer.pause() : mediaPlayer.play()
}
}
EffectImage {
anchors.centerIn: parent
visible: mediaPlayer.playbackState !== MediaPlayer.PlayingState
width: Utils.getSizeWithScreenRatio(24)
height: Utils.getSizeWithScreenRatio(24)
imageSource: AppIcons.playFill
colorizationColor: DefaultStyle.main2_0
}
}