Warning, /plasma-bigscreen/peertube-voice-application/ui/+mediacenter/PeerTubePlayer.qml is written in an unsupported language. File is not indexed.
0001 import QtMultimedia 5.12
0002 import QtQuick.Layouts 1.4
0003 import QtQuick 2.9
0004 import QtQuick.Controls 2.12 as Controls
0005 import org.kde.kirigami 2.10 as Kirigami
0006 import QtGraphicalEffects 1.0
0007
0008 import Mycroft 1.0 as Mycroft
0009
0010 import "." as Local
0011
0012 Mycroft.Delegate {
0013 id: root
0014
0015 property var videoSource: sessionData.video_stream
0016 property var videoStatus: sessionData.video_status
0017 property var videoThumb: "https://" + sessionData.video_meta.channel.host + sessionData.video_meta.thumbnail_path
0018 property var videoTitle: sessionData.video_meta.name
0019 property var videoAuthor: sessionData.video_meta.channel.name
0020 property var videoViewCount: sessionData.video_meta.views
0021 property var videoPublishDate: sessionData.video_meta.published_at
0022 property bool busyIndicate: false
0023
0024 //The player is always fullscreen
0025 fillWidth: true
0026 background: Rectangle {
0027 color: "black"
0028 }
0029 leftPadding: 0
0030 topPadding: 0
0031 rightPadding: 0
0032 bottomPadding: 0
0033
0034 onEnabledChanged: syncStatusTimer.restart()
0035 onVideoSourceChanged: syncStatusTimer.restart()
0036 Component.onCompleted: {
0037 syncStatusTimer.restart()
0038 }
0039
0040 function changePage(){
0041 delay(3500, function() {
0042 parent.parent.parent.currentIndex++
0043 parent.parent.parent.currentItem.contentItem.forceActiveFocus()
0044 })
0045 }
0046
0047 onVideoThumbChanged: {
0048 if(videoThumb == ""){
0049 busyIndicatorPop.open()
0050 } else {
0051 busyIndicatorPop.close()
0052 }
0053 }
0054
0055 Keys.onDownPressed: {
0056 controlBarItem.opened = true
0057 controlBarItem.forceActiveFocus()
0058 }
0059
0060 onFocusChanged: {
0061 if(focus){
0062 video.forceActiveFocus();
0063 }
0064 }
0065
0066 Connections {
0067 target: window
0068 onVisibleChanged: {
0069 if(video.playbackState == MediaPlayer.PlayingState) {
0070 videoStatus = "stop"
0071 video.stop()
0072 }
0073 }
0074 }
0075
0076 function getViewCount(value){
0077 return value.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')
0078 }
0079
0080 function setPublishedDate(publishDate) {
0081 var date1 = new Date(publishDate).getTime();
0082 var date2 = new Date().getTime();
0083 console.log(date1)
0084 console.log(date2)
0085
0086 var msec = date2 - date1;
0087 var mins = Math.floor(msec / 60000);
0088 var hrs = Math.floor(mins / 60);
0089 var days = Math.floor(hrs / 24);
0090 var yrs = Math.floor(days / 365);
0091 mins = mins % 60;
0092 hrs = hrs % 24;
0093 days = days % 365;
0094 var result = ""
0095 if(days == 0 && hrs > 0) {
0096 result = hrs + " hours, " + mins + " minutes ago"
0097 } else if (days == 0 && hrs == 0) {
0098 result = mins + " minutes ago"
0099 } else {
0100 result = days + " days, " + hrs + " hours, " + mins + " minutes ago"
0101 }
0102 return result
0103 }
0104
0105 // Sometimes can't be restarted reliably immediately, put it in a timer
0106 Timer {
0107 id: syncStatusTimer
0108 interval: 0
0109 onTriggered: {
0110 if (enabled && videoStatus == "play") {
0111 video.play();
0112 } else if (videoStatus == "stop") {
0113 video.stop();
0114 } else {
0115 video.pause();
0116 }
0117 }
0118 }
0119
0120 Timer {
0121 id: delaytimer
0122 }
0123
0124 function delay(delayTime, cb) {
0125 delaytimer.interval = delayTime;
0126 delaytimer.repeat = false;
0127 delaytimer.triggered.connect(cb);
0128 delaytimer.start();
0129 }
0130
0131 controlBar: Local.SeekControl {
0132 id: seekControl
0133 anchors {
0134 left: parent.left
0135 right: parent.right
0136 bottom: parent.bottom
0137 }
0138 title: videoTitle
0139 videoControl: video
0140 duration: video.duration
0141 playPosition: video.position
0142 onSeekPositionChanged: video.seek(seekPosition);
0143 z: 1000
0144 }
0145
0146 Item {
0147 id: videoRoot
0148 anchors.fill: parent
0149
0150 Rectangle {
0151 id: infomationBar
0152 anchors.left: parent.left
0153 anchors.right: parent.right
0154 anchors.top: parent.top
0155 visible: false
0156 color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.6)
0157 implicitHeight: vidTitle.implicitHeight + Kirigami.Units.largeSpacing * 2
0158 z: 1001
0159
0160 onVisibleChanged: {
0161 delay(15000, function() {
0162 infomationBar.visible = false;
0163 })
0164 }
0165
0166 Kirigami.Heading {
0167 id: vidTitle
0168 level: 2
0169 height: Kirigami.Units.gridUnit * 2
0170 visible: true
0171 anchors.verticalCenter: parent.verticalCenter
0172 text: "Title: " + videoTitle
0173 z: 100
0174 }
0175 }
0176
0177 Image {
0178 id: thumbart
0179 anchors.fill: parent
0180 fillMode: Image.PreserveAspectFit
0181 source: root.videoThumb
0182 enabled: root.videoStatus == "stop" ? 1 : 0
0183 visible: root.videoStatus == "stop" ? 1 : 0
0184 }
0185
0186 Controls.Popup {
0187 id: busyIndicatorPop
0188 x: (parent.width - width) / 2
0189 y: (parent.height - height) / 2
0190
0191 background: Rectangle {
0192 anchors.fill: parent
0193 color: Qt.rgba(0, 0, 0, 0.5)
0194 }
0195 closePolicy: Controls.Popup.CloseOnEscape | Controls.Popup.CloseOnPressOutsideParent
0196
0197 RowLayout {
0198 anchors.centerIn: parent
0199
0200 Controls.BusyIndicator {
0201 running: busyIndicate
0202 }
0203
0204 Kirigami.Heading {
0205 level: 2
0206 text: "Searching Video"
0207 }
0208 }
0209
0210 onOpened: {
0211 busyIndicate = true
0212 }
0213
0214 onClosed: {
0215 busyIndicate = false
0216 }
0217 }
0218
0219 Video {
0220 id: video
0221 anchors.fill: parent
0222 focus: true
0223 autoLoad: true
0224 autoPlay: false
0225 Keys.onSpacePressed: video.playbackState == MediaPlayer.PlayingState ? video.pause() : video.play()
0226 KeyNavigation.up: closeButton
0227 source: videoSource
0228 readonly property string currentStatus: root.enabled ? root.videoStatus : "pause"
0229
0230 onCurrentStatusChanged: {print("OOO"+currentStatus)
0231 switch(currentStatus){
0232 case "stop":
0233 video.stop();
0234 break;
0235 case "pause":
0236 video.pause()
0237 break;
0238 case "play":
0239 video.play()
0240 busyIndicatorPop.close()
0241 delay(6000, function() {
0242 infomationBar.visible = false;
0243 })
0244 break;
0245 }
0246 }
0247
0248 Keys.onReturnPressed: {
0249 video.playbackState == MediaPlayer.PlayingState ? video.pause() : video.play()
0250 }
0251
0252 Keys.onDownPressed: {
0253 controlBarItem.opened = true
0254 controlBarItem.forceActiveFocus()
0255 }
0256
0257 MouseArea {
0258 anchors.fill: parent
0259 onClicked: {
0260 controlBarItem.opened = !controlBarItem.opened
0261 }
0262 }
0263
0264 onStatusChanged: {
0265 console.log(status)
0266 if(status == 7) {
0267 changePage()
0268 }
0269 }
0270 }
0271 }
0272 }