Commit 305491db authored by kempe's avatar kempe

Added a loader to load the selected player layout

parent b8bdcf52
import QtQuick 2.0
import QtQuick 2.6
import Sailfish.Silica 1.0
import it.kempe.AudioPlayer 1.0
import "../js/Favorites.js" as FavoritesUtils
Item {
DockedPanel {
id: dockedAudioPlayerLoader
property Item player
// Layout
width: parent.width
dock: Dock.Bottom
Behavior on opacity { FadeAnimation { duration: 250 } }
Behavior on height { NumberAnimation { duration: 250 } }
Behavior on y { }
contentHeight: height
flickableDirection: Flickable.VerticalFlick
Loader {
id: dockedAudioPlayer
width: parent.width
onLoaded: {
dockedAudioPlayerLoader.player = dockedAudioPlayer.item
dockedAudioPlayerLoader.height = dockedAudioPlayer.item.height
}
}
Component.onCompleted: {
var sourceBaseName = settings.value("playerLayout") ? settings.value("playerLayout") : "DockedAudioPlayer"
dockedAudioPlayer.source = Qt.resolvedUrl(sourceBaseName + ".qml")
}
function playerLayoutUpdated() {
dockedAudioPlayer.source = Qt.resolvedUrl(settings.value("playerLayout") + ".qml")
}
// Helper functions
function play(station) {
if (!expanded)
open = true
window.stationData = JSON.parse(JSON.stringify(station));
AudioPlayer.loadUrl(window.stationData.url)
}
function playNext() {
var nextStation = FavoritesUtils.getNextFavorite(window.stationData);
console.debug("Playing next favorite", JSON.stringify(nextStation));
play(nextStation);
}
function playPrev() {
var prevStation = FavoritesUtils.getPrevFavorite(window.stationData);
console.debug("Playing prev favorite", JSON.stringify(prevStation));
play(prevStation);
}
}
......@@ -11,8 +11,9 @@ ApplicationWindow
{
id: window
property bool loading: false
property string stationIcon: ""
property bool loading
property string stationIcon
property var stationData
allowedOrientations: Orientation.All
bottomMargin: player.visibleSize
......@@ -27,7 +28,7 @@ ApplicationWindow
id: favorites
}
Audio.DockerAudioPlayerSmal {
Audio.DockedAudioPlayerLoader {
id: player
}
......@@ -40,6 +41,10 @@ ApplicationWindow
RadioAPI {
id: radioAPI
}
function playerLayoutUpdated() {
player.playerLayoutUpdated()
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment