YouTube Video Player App
import Felgo 4.0
import QtQuick 2.0
import "pages"
import "common"
import "model"
App {
id: app
DataModel {
id: dataModel
dispatcher: logic
}
Logic {
id: logic
}
onIsOnlineChanged: Qt.callLater(logic.loadYouTubeData)
Connections {
target: dataModel
function onUserNameChanged() {
Qt.callLater(logic.loadYouTubeData)
}
function onMainPlaylistChanged() {
Qt.callLater(logic.loadMainPlaylistVideos)
}
}
Component.onCompleted: Qt.callLater(logic.loadYouTubeData)
onInitTheme: {
var darkBgColor = "#161614"
var darkTextColor = "white"
Theme.navigationBar.backgroundColor = darkBgColor
Theme.navigationBar.titleColor = darkTextColor
Theme.navigationBar.itemColor = darkTextColor
Theme.navigationTabBar.backgroundColor = darkBgColor
Theme.navigationTabBar.titleColor = darkTextColor
Theme.colors.secondaryBackgroundColor = "#EFEFF4"
Theme.colors.statusBarStyle = Theme.colors.statusBarStyleWhite
}
Navigation {
id: navigation
NavigationItem {
iconType: IconType.star
title: "Spotlight"
NavigationStack {
PlaylistPage {
title: "Spotlight"
playlist: dataModel.mainPlaylist
}
}
showItem: !!dataModel.mainPlaylistId
onShowItemChanged: Qt.callLater(() => {
if(showItem) navigation.currentIndex = 0
})
}
NavigationItem {
iconType: IconType.compass
title: "Browse"
NavigationStack {
ChannelPage {
id: channelPage
onSelected: playlist => channelPage.navigationStack.push(Qt.resolvedUrl("pages/PlaylistPage.qml"), { playlist: playlist })
}
}
}
NavigationItem {
iconType: IconType.gear
title: "Settings"
NavigationStack {
SettingsPage { }
}
}
}
property alias youTubePlayer: player
YouTubeWebPlayer {
id: player
visible: false
onVisibleChanged: {
if(visible) {
hideWhenScrolling = false
videoStartedTimer.start()
}
}
property bool hideWhenScrolling: false
Timer {
id: videoStartedTimer
interval: 1000
onTriggered: player.hideWhenScrolling = true
}
}
function getOfflineStatus() {
if(dataModel.requestsPending)
return "loading ..."
else if(!isOnline)
return "You are offline. Please go online to use the app."
else if (dataModel.channelId === "")
return "Please log-in with your user name."
else