Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. import QtQuick 2.4
  2. import QtQuick.Window 2.2
  3. import QtMultimedia 5.1
  4. import QtQml.StateMachine 1.0 as DSM
  5.  
  6. import "qrc:/qml"
  7. import "qrc:/js/Core.js" as Core
  8.  
  9.  
  10. Window {
  11. id:root
  12. width: 720
  13. height: 720
  14. visible: true
  15. property int i: 0
  16.  
  17. Component.onCompleted: console.debug("APP: qml completed")
  18.  
  19. function olala()
  20. {
  21. console.log("enuda")
  22. Core.channel.up()
  23. }
  24.  
  25. //
  26. // handle application suspend/focus
  27. //
  28.  
  29. Connections {
  30. target: Qt.application
  31. onActiveChanged:{
  32. console.debug(Qt.application.active)
  33. console.debug(Qt.application.state)
  34. switch(Qt.application.state)
  35. {
  36. case Qt.ApplicationActive:
  37. //player.play()
  38. break
  39.  
  40. case Qt.ApplicationInactive:
  41. player.pause()
  42. break
  43. }
  44. }
  45. }
  46.  
  47. //
  48. // main video player
  49. //
  50.  
  51. MediaPlayer {
  52. id: player
  53. source: Qt.resolvedUrl(Core.channel.get_current_url())
  54. autoPlay: false
  55.  
  56. onError: console.error("APP: got error: " + error + " " + errorString)
  57. onPlaybackStateChanged: console.debug("APP: playback state log: " + playbackState)
  58. }
  59.  
  60. Rectangle {
  61. id : main
  62. anchors.fill: parent
  63. focus: true
  64. color: "#000000"
  65. signal keyPressed(int key)
  66.  
  67. Keys.onPressed: {
  68. event.accepted = true
  69. main.keyPressed(event.key)
  70. }
  71.  
  72. VideoOutput {
  73. id: videoOutput
  74. source: player
  75. anchors.fill: parent
  76. fillMode: VideoOutput.Stretch
  77. }
  78.  
  79. InfoBar {
  80. id:infoBar
  81. }
  82.  
  83. DSM.StateMachine {
  84. id: stateMachine
  85. initialState: video
  86. running: true
  87.  
  88. //
  89. // main video state
  90. //
  91.  
  92. DSM.State {
  93. id: video
  94. onEntered: console.log("in video state")
  95.  
  96. // change channel up - open infobar
  97. DSM.SignalTransition {
  98. targetState: bar
  99. signal: main.keyPressed
  100. guard: {
  101. if (key == Qt.Key_Up)
  102. {
  103. console.log("olaaaaaaaaaaa")
  104. Core.channel.up()
  105. return 1
  106. }
  107.  
  108. switch (key)
  109. {
  110. case Qt.Key_Up:
  111. Core.channel.up()
  112. break
  113.  
  114. case Qt.Key_Down:
  115. Core.channel.down()
  116. break
  117.  
  118. default:
  119. return 0
  120. break
  121. }
  122.  
  123. return 1
  124. }
  125. }
  126. }
  127.  
  128. // infobar state
  129. DSM.State {
  130. id: bar
  131. onEntered: {
  132. console.log("main: infobar trigger")
  133. //player.source = Qt.resolvedUrl(Core.channel.get_current_url())
  134. infoBar.show(Core.channel.get_current_url())
  135. }
  136. }
  137.  
  138. // menu state
  139. DSM.State {
  140. id: menu
  141. onEntered: {
  142. console.log("in menu")
  143. }
  144. }
  145.  
  146. onFinished: console.log("machine done")
  147. }
  148.  
  149. }//Rectangle
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement