xref: /OK3568_Linux_fs/app/forlinx/flapp/src/plugins/allwinner/MediaUI/player/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     static MusicPlayer *Instance(QWidget *parent = 0);//create window by this interface
57     ~MusicPlayer();
58     void initAutPlayer();
59     void startPlay();
60     void stopPlay();
61     void updateDurationInfo(qint64 currentInfo);
62     void getMusicInfo(QString path);
63 
64 	static int autMusicCb_func(int msgType, void* user,void* data,int len);
65 
66 
67 private slots:
68 	void on_return_btn_clicked();
69 
70     void on_preMusicButton_clicked();
71 
72     void on_playButton_clicked();
73 
74     void on_nextMusicButton_clicked();
75 
76     void on_searchButton_clicked();
77 
78     //void on_playListButton_clicked();
79 
80     void on_playOrderButton_clicked();
81 
82     void on_setttingButton_clicked();
83 
84     void on_pushButton_clicked();
85 
86     void on_notifyMusicPlayerToPlay(QList<QFileInfo>,int,int listType);
87 
88     void on_notifyMusicPlayerListChanged(QList<QFileInfo>,int listType);
89 
90     void timerUpdate();
91 
92     void onProgressSliderMoved(int);
93 
94     void onProgressSliderReleased();
95 
96     void setMusicInfo(QString,QString,QString,QPixmap);
97 
98     void on_notifyMusicPlayerAddFile(QString);
99 
100     void on_notifyMusicCancelSearch();
101 
102     void doMsgCmd(int msgType,void* user,void* data,int len);
103 
104 signals:
105     void msgSignal(int msgType,void* user,void* data,int len);
106 
107     void hidePlayList();
108 
109     void showPlayList();
110 
111     void hideSearchFileDialog();
112 
113     void showSearchFileDialog();
114 
115 protected:
116     void focusInEvent(QFocusEvent *e);
117 private:
118     Ui::MusicPlayer *ui;
119 
120     static MusicPlayer* self;//this  is for single instance
121     explicit MusicPlayer(QWidget *parent = 0);
122 
123     CommonFunction* m_commonFunction;
124     //PlayList *m_pPlayList;
125     searchFileDialog *m_pSearchDialog;
126 
127     PLAYSTATE m_bPlayState;//ENUM of state
128     bool m_bMusicListOpen;//for open is 1;close is 0
129     bool m_bSearchDialogOpen;//for open is 1;close is 0
130 
131     QList<QFileInfo> m_playList;//this is the list now play
132     QList<QFileInfo> m_playList_udisk;//this is the list from udisk
133     QList<QFileInfo> m_playList_favorite;//this is the list from favorite file
134 
135     QString m_curMusicFilePath;
136     int m_curMusicFileCount;
137 
138     AudioPlayer* ap;
139     qint64 m_totalDuration;
140     qint64 m_curDuration;
141     QTimer* progressSliderTimer;
142 
143     QString m_albumName;
144     QString m_musicName;
145     QString m_singerName;
146     QPixmap m_poster;
147 
148     int m_curPlayOrderState;//0:sequences;1:random;2:single one
149     int m_nextPlayOrderState;
150     AudioSink::OutType m_outType = AudioSink::CODEC_OUT;
151 };
152 
153 static MusicPlayer *pStaticMusicPlayer=NULL;
154 
155 #endif // MUSICPLAYER_H
156