Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.4
- import QtQuick.Window 2.2
- import QtMultimedia 5.1
- import QtQml.StateMachine 1.0 as DSM
- import "qrc:/qml"
- import "qrc:/js/Core.js" as Core
- Window {
- id:root
- width: 720
- height: 720
- visible: true
- property int i: 0
- Component.onCompleted: console.debug("APP: qml completed")
- function olala()
- {
- console.log("enuda")
- Core.channel.up()
- }
- //
- // handle application suspend/focus
- //
- Connections {
- target: Qt.application
- onActiveChanged:{
- console.debug(Qt.application.active)
- console.debug(Qt.application.state)
- switch(Qt.application.state)
- {
- case Qt.ApplicationActive:
- //player.play()
- break
- case Qt.ApplicationInactive:
- player.pause()
- break
- }
- }
- }
- //
- // main video player
- //
- MediaPlayer {
- id: player
- source: Qt.resolvedUrl(Core.channel.get_current_url())
- autoPlay: false
- onError: console.error("APP: got error: " + error + " " + errorString)
- onPlaybackStateChanged: console.debug("APP: playback state log: " + playbackState)
- }
- Rectangle {
- id : main
- anchors.fill: parent
- focus: true
- color: "#000000"
- signal keyPressed(int key)
- Keys.onPressed: {
- event.accepted = true
- main.keyPressed(event.key)
- }
- VideoOutput {
- id: videoOutput
- source: player
- anchors.fill: parent
- fillMode: VideoOutput.Stretch
- }
- InfoBar {
- id:infoBar
- }
- DSM.StateMachine {
- id: stateMachine
- initialState: video
- running: true
- //
- // main video state
- //
- DSM.State {
- id: video
- onEntered: console.log("in video state")
- // change channel up - open infobar
- DSM.SignalTransition {
- targetState: bar
- signal: main.keyPressed
- guard: {
- if (key == Qt.Key_Up)
- {
- console.log("olaaaaaaaaaaa")
- Core.channel.up()
- return 1
- }
- switch (key)
- {
- case Qt.Key_Up:
- Core.channel.up()
- break
- case Qt.Key_Down:
- Core.channel.down()
- break
- default:
- return 0
- break
- }
- return 1
- }
- }
- }
- // infobar state
- DSM.State {
- id: bar
- onEntered: {
- console.log("main: infobar trigger")
- //player.source = Qt.resolvedUrl(Core.channel.get_current_url())
- infoBar.show(Core.channel.get_current_url())
- }
- }
- // menu state
- DSM.State {
- id: menu
- onEntered: {
- console.log("in menu")
- }
- }
- onFinished: console.log("machine done")
- }
- }//Rectangle
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement