import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtMultimedia 5.4
ApplicationWindow {
title: qsTr("Hello World")
//width: Screen.desktopAvailableWidth
//height: Screen.desktopAvailableHeight
width: 640
height: 480
visible: true
Rectangle {
color: "black"
anchors.fill: parent
MediaPlayer {
id: mediaPlayer
source: "file:///c:/test.mp4"
autoPlay: true
}
VideoOutput {
id: video
anchors.fill: parent
source: mediaPlayer
}
}
Rectangle {
id: progressBar
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 0
height: 10
color: "lightGray"
Rectangle {
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
width: mediaPlayer.duration>0?parent.width*mediaPlayer.position/mediaPlayer.duration:0
color: "darkGreen"
}
MouseArea {
property int pos
anchors.fill: parent
onClicked: {
if (mediaPlayer.seekable)
pos = mediaPlayer.duration * mouse.x/width
mediaPlayer.seek(pos)
}
}
}
}
代码:
本文展示了一个使用Qt Quick和Qt Multimedia模块创建的简单多媒体播放器示例。该示例演示了如何加载并自动播放一个视频文件,同时提供进度条以实现视频播放位置的跳转功能。

被折叠的 条评论
为什么被折叠?



