qt - 如何使用 video 5.12 qt qml 播放视频?
问题描述
我想用播放按钮播放视频,暂停,在10秒内转发视频,然后使用qml返回视频,但我不知道如何。
像这样的东西:
import QtQuick 2.12
import QtQuick.Window 2.12
import QtMultimedia 5.12
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.12
Window {
visible: true
width: 840
height: 680
title: qsTr("Hello World")
ColumnLayout{
Video {
id: video
width : 600
height : 600
source: "a.avi"
}
RowLayout{
Button {
width: 80
height: 80
text: "play"
onClicked: {video.play()}
}
Button {
width: 80
height: 80
text: "pause"
onClicked: {video.pause()}
}
Button {
width: 80
height: 80
text: "foward"
onClicked: {video.foward()}
}
Button {
width: 80
height: 80
text: "back"
onClicked: {video.back()}
}
}
}
}
解决方案
问题是来源。您需要使用 URL 格式:
source: "file:///home/user/videos/a.avi"
或者,您可以使用 QtResources 文件 ( ) 将视频嵌入到可执行文件中.qrc
。
推荐阅读
- javascript - ajax + django,点击按钮随机
- java - 基于具有 java.time API 的 Locale 以正确顺序排列的工作日
- spring-boot - 关系 jv_commit 已经存在
- node.js - 猫鼬需要真正的 req.body.name {}
- java - 为 Web 开发做出反应而不是替代方案
- ruby-on-rails - Rails,Postgres:dyld:惰性符号绑定失败:找不到符号:_PQresultMemorySize
- python - 损失在迭代中不断增加
- sql - Azure SQL 数据同步初始同步不起作用
- css - Angular 8 [class] 与 if、else if、else 绑定
- javascript - Node.js 从匿名函数访问值