Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.0
- import QtMultimedia 5.0
- import './common/' as Common
- import './common/js/subsonic.js' as Subsonic
- Rectangle {
- id: root
- width: 360
- height: 360
- color: 'black'
- Common.ServerListModel {
- id: serverListModel
- }
- Common.Ping {
- id: ping
- onPongChanged: if (pong) playlistsModel.load()
- }
- Common.PlaylistsModel {
- id: playlistsModel
- onLoadingChanged: if (!loading && count > 0) {
- playlistsView.currentIndex = 0
- }
- }
- Common.PlaylistModel {
- id: playlistModel
- property string playlistsId: playlistsView.currentIndex > -1 ? playlistsModel.get(playlistsView.currentIndex).id : ''
- onPlaylistsIdChanged: {
- _id = playlistsId
- load()
- }
- }
- Row {
- ListView {
- id: playlistsView
- width: root.width / 3
- height: root.height
- spacing: 5
- model: playlistsModel
- delegate: Rectangle {
- id: playlistsDelegate
- width: ListView.view.width
- height: 30
- radius: 5
- color: 'transparent'
- border.color: 'white'
- border.width: 1
- smooth: true
- Text {
- anchors.fill: parent
- anchors.margins: 5
- verticalAlignment: Text.AlignVCenter
- color: 'white'
- text: model.name
- }
- }
- highlight: Rectangle {
- color: 'white'
- opacity: playlistsView.focus ? 0.50 : 0.25
- }
- focus: true
- Keys.onUpPressed: playlistsView.decrementCurrentIndex()
- Keys.onDownPressed: playlistsView.incrementCurrentIndex()
- Keys.onRightPressed: playlistView.focus = true
- Keys.onEscapePressed: Qt.quit()
- }
- ListView {
- id: playlistView
- width: root.width / 3
- height: root.height
- spacing: 5
- model: playlistModel
- delegate: Rectangle {
- id: playlistDelegate
- width: ListView.view.width
- height: 30
- radius: 5
- color: 'transparent'
- border.color: 'white'
- border.width: 1
- smooth: true
- Text {
- anchors.fill: parent
- anchors.margins: 5
- verticalAlignment: Text.AlignVCenter
- color: 'white'
- text: model.title
- }
- }
- highlight: Rectangle {
- color: 'white'
- opacity: playlistView.focus ? 0.50 : 0.25
- }
- focus: true
- Keys.onUpPressed: playlistView.decrementCurrentIndex()
- Keys.onDownPressed: playlistView.incrementCurrentIndex()
- Keys.onLeftPressed: playlistsView.focus = true
- Keys.onEscapePressed: Qt.quit()
- Keys.onReturnPressed: {
- console.debug(audio.playbackState)
- switch (audio.playbackState) {
- case Audio.PlayingState:
- audio.pause()
- break
- case Audio.StoppedState:
- audio.source = Subsonic.getStreamSongUrl(playlistModel.get(playlistView.currentIndex).id, "128", "mp3", 0)
- case Audio.PausedState:
- audio.play()
- break
- }
- }
- }
- }
- Audio {
- id: audio
- onStatusChanged: {
- switch(status) {
- case Audio.EndOfMedia:
- console.debug("Audio Status: End Of Media");
- break;
- case Audio.NoMedia:
- console.debug("Audio Status: No Media");
- break;
- case Audio.Loading:
- console.debug("Audio Status: Loading");
- break;
- case Audio.Loaded:
- console.debug("Audio Status: Loaded");
- break;
- case Audio.Buffering:
- console.debug("Audio Status: Buffering");
- break;
- case Audio.Stalled:
- console.debug("Audio Status: Stalled");
- break;
- case Audio.Buffered:
- console.debug("Audio Status: Stalled");
- break;
- case Audio.InvalidMedia:
- console.debug("Audio Status: InvalidMedia");
- break;
- case Audio.UnknownStatus:
- console.debug("Audio Status: Stalled");
- break;
- default:
- break;
- }
- }
- }
- Text {
- anchors.centerIn: parent
- color: 'white'
- text: playlistModel.loading
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- ping.ping()
- }
- }
- Component.onCompleted: {
- Subsonic.currentServer = serverListModel.get(0)
- ping.ping()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement