This commit is contained in:
朱子楚\zhuzi 2023-06-13 22:00:15 +08:00
parent 2a5acb45a1
commit c3b3dc904e
8 changed files with 3 additions and 458 deletions

View File

@ -20,7 +20,7 @@ endif()
file(TO_CMAKE_PATH "/" PATH_SEPARATOR) file(TO_CMAKE_PATH "/" PATH_SEPARATOR)
# #
add_definitions(-DVERSION=1,3,3,0) add_definitions(-DVERSION=1,3,4,0)
find_package(Qt6 REQUIRED COMPONENTS Quick REQUIRED) find_package(Qt6 REQUIRED COMPONENTS Quick REQUIRED)

View File

@ -13,7 +13,6 @@ Window {
"/":"qrc:/example/qml/window/MainWindow.qml", "/":"qrc:/example/qml/window/MainWindow.qml",
"/about":"qrc:/example/qml/window/AboutWindow.qml", "/about":"qrc:/example/qml/window/AboutWindow.qml",
"/login":"qrc:/example/qml/window/LoginWindow.qml", "/login":"qrc:/example/qml/window/LoginWindow.qml",
"/media":"qrc:/example/qml/window/MediaWindow.qml",
"/singleTaskWindow":"qrc:/example/qml/window/SingleTaskWindow.qml", "/singleTaskWindow":"qrc:/example/qml/window/SingleTaskWindow.qml",
"/standardWindow":"qrc:/example/qml/window/StandardWindow.qml", "/standardWindow":"qrc:/example/qml/window/StandardWindow.qml",
"/singleInstanceWindow":"qrc:/example/qml/window/SingleInstanceWindow.qml" "/singleInstanceWindow":"qrc:/example/qml/window/SingleInstanceWindow.qml"

View File

@ -279,22 +279,6 @@ FluObject{
} }
} }
FluPaneItemExpander{
title:lang.media
icon:FluentIcons.Media
FluPaneItem{
title:"MediaPlayer"
image:"qrc:/example/res/image/control/MediaPlayerElement.png"
recentlyAdded:true
order:0
desc:"A control to display video and image content."
onTap:{
navigationView.push("qrc:/example/qml/page/T_MediaPlayer.qml")
}
}
}
FluPaneItemExpander{ FluPaneItemExpander{
title:lang.other title:lang.other
icon:FluentIcons.Shop icon:FluentIcons.Shop

View File

@ -1,62 +0,0 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Window
import FluentUI
import "qrc:///example/qml/component"
FluScrollablePage{
title:"MediaPlayer"
onVisibleChanged: {
if(visible){
player.play()
}else{
player.pause()
}
}
FluArea{
Layout.fillWidth: true
height: 320
Layout.topMargin: 20
paddings: 10
ColumnLayout{
anchors{
verticalCenter: parent.verticalCenter
left:parent.left
}
FluMediaPlayer{
id:player
source:"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
}
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -1
code:'FluMediaPlayer{
id:player
source:"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
}
'
}
FluArea{
Layout.fillWidth: true
height: 68
Layout.topMargin: 20
paddings: 10
FluButton{
text:"跳转到视频播放器窗口"
anchors.verticalCenter: parent.verticalCenter
onClicked:{
FluApp.navigate("/media",{source:"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"})
}
}
}
}

View File

@ -1,30 +0,0 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import FluentUI
import "qrc:///example/qml/component"
CustomWindow {
title:"视频播放器"
width: 640
height: 480
minimumWidth: 640
minimumHeight: 480
onInitArgument:
(argument)=>{
player.source = argument.source
}
FluMediaPlayer{
id:player
anchors{
left: parent.left
right: parent.right
top: parent.top
bottom: parent.bottom
}
}
}

View File

@ -13,9 +13,9 @@ endif()
set(QML_PLUGIN_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI) set(QML_PLUGIN_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI)
# #
add_definitions(-DVERSION=1,3,3,0) add_definitions(-DVERSION=1,3,4,0)
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml ShaderTools) find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml)
#Cpp #Cpp
file(GLOB_RECURSE CPP_FILES *.cpp *.h) file(GLOB_RECURSE CPP_FILES *.cpp *.h)

