Commit d18c572b authored by Camilo higuita's avatar Camilo higuita

push more fixes for new player backend

parent af89e3a5
......@@ -62,7 +62,7 @@ Maui.ApplicationWindow
property int currentTrackIndex: 0
property int prevTrackIndex: 0
property string currentArtwork: !mainlistEmpty ? mainPlaylist.list.model.get(0).artwork : ""
property string currentArtwork: !mainlistEmpty ? mainPlaylist.list.get(0).artwork : ""
property bool currentBabe: currentTrack.babe == "0" ? false : true
property string durationTimeLabel: player.duration
property string progressTimeLabel: player.transformTime(player.position/1000)
......@@ -169,13 +169,16 @@ Maui.ApplicationWindow
id: player
volume: 100
onFinishedChanged: if (!mainlistEmpty)
{
if (currentTrack.url)
bae.playedTrack(currentTrack.url)
// onTestChanged: console.log("new value:", player.test)
onPositionChanged: console.log("new value:", player.position)
Player.nextTrack()
}
// onFinishedChanged: if (!mainlistEmpty)
// {
// if (currentTrack.url)
// bae.playedTrack(currentTrack.url)
// Player.nextTrack()
// }
}
BabeNotify
......@@ -596,10 +599,7 @@ Maui.ApplicationWindow
iconName: isPlaying ? "media-playback-pause" : "media-playback-start"
onClicked:
{
if (isPlaying)
Player.pauseTrack()
else
Player.resumeTrack()
player.playing = !player.playing
}
},
......
......@@ -23,7 +23,7 @@ bool Player::play()
if(this->url.isEmpty()) return false;
if(!updater->isActive())
this->updater->start(150);
this->updater->start(500);
this->player->play();
......@@ -102,6 +102,9 @@ void Player::setUrl(const QString &value)
this->url = value;
emit this->urlChanged();
// this->position = 0;
// emit this->positionChanged();
auto media = QMediaContent(QUrl::fromLocalFile(this->url));
this->player->setMedia(media);
this->emitState();
......@@ -134,13 +137,11 @@ int Player::getDuration() const
void Player::setPosition(const int &value)
{
if(value == this->position)
return;
this->position = value;
this->positionChanged();
// this->position = value;
// this->player->setPosition( this->player->duration() / 1000 * position);
// this->emitState();
// this->positionChanged();
this->player->setPosition(position);
this->emitState();
}
int Player::getPosition() const
......@@ -155,15 +156,13 @@ Player::STATE Player::getState() const
void Player::setPlaying(const bool &value)
{
if(value == this->playing)
return;
this->playing = value;
if(this->playing)
this->play();
else this->pause();
emit this->playingChanged();
this->emitState();
}
......@@ -177,6 +176,19 @@ bool Player::getFinished()
return this->finished;
}
void Player::setPos(const int &value)
{
this->position = value;
this->player->setPosition( this->player->duration() / 1000 * position);
this->emitState();
this->positionChanged();
}
int Player::getPos() const
{
return this->pos;
}
void Player::playBuffer()
{
buffer->setData(array);
......@@ -192,8 +204,12 @@ void Player::update()
{
if(this->player->isAvailable())
{
this->position = static_cast<int>(static_cast<double>(this->player->position())/this->player->duration()*1000);
emit this->positionChanged();
this->pos = static_cast<int>(static_cast<double>(this->player->position())/this->player->duration()*1000);;
emit this->posChanged();
qDebug() << "Setting value:" << this->position;
}
if(this->player->state() == QMediaPlayer::StoppedState && this->updater->isActive())
......
......@@ -16,6 +16,7 @@ class Player : public QObject
Q_PROPERTY(int duration READ getDuration NOTIFY durationChanged)
Q_PROPERTY(bool playing READ getPlaying WRITE setPlaying NOTIFY playingChanged)
Q_PROPERTY(bool finished READ getFinished NOTIFY finishedChanged)
Q_PROPERTY(int pos READ getPos WRITE setPos NOTIFY posChanged)
public:
......@@ -49,6 +50,9 @@ public:
bool getFinished();
int getPos() const;
void setPos(const int &value);
private:
QMediaPlayer *player;
QTimer *updater;
......@@ -69,6 +73,8 @@ private:
void emitState();
int pos = 0;
signals:
void durationChanged();
void urlChanged();
......@@ -78,6 +84,8 @@ signals:
void playingChanged();
void finishedChanged();
void posChanged();
public slots:
QString transformTime(const int &pos);
void playRemote(const QString &url);
......
......@@ -3,9 +3,9 @@ Qt.include("Icons.js")
function playTrack(index)
{
if((index < mainPlaylist.list.count) && (mainPlaylist.list.count > 0) && (index > -1))
if((index < mainPlaylist.listView.count) && (mainPlaylist.listView.count > 0) && (index > -1))
{
currentTrack = mainPlaylist.list.model.get(index)
currentTrack = mainPlaylist.list.get(index)
if(typeof(currentTrack) === "undefined") return
......@@ -76,8 +76,8 @@ function pauseTrack()
function resumeTrack()
{
// if(!player.play() && !mainlistEmpty)
// playAt(0)
if(!player.play() && !mainlistEmpty)
playAt(0)
}
function nextTrack()
......@@ -88,9 +88,9 @@ function nextTrack()
if(isShuffle && onQueue === 0)
next = shuffle()
else
next = currentTrackIndex+1 >= mainPlaylist.list.count? 0 : currentTrackIndex+1
next = currentTrackIndex+1 >= mainPlaylist.listView.count? 0 : currentTrackIndex+1
prevTrackIndex = mainPlaylist.list.currentIndex
prevTrackIndex = mainPlaylist.listView.currentIndex
playAt(next)
if(onQueue > 0)
......@@ -105,8 +105,8 @@ function previousTrack()
{
if(!mainlistEmpty>0)
{
var previous = previous = currentTrackIndex-1 >= 0 ? mainPlaylist.list.currentIndex-1 : currentTrackIndex-1
prevTrackIndex = mainPlaylist.list.currentIndex
var previous = previous = currentTrackIndex-1 >= 0 ? mainPlaylist.listView.currentIndex-1 : currentTrackIndex-1
prevTrackIndex = mainPlaylist.listView.currentIndex
playAt(previous)
}
}
......@@ -119,10 +119,10 @@ function shuffle()
function playAt(index)
{
if((index < mainPlaylist.list.count) && (mainPlaylist.list.count > 0) && (index > -1))
if((index < mainPlaylist.listView.count) && (mainPlaylist.listView.count > 0) && (index > -1))
{
currentTrackIndex = index
mainPlaylist.list.currentIndex = currentTrackIndex
mainPlaylist.listView.currentIndex = currentTrackIndex
mainPlaylist.albumsRoll.positionAlbum(currentTrackIndex)
playTrack(currentTrackIndex)
}
......@@ -133,7 +133,7 @@ function quickPlay(track)
// root.pageStack.currentIndex = 0
appendTrack(track)
playAt(mainPlaylist.list.count-1)
mainPlaylist.list.positionViewAtEnd()
mainPlaylist.listView.positionViewAtEnd()
mainPlaylist.albumsRoll.positionViewAtEnd()
}
......@@ -176,7 +176,7 @@ function addTrack(track)
if(track)
{
appendTrack(track)
mainPlaylist.list.positionViewAtEnd()
mainPlaylist.listView.positionViewAtEnd()
}
}
......@@ -187,7 +187,7 @@ function appendAll(tracks)
for(var i in tracks)
appendTrack(tracks[i])
mainPlaylist.list.positionViewAtEnd()
mainPlaylist.listView.positionViewAtEnd()
}
}
......@@ -198,11 +198,11 @@ function savePlaylist()
n = n > 15 ? 15 : n
for(var i=0 ; i < n; i++)
{
var url = mainPlaylist.list.model.get(i).url
var url = mainPlaylist.list.get(i).url
list.push(url)
}
bae.savePlaylist(list)
bae.savePlaylistPos(mainPlaylist.list.currentIndex)
bae.savePlaylistPos(mainPlaylist.listView.currentIndex)
}
function clearOutPlaylist()
......@@ -215,13 +215,13 @@ function cleanPlaylist()
{
var urls = []
for(var i = 0; i < mainPlaylist.list.count; i++)
for(var i = 0; i < mainPlaylist.listView.count; i++)
{
var url = mainPlaylist.list.model.get(i).url
var url = mainPlaylist.list.get(i).url
if(urls.indexOf(url)<0)
urls.push(url)
else mainPlaylist.list.model.remove(i)
else mainPlaylist.list.remove(i)
}
}
......@@ -242,7 +242,7 @@ function playAll(tracks)
// root.mainPlaylist.list.currentIndex = 0
// playTrack(root.mainPlaylist.list.model.get(0))
mainPlaylist.list.positionViewAtBeginning()
mainPlaylist.listView.positionViewAtBeginning()
playAt(0)
}
}
......
......@@ -22,7 +22,8 @@ BabeList
property alias list : _tracksList
property alias listModel : _tracksModel
property alias listView : babeTableRoot.listView
property bool trackNumberVisible
property bool quickPlayVisible : true
property bool coverArtVisible : false
......@@ -154,7 +155,7 @@ BabeList
{
if(paths.length > 1)
H.moodIt(paths, color)
H.moodIt(paths, color)
else
list.color(listView.currentIndex, color);
......
......@@ -18,9 +18,9 @@ SwipeDelegate
{
if(coverArt)
{
if(listModel.get(index-1))
if(list.get(index-1))
{
if(listModel.get(index-1).album === album && listModel.get(index-1).artist === artist) true
if(list.get(index-1).album === album && list.get(index-1).artist === artist) true
else false
}else false
}else false
......
......@@ -15,7 +15,7 @@ ListView
highlightFollowsCurrentItem: true
highlightMoveDuration: 0
snapMode: ListView.SnapOneItem
model: mainPlaylist.list.model
model: mainPlaylist.listModel
onMovementEnded:
{
......
......@@ -22,6 +22,8 @@ Maui.Page
property alias albumsRoll : albumsRoll
property alias cover : cover
property alias list : table.list
property alias listModel: table.listModel
property alias listView : table.listView
property alias table: table
property alias infoView : infoView
property alias progressBar: progressBar
......@@ -379,13 +381,15 @@ Maui.Page
padding: 0
from: 0
to: 1000
value: player.position
value: player.pos
spacing: 0
focus: true
onMoved:
{
player.position = player.duration / 1000 * value
}
// onMoved:
// {
// player.position = value
// }
// onValueChanged: console.log("new value:", value)
background: Rectangle
{
......
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