-
Notifications
You must be signed in to change notification settings - Fork 2
/
player.h
executable file
·148 lines (125 loc) · 5.24 KB
/
player.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/***************************************************************************
* Project created by QtCreator 2018-06-01T17:15:24 *
* *
* goldfinch Copyright (C) 2014 AbouZakaria <yahiaui@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef PLAYER_H
#define PLAYER_H
#include "playercontrols.h"
#include "actions.h"
#include "widgetplaylist.h"
#include "player_adaptor.h"
#include <QWidget>
#include <QMediaPlayer>
#include <QMediaPlaylist>
#include <QListView>
QT_BEGIN_NAMESPACE
class QAbstractItemView;
class QMediaPlayer;
class QModelIndex;
QT_END_NAMESPACE
class PlaylistModel;
class Player : public QWidget
{
Q_OBJECT
public:
explicit Player(QListView *playlist,QWidget *parent = nullptr);
~Player();
void addToPlaylist(QList<QVariantMap> &files);
void addToPlaylist( QList<QUrl> &urls);
void playLast();
void setMiniPlayer(bool mini){mControls->togglePreview(mini);}
signals:
void statuInfoChanged(QString );
void playBackChanged(QString,int=0 );
// void iconsChanged();
void imageChanged(QImage);
void titleChanged(QString,QString);
void infoChanged(QString);
void durationChanged(qint64 duration);
void positionChanged(qint64 progress);
void appCloseChanged();
void appRaiseChanged();
void appHideChanged();
void apptoggleHideChanged();
// void updateSong(QVariantMap,QString);
// void propertiesChanged(QString,QVariantMap,QStringList);
public slots:
void setVolumeUp(){mPlayer->setVolume(mPlayer->volume()+5);}
void setVolumeDown(){mPlayer->setVolume(mPlayer->volume()-5);}
void setVolumeMuteUnmute(bool mute){mPlayer->setMuted(mute);}
// dbus
void appHide() {emit appHideChanged();}
void appQuit() {emit appCloseChanged();}
void showRaise(){emit appRaiseChanged();}
void toggleHide(){emit apptoggleHideChanged();}
void play() { mPlayer->play(); }
void pause(){ mPlayer->pause(); }
void stop() { mPlayer->stop(); }
void next() { mPlaylist->next(); }
void previous();
void playPause();
void setSeek(int seconds);
void setSeekPlus();
void setSeekMinus();
void seek(qlonglong Offset);
qint64 position(){return mPlayer->position()*1000; }
bool canPlay() { if(!mPlayer->isAvailable()){return false;} else { return true;} }
bool canPause() { if(!mPlayer->isAvailable()) { return false; } else { return true;} }
bool canGoNext(){ if(mPlaylist->currentIndex()<(mPlaylist->mediaCount()-1)) { return true; } else {return false;} }
bool canGoPrevious(){ if(mPlaylist->currentIndex()>0) { return true; } else { return false; } }
bool canSeek(){return mPlayer->isSeekable();}
QVariantMap metadata(){return mMetaDataMap;}
QString playbackStatus(){return mPlaybackStatus;}
//--
void rmovePlaylistItem();
void moveMedia(int from,int to);
void cleanList();
void setPlaybackMode(int value);
void setFile(const QString &file);
void saveList();
private slots:
void metaDataChanged();
void jump(const QModelIndex &index);
void playlistPositionChanged(int);
void statusChanged(QMediaPlayer::MediaStatus status);
void stateChanged(QMediaPlayer::State state);
void bufferingProgress(int progress);
void displayErrorMessage();
void setseekold();
void openSavedList();
void setduration(qint64 duration);
private:
void setTrackInfo (const QString &info);
void setStatusInfo (const QString &info);
void handleCursor (QMediaPlayer::MediaStatus status);
void setCovertImage(QImage img, QString album);
PlayerAdaptor *mPlayerAdaptor;
QMediaPlayer *mPlayer = nullptr;
QMediaPlaylist *mPlaylist = nullptr;
PlayerControls *mControls;
PlaylistModel *mPlaylistModel = nullptr;
QListView *mPlaylistView ;
QVariantMap mMetaDataMap;
QString mTrackInfo;
QString mStatusInfo;
QString mPlaybackStatus;
qint64 mOldPos=0;
// FreeDesktopAdaptor *mFreeDesktopAdaptor;
};
#endif // PLAYER_H