View File

@ -1,202 +0,0 @@
import QtQuick
import QtQuick.Controls
import QtMultimedia
import FluentUI
Rectangle {
property url source
property bool showControl: false
property real volume: 30
id:control
width: 480
height: 270
color: FluColors.Black
clip: true
MouseArea{
anchors.fill: parent
preventStealing: true
onClicked: {
showControl = !showControl
}
}
MediaPlayer {
id: mediaplayer
property bool autoSeek:true
source: control.source
videoOutput: video_output
audioOutput: AudioOutput{
id:audio_output
}
onErrorStringChanged:
(error)=> {
console.debug(errorString)
}
onPositionChanged: {
if(autoSeek){
slider.seek(mediaplayer.position*slider.maxValue/mediaplayer.duration)
}
}
onMediaStatusChanged:
(status)=> {
if(status===2){
slider.maxValue = mediaplayer.duration
showControl = true
mediaplayer.play()
}
}
}
onSourceChanged: {
slider.seek(0)
}
VideoOutput {
id:video_output
anchors.fill: parent
}
Item{
height: 100
y:showControl ? control.height - 110 : control.height
anchors{
horizontalCenter: parent.horizontalCenter
}
width: 460
opacity: showControl
MouseArea{
anchors.fill: parent
}
Behavior on opacity{
NumberAnimation{
duration: 150
}
}
Behavior on y{
NumberAnimation{
duration: 150
}
}
Rectangle{
anchors.fill: parent
color:FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,0.97) : Qt.rgba(237/255,237/255,237/255,0.97)
radius: 5
}
FluSlider{
id:slider
size:parent.width-20
y:20
anchors.horizontalCenter: parent.horizontalCenter
tipEnabled:false
onPressed: {
mediaplayer.autoSeek = false
mediaplayer.pause()
}
value:mediaplayer.position
onReleased: {
mediaplayer.autoSeek = true
mediaplayer.play()
}
onValueChanged: {
if(mediaplayer.autoSeek == false){
mediaplayer.position = value*mediaplayer.duration/slider.maxValue
}
}
onLineClickFunc:function(val){
mediaplayer.position = val*mediaplayer.duration/slider.maxValue
}
}
FluText{
id:start_time
anchors{
top: slider.bottom
topMargin: 10
left: slider.left
}
text: formatDuration(slider.value*mediaplayer.duration/slider.maxValue)
}
FluText{
id:end_time
anchors{
top: slider.bottom
right: slider.right
topMargin: 10
}
text: formatDuration(mediaplayer.duration)
}
Row{
spacing: 10
anchors{
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
bottomMargin: 10
}
FluIconButton{
iconSize: 17
iconSource: FluentIcons.SkipBack10
onClicked: {
mediaplayer.position = Math.max(mediaplayer.position-10*1000,0)
}
}
FluIconButton{
iconSize: 15
iconSource: mediaplayer.playbackState === MediaPlayer.PlayingState ? FluentIcons.Pause : FluentIcons.Play
onClicked: {
if(mediaplayer.playbackState === MediaPlayer.PlayingState){
mediaplayer.pause()
}else{
mediaplayer.play()
}
}
}
FluIconButton{
iconSize: 17
iconSource: FluentIcons.SkipForward30
onClicked: {
mediaplayer.position = Math.min(mediaplayer.position+30*1000,mediaplayer.duration)
}
}
}
FluIconButton{
id:btn_volume
iconSize: 17
iconSource: audio_output.muted ? FluentIcons.Mute : FluentIcons.Volume
anchors{
left: parent.left
leftMargin: 5
bottom: parent.bottom
bottomMargin: 10
}
onClicked: {
audio_output.muted = !audio_output.muted
}
}
FluSlider{
id:slider_volume
size: 80
dotSize: 20
value:30
anchors{
left:btn_volume.right
verticalCenter: btn_volume.verticalCenter
leftMargin: 10
}
onValueChanged:{
audio_output.volume = value/100
}
}
}
function formatDuration(duration) {
const seconds = Math.floor(duration / 1000);
const hours = Math.floor(seconds / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const remainingSeconds = seconds % 60;
return `${pad(hours)}:${pad(minutes)}:${pad(remainingSeconds)}`;
}
function pad(value) {
return value.toString().padStart(2, '0');
}
function pause(){
mediaplayer.pause()
}
function play(){
mediaplayer.play()
}
}

View File

@ -1,144 +0,0 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Window
import FluentUI
MouseArea {
property int border: 4
property var window: Window.window
property bool fixedSize: {
if(window == null)
return true
if(window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
return true
}
return (window.minimumWidth === window.maximumWidth && window.minimumHeight === window.maximumHeight)
}
anchors.fill: parent
acceptedButtons: Qt.LeftButton
hoverEnabled: true
preventStealing: true
propagateComposedEvents: true
z: -65535
onPressed :
(mouse)=> {
if (fixedSize) {
return;
}
let e = 0;
if (ptInRect(0,0,border,border, mouse.x, mouse.y)) {
e = Qt.TopEdge | Qt.LeftEdge;
window.startSystemResize(e);
return;
}
if (ptInRect(border,0,window.width-border*2,border, mouse.x, mouse.y)) {
e = Qt.TopEdge;
window.startSystemResize(e);
return;
}
if (ptInRect(window.width-border,0,border,border, mouse.x, mouse.y)) {
e = Qt.TopEdge | Qt.RightEdge;
window.startSystemResize(e);
return;
}
if (ptInRect(window.width-border,border,border,window.height-border*2, mouse.x, mouse.y)) {
e = Qt.RightEdge;
window.startSystemResize(e);
return;
}
if (ptInRect(window.width-border,window.height-border,border,border, mouse.x, mouse.y)) {
e = Qt.BottomEdge | Qt.RightEdge;
window.startSystemResize(e);
return;
}
if (ptInRect(border,window.height-border,window.width-border*2,border, mouse.x, mouse.y)) {
e = Qt.BottomEdge;
window.startSystemResize(e);
return;
}
if (ptInRect(0,window.height-border,border,border, mouse.x, mouse.y)) {
e = Qt.BottomEdge | Qt.LeftEdge;
window.startSystemResize(e);
return;
}
if (ptInRect(0,border,border , window.height-border*2, mouse.x, mouse.y)) {
e = Qt.LeftEdge;
window.startSystemResize(e);
return;
}
}
onPositionChanged:
(mouse)=> {
if (fixedSize) {
cursorShape = Qt.ArrowCursor;
return;
}
if (ptInRect(0,0,border,border, mouse.x, mouse.y)) {
cursorShape = Qt.SizeFDiagCursor;
return;
}
if (ptInRect(border,0,window.width-border*2,border, mouse.x, mouse.y)) {
cursorShape = Qt.SizeVerCursor;
return;
}
if (ptInRect(window.width-border,0,border,border, mouse.x, mouse.y)) {
cursorShape = Qt.SizeBDiagCursor;
return;
}
if (ptInRect(window.width-border,border,border,window.height-border*2, mouse.x, mouse.y)) {
cursorShape = Qt.SizeHorCursor;
return;
}
if (ptInRect(window.width-border,window.height-border,border,border, mouse.x, mouse.y)) {
cursorShape = Qt.SizeFDiagCursor;
return;
}
if (ptInRect(border,window.height-border,window.width-border*2,border, mouse.x, mouse.y)) {
cursorShape = Qt.SizeVerCursor;
return;
}
if (ptInRect(0,window.height-border,border,border, mouse.x, mouse.y)) {
cursorShape = Qt.SizeBDiagCursor;
return;
}
if (ptInRect(0,border,border, window.height-border*2, mouse.x, mouse.y)) {
cursorShape = Qt.SizeHorCursor;
return;
}
cursorShape = Qt.ArrowCursor;
}
onExited: {
cursorShape = Qt.ArrowCursor;
}
function ptInRect(rcx,rcy,rcwidth,rcheight, x, y)
{
if ((rcx <= x && x <= (rcx + rcwidth)) &&
(rcy <= y && y <= (rcy + rcheight))) {
return true;
}
return false;
}
}