Add AudioPlayer & EventAudio
This commit is contained in:
parent
f19d337817
commit
4c4d747ecf
1
TODO.md
1
TODO.md
@ -17,6 +17,7 @@
|
|||||||
- Video bug: when media is done playing, clicking on progress slider always
|
- Video bug: when media is done playing, clicking on progress slider always
|
||||||
bring back to the beginning no matter where
|
bring back to the beginning no matter where
|
||||||
- Video: missing buttons and small size problems
|
- Video: missing buttons and small size problems
|
||||||
|
- Audio: online playback is buggy, must download+play file
|
||||||
|
|
||||||
- Refactor EventContent
|
- Refactor EventContent
|
||||||
- No background/padding around medias
|
- No background/padding around medias
|
||||||
|
23
src/qml/Base/MediaPlayer/AudioPlayer.qml
Normal file
23
src/qml/Base/MediaPlayer/AudioPlayer.qml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import QtQuick 2.12
|
||||||
|
import QtAV 1.7
|
||||||
|
|
||||||
|
OSD {
|
||||||
|
id: osd
|
||||||
|
audioOnly: true
|
||||||
|
media: audioPlayer
|
||||||
|
|
||||||
|
implicitWidth: osd.width
|
||||||
|
implicitHeight: osd.height
|
||||||
|
|
||||||
|
|
||||||
|
property alias source: audioPlayer.source
|
||||||
|
|
||||||
|
|
||||||
|
MediaPlayer {
|
||||||
|
id: audioPlayer
|
||||||
|
autoLoad: window.settings.media.autoLoad
|
||||||
|
autoPlay: window.settings.media.autoPlay
|
||||||
|
volume: window.settings.media.defaultVolume / 100
|
||||||
|
muted: window.settings.media.startMuted
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,8 @@ HColumnLayout {
|
|||||||
|
|
||||||
transform: Scale {
|
transform: Scale {
|
||||||
id: osdScaleTransform
|
id: osdScaleTransform
|
||||||
yScale: osdHover.hovered ||
|
yScale: audioOnly ||
|
||||||
|
osdHover.hovered ||
|
||||||
media.playbackState !== MediaPlayer.PlayingState ||
|
media.playbackState !== MediaPlayer.PlayingState ||
|
||||||
osd.showup ?
|
osd.showup ?
|
||||||
1 : 0
|
1 : 0
|
||||||
@ -20,19 +21,23 @@ HColumnLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
property Item media: parent // QtAV.Video or QtAV.Audio
|
property QtObject media: parent // QtAV.Video or QtAV.MediaPlayer
|
||||||
|
property bool audioOnly: false
|
||||||
property bool showup: false
|
property bool showup: false
|
||||||
property bool enableFullScreen: false
|
|
||||||
property bool fullScreen: false
|
property bool fullScreen: false
|
||||||
|
|
||||||
|
property real savedAspectRatio: 16 / 9
|
||||||
property int savedDuration: 0
|
property int savedDuration: 0
|
||||||
|
readonly property real aspectRatio: media.sourceAspectRatio || 0
|
||||||
readonly property int duration: media.duration
|
readonly property int duration: media.duration
|
||||||
readonly property int boundPosition:
|
readonly property int boundPosition:
|
||||||
Math.min(media.position, savedDuration)
|
savedDuration ?
|
||||||
|
Math.min(media.position, savedDuration) : media.position
|
||||||
|
|
||||||
|
|
||||||
onShowupChanged: if (showup) osdHideTimer.restart()
|
onShowupChanged: if (showup) osdHideTimer.restart()
|
||||||
onDurationChanged: if (duration) savedDuration = duration
|
onDurationChanged: if (duration) savedDuration = duration
|
||||||
|
onAspectRatioChanged: if (aspectRatio) savedAspectRatio = aspectRatio
|
||||||
|
|
||||||
|
|
||||||
function togglePlay() {
|
function togglePlay() {
|
||||||
@ -42,7 +47,7 @@ HColumnLayout {
|
|||||||
|
|
||||||
function seekToPosition(pos) { // pos: 0.0 to 1.0
|
function seekToPosition(pos) { // pos: 0.0 to 1.0
|
||||||
if (media.playbackState === MediaPlayer.StoppedState) media.play()
|
if (media.playbackState === MediaPlayer.StoppedState) media.play()
|
||||||
if (media.seekable) media.seek(pos * savedDuration)
|
if (media.seekable) media.seek(pos * (savedDuration || boundPosition))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +77,9 @@ HColumnLayout {
|
|||||||
HToolTip {
|
HToolTip {
|
||||||
id: previewToolTip
|
id: previewToolTip
|
||||||
x: timeSlider.mouseArea.mouseX - width / 2
|
x: timeSlider.mouseArea.mouseX - width / 2
|
||||||
visible: preview.implicitWidth >=
|
visible: ! audioOnly &&
|
||||||
|
|
||||||
|
preview.implicitWidth >=
|
||||||
previewLabel.implicitWidth + previewLabel.padding &&
|
previewLabel.implicitWidth + previewLabel.padding &&
|
||||||
|
|
||||||
preview.implicitHeight >=
|
preview.implicitHeight >=
|
||||||
@ -101,7 +108,7 @@ HColumnLayout {
|
|||||||
media.height - osd.height - theme.spacing
|
media.height - osd.height - theme.spacing
|
||||||
)
|
)
|
||||||
implicitWidth: Math.min(
|
implicitWidth: Math.min(
|
||||||
implicitHeight * media.savedAspectRatio,
|
implicitHeight * savedAspectRatio,
|
||||||
media.width - theme.spacing,
|
media.width - theme.spacing,
|
||||||
)
|
)
|
||||||
file: media.source
|
file: media.source
|
||||||
@ -258,6 +265,7 @@ HColumnLayout {
|
|||||||
|
|
||||||
OSDButton {
|
OSDButton {
|
||||||
id: fullScreenButton
|
id: fullScreenButton
|
||||||
|
visible: ! audioOnly
|
||||||
icon.name: "player-fullscreen" + (fullScreen ? "-exit" : "")
|
icon.name: "player-fullscreen" + (fullScreen ? "-exit" : "")
|
||||||
toolTip.text: fullScreen ?
|
toolTip.text: fullScreen ?
|
||||||
qsTr("Exit fullscreen") : qsTr("Fullscreen")
|
qsTr("Exit fullscreen") : qsTr("Fullscreen")
|
||||||
|
@ -9,7 +9,7 @@ Video {
|
|||||||
volume: window.settings.media.defaultVolume / 100
|
volume: window.settings.media.defaultVolume / 100
|
||||||
muted: window.settings.media.startMuted
|
muted: window.settings.media.startMuted
|
||||||
implicitWidth: fullScreen ? window.width : 640
|
implicitWidth: fullScreen ? window.width : 640
|
||||||
implicitHeight: fullScreen ? window.height : (width / savedAspectRatio)
|
implicitHeight: fullScreen ? window.height : (width / osd.savedAspectRatio)
|
||||||
|
|
||||||
|
|
||||||
property bool hovered: false
|
property bool hovered: false
|
||||||
@ -18,11 +18,6 @@ Video {
|
|||||||
property int oldVisibility: Window.Windowed
|
property int oldVisibility: Window.Windowed
|
||||||
property QtObject oldParent: video.parent
|
property QtObject oldParent: video.parent
|
||||||
|
|
||||||
property real savedAspectRatio: 16 / 9
|
|
||||||
|
|
||||||
|
|
||||||
onSourceAspectRatioChanged:
|
|
||||||
if (sourceAspectRatio) savedAspectRatio = sourceAspectRatio
|
|
||||||
|
|
||||||
onFullScreenChanged: {
|
onFullScreenChanged: {
|
||||||
if (fullScreen) {
|
if (fullScreen) {
|
||||||
@ -69,6 +64,5 @@ Video {
|
|||||||
id: osd
|
id: osd
|
||||||
width: parent.width
|
width: parent.width
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
enableFullScreen: true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
src/qml/Chat/Timeline/EventAudio.qml
Normal file
20
src/qml/Chat/Timeline/EventAudio.qml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Layouts 1.12
|
||||||
|
import QtAV 1.7
|
||||||
|
import "../../Base"
|
||||||
|
import "../../Base/MediaPlayer"
|
||||||
|
import "../../utils.js" as Utils
|
||||||
|
|
||||||
|
AudioPlayer {
|
||||||
|
id: audio
|
||||||
|
width: Math.min(
|
||||||
|
mainColumn.width - eventContent.spacing * 2,
|
||||||
|
theme.chat.message.audioWidth,
|
||||||
|
)
|
||||||
|
|
||||||
|
HoverHandler {
|
||||||
|
onHoveredChanged:
|
||||||
|
eventDelegate.hoveredMediaTypeUrl =
|
||||||
|
hovered ? [EventDelegate.Media.Audio, audio.source] : []
|
||||||
|
}
|
||||||
|
}
|
@ -130,6 +130,12 @@ Column {
|
|||||||
contextMenu.media[0] === EventDelegate.Media.Image ?
|
contextMenu.media[0] === EventDelegate.Media.Image ?
|
||||||
qsTr("Copy image address") :
|
qsTr("Copy image address") :
|
||||||
|
|
||||||
|
contextMenu.media[0] === EventDelegate.Media.Video ?
|
||||||
|
qsTr("Copy video address") :
|
||||||
|
|
||||||
|
contextMenu.media[0] === EventDelegate.Media.Audio ?
|
||||||
|
qsTr("Copy audio address") :
|
||||||
|
|
||||||
qsTr("Copy media address")
|
qsTr("Copy media address")
|
||||||
|
|
||||||
visible: Boolean(text)
|
visible: Boolean(text)
|
||||||
|
@ -69,6 +69,10 @@ HLoader {
|
|||||||
var file = "EventVideo.qml"
|
var file = "EventVideo.qml"
|
||||||
var props = { source: mediaUrl }
|
var props = { source: mediaUrl }
|
||||||
|
|
||||||
|
} else if (type === EventDelegate.Media.Audio) {
|
||||||
|
var file = "EventAudio.qml"
|
||||||
|
var props = { source: mediaUrl }
|
||||||
|
|
||||||
} else { return }
|
} else { return }
|
||||||
|
|
||||||
loader.setSource(file, props)
|
loader.setSource(file, props)
|
||||||
|
@ -12,8 +12,7 @@ VideoPlayer {
|
|||||||
theme.chat.message.videoWidth,
|
theme.chat.message.videoWidth,
|
||||||
)
|
)
|
||||||
|
|
||||||
onHoveredChanged: {
|
onHoveredChanged:
|
||||||
eventDelegate.hoveredMediaTypeUrl =
|
eventDelegate.hoveredMediaTypeUrl =
|
||||||
hovered ? [EventDelegate.Media.Video, video.source] : []
|
hovered ? [EventDelegate.Media.Video, video.source] : []
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -334,6 +334,7 @@ chat:
|
|||||||
|
|
||||||
int thumbnailWidth: 256
|
int thumbnailWidth: 256
|
||||||
int videoWidth: 512
|
int videoWidth: 512
|
||||||
|
int audioWidth: 512
|
||||||
|
|
||||||
daybreak:
|
daybreak:
|
||||||
color background: colors.strongBackground
|
color background: colors.strongBackground
|
||||||
|
Loading…
Reference in New Issue
Block a user