xref: /OK3568_Linux_fs/app/forlinx/flapp/src/plugins/allwinner/music/musicplayer.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*!
2  * @file musicplayer.h
3  * Copyright (c) 2018
4  * @brief des
5  * detailed des
6  *
7  * @date 2018
8  * @author lee
9  */
10 #ifndef MUSICPLAYER_H
11 #define MUSICPLAYER_H
12 
13 #include <QWidget>
14 #include <QTimer>
15 #include <QThread>
16 #include <QPixmap>
17 #include "playlist.h"
18 #include "commonfunction.h"
19 #include "searchfiledialog.h"
20 #include "xmetadataretriever.h"
21 #include "audiosink.h"
22 
23 extern int autCb_func(int32_t msgType, void *user,void* data,int len);
24 
25 class MusicInfoThread : public QThread
26 {
27     Q_OBJECT
28 public:
29     explicit MusicInfoThread(QString path,QObject *parent = 0);
30     ~MusicInfoThread();
31 protected:
32     virtual void run();
33 signals:
34     void complete(QString,QString,QString,QPixmap);
35 private:
36     QString m_filepath;
37     QString m_albumName;
38     QString m_musicName;
39     QString m_singerName;
40     QPixmap m_poster;
41     CommonFunction* commonfunc;
42 };
43 
44 
45 namespace Ui {
46 class MusicPlayer;
47 }
48 
49 class AudioPlayer;
50 
51 class MusicPlayer : public QWidget
52 {
53     Q_OBJECT
54 
55 public:
56     explicit MusicPlayer(QWidget *parent = 0);
57     static MusicPlayer *Instance(QWidget *parent = 0);//create window by this interface
58     ~MusicPlayer();
59     void initAutPlayer();
60     void startPlay();
61     void stopPlay();
62     void updateDurationInfo(qint64 currentInfo);
63     void getMusicInfo(QString path);
64 
65 	static int autMusicCb_func(int msgType, void* user,void* data,int len);
66 
67 
68 private slots:
69     void on_preMusicButton_clicked();
70 
71     void on_playButton_clicked();
72 
73     void on_nextMusicButton_clicked();
74 
75     void on_searchButton_clicked();
76 
77     //void on_playListButton_clicked();
78 
79     void on_playOrderButton_clicked();
80 
81     void on_setttingButton_clicked();
82 
83     void on_pushButton_clicked();
84 
85     void on_notifyMusicPlayerToPlay(QList<QFileInfo>,int,int listType);
86 
87     void on_notifyMusicPlayerListChanged(QList<QFileInfo>,int listType);
88 
89     void timerUpdate();
90 
91     void onProgressSliderMoved(int);
92 
93     void onProgressSliderReleased();
94 
95     void setMusicInfo(QString,QString,QString,QPixmap);
96 
97     void on_notifyMusicPlayerAddFile(QString);
98 
99     void on_notifyMusicCancelSearch();
100 
101     void doMsgCmd(int msgType,void* user,void* data,int len);
102 
103 signals:
104     void msgSignal(int msgType,void* user,void* data,int len);
105 
106     void hidePlayList();
107 
108     void showPlayList();
109 
110     void hideSearchFileDialog();
111 
112     void showSearchFileDialog();
113 
114 protected:
115     void focusInEvent(QFocusEvent *e);
116 private:
117     Ui::MusicPlayer *ui;
118 
119     static MusicPlayer* self;//this  is for single instance
120 
121     CommonFunction* m_commonFunction;
122     //PlayList *m_pPlayList;
123     searchFileDialog *m_pSearchDialog;
124 
125     PLAYSTATE m_bPlayState;//ENUM of state
126     bool m_bMusicListOpen;//for open is 1;close is 0
127     bool m_bSearchDialogOpen;//for open is 1;close is 0
128 
129     QList<QFileInfo> m_playList;//this is the list now play
130     QList<QFileInfo> m_playList_udisk;//this is the list from udisk
131     QList<QFileInfo> m_playList_favorite;//this is the list from favorite file
132 
133     QString m_curMusicFilePath;
134     int m_curMusicFileCount;
135 
136     AudioPlayer* ap;
137     qint64 m_totalDuration;
138     qint64 m_curDuration;
139     QTimer* progressSliderTimer;
140 
141     QString m_albumName;
142     QString m_musicName;
143     QString m_singerName;
144     QPixmap m_poster;
145 
146     int m_curPlayOrderState;//0:sequences;1:random;2:single one
147     int m_nextPlayOrderState;
148     AudioSink::OutType m_outType = AudioSink::CODEC_OUT;
149 };
150 
151 static MusicPlayer *pStaticMusicPlayer=NULL;
152 
153 #include "iwidget.h"
154 CreateSimplePlugin(MusicWidget, "music", "music.json", new MusicPlayer)
155 
156 #endif // MUSICPLAYER_H
157