Player.qml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import QtQuick 2.15
  2. import DMusic 1.0
  3. import "components"
  4. Rectangle {
  5. id: root
  6. color: Style.panel.background
  7. property alias player: _audio_player
  8. property alias track: _track
  9. function toglleLiked() {
  10. _audio_player.currentTrack.setLiked(!_audio_player.currentTrack.liked)
  11. }
  12. function next() {
  13. _audio_player.next()
  14. }
  15. function prev() {
  16. _audio_player.prev()
  17. }
  18. PlayerControls {
  19. id: _controls
  20. anchors.horizontalCenter: root.horizontalCenter
  21. y: 21
  22. playing: _audio_player.state === AudioPlayer.PlayingState
  23. loopMode: _audio_player.loopMode
  24. nextMode: _audio_player.nextMode
  25. onPause_or_play: _audio_player.pause_or_play()
  26. onNext: _audio_player.next()
  27. onPrev: _audio_player.prev()
  28. onChangeLoopMode: _audio_player.loopMode = mode
  29. onChangeNextMode: _audio_player.nextMode = mode
  30. }
  31. PlayerLine {
  32. id: _playerLine
  33. anchors.horizontalCenter: root.horizontalCenter
  34. y: 48
  35. width: root.width / 2.7
  36. progress: _audio_player.progress
  37. onSeek: _audio_player.progress = progress
  38. onAppendMs: _audio_player.progress_ms += delta * 1000
  39. positionText: _audio_player.formatProgress
  40. durationText: _audio_player.formatDuration
  41. }
  42. AudioPlayer {
  43. id: _audio_player
  44. Component.onCompleted: {
  45. volume = Config.volume
  46. nextMode = Config.nextMode
  47. loopMode = Config.loopMode
  48. }
  49. onVolumeChanged: Config.volume = volume
  50. onNextModeChanged: Config.nextMode = nextMode
  51. onLoopModeChanged: Config.loopMode = loopMode
  52. }
  53. RemoteMediaController {
  54. target: _audio_player
  55. }
  56. Row {
  57. spacing: 20
  58. anchors.right: root.right
  59. anchors.verticalCenter: root.verticalCenter
  60. anchors.rightMargin: 24
  61. IconButton {
  62. width: 32
  63. height: 32
  64. src: "qrc:/resources/player/debug.svg"
  65. onClicked: _dpc.opened = !_dpc.opened
  66. PopupController {
  67. id: _dpc
  68. target: _debug
  69. }
  70. DebugPanel {
  71. id: _debug
  72. anchors.right: parent.right
  73. anchors.bottom: parent.top
  74. anchors.rightMargin: -58
  75. anchors.bottomMargin: 30 - _dpc.shift
  76. triangleOffset: -73
  77. triangleCenter: _debug.right
  78. player: root
  79. }
  80. }
  81. VolumeControl {}
  82. }
  83. PlayerTrack {
  84. id: _track
  85. x: 8
  86. anchors.verticalCenter: root.verticalCenter
  87. width: root.width / 2 - _playerLine.leftWidth - 14 - x
  88. height: root.height
  89. icon: _audio_player.currentTrack.cover
  90. title: _audio_player.currentTrack.title
  91. artists: _audio_player.currentTrack.artistsStr
  92. comment: _audio_player.currentTrack.comment
  93. trackId: _audio_player.currentTrack.id
  94. liked: _audio_player.currentTrack.liked
  95. isYandex: _audio_player.currentTrack.isYandex
  96. onToggleLiked: _audio_player.currentTrack.setLiked(liked)
  97. }
  98. }