Commit 483cbe63 authored by kempe's avatar kempe

Refactored audioPlayer to work with the loader

parent 6e32bf43
......@@ -7,15 +7,9 @@ import "../js/Favorites.js" as FavoritesUtils
DockedAudioPlayerForm {
id: player
// Layout
width: parent.width
dock: Dock.Bottom
Behavior on opacity { FadeAnimation {duration: 300}}
Behavior on y { }
// Property assignment
isPlaying: AudioPlayer.isPlaying
isFavorite: FavoritesUtils.isFavorite(window.stationData);
currentTrack: AudioPlayer.title
bufferProgress: AudioPlayer.bufferProgress
showProgressBar: AudioPlayer.isLoading || AudioPlayer.isBuffering
......@@ -26,7 +20,7 @@ DockedAudioPlayerForm {
// Triggers
opener.onClicked: console.debug("Show fullscreen player controls")
buttonPlay.onClicked: AudioPlayer.togglePlayback();
buttonStar.onClicked: player.isFavorite = FavoritesUtils.toogleFavorite(stationData)
buttonStar.onClicked: player.isFavorite = FavoritesUtils.toogleFavorite(window.stationData)
buttonPrevious.onClicked: playPrev()
buttonNext.onClicked: playNext()
cancelSleepTimer.onClicked: sleepTimer.stopTimer()
......@@ -50,29 +44,4 @@ DockedAudioPlayerForm {
onActivateTimer: sleepTimer.startTimer(sec)
}
}
// Helper functions
function play(station) {
if(!player.expanded)
player.open = true;
player.stationData = JSON.parse(JSON.stringify(station));
player.isFavorite = FavoritesUtils.isFavorite(stationData);
window.stationIcon = stationData.stationLogo;
AudioPlayer.loadUrl(stationData.url)
}
function playNext() {
var nextStation = FavoritesUtils.getNextFavorite(stationData);
console.debug("Playing next favorite", JSON.stringify(nextStation));
play(nextStation);
}
function playPrev() {
var prevStation = FavoritesUtils.getPrevFavorite(stationData);
console.debug("Playing prev favorite", JSON.stringify(prevStation));
play(prevStation);
}
}
import QtQuick 2.6
import Sailfish.Silica 1.0
import "../"
import "../sleeptimer"
DockedPanel {
Item {
id: player
property bool isPlaying
property bool isFavorite
property var stationData
property string currentTrack
property int bufferProgress
property bool showProgressBar
......@@ -21,16 +19,12 @@ DockedPanel {
property alias buttonPrevious: controls.buttonPrevious
property alias buttonNext: controls.buttonNext
property alias playerMenu: playerMenu
property alias cancelSleepTimer: cancelSleepTimer
property alias setSleepTimer: setSleepTimer
property real hightPadding: Theme.paddingMedium
height: Theme.itemSizeExtraLarge + (hightPadding * 2)
contentHeight: height
flickableDirection: Flickable.VerticalFlick
MouseArea {
id: opener
......@@ -51,7 +45,7 @@ DockedPanel {
height: parent.height
width: parent.height
source: window.stationIcon
source: window.stationData ? window.stationData.stationLogo : ""
smooth: true
cache: true
......@@ -67,7 +61,7 @@ DockedPanel {
height: parent.height
StationInfoLabel {
name: stationData ? stationData.name : ""
name: window.stationData ? window.stationData.name : ""
track: currentTrack
width: parent.width
height: parent.height / 2
......
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