You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
2.1 KiB
107 lines
2.1 KiB
6 months ago
|
#ifndef MUSIC_H
|
||
|
#define MUSIC_H
|
||
|
|
||
|
#include <QMainWindow>
|
||
|
#include <QMediaPlayer>
|
||
|
#include <QMediaPlaylist>
|
||
|
#include <QPushButton>
|
||
|
#include <QSlider>
|
||
|
#include <QVBoxLayout>
|
||
|
#include <QHBoxLayout>
|
||
|
#include <QListWidget>
|
||
|
#include <QLabel>
|
||
|
#include <QSpacerItem>
|
||
|
#include <QDebug>
|
||
|
#include <QMatrix>
|
||
|
#include "flyme/flyme.h"
|
||
|
|
||
|
QT_BEGIN_NAMESPACE
|
||
|
namespace Ui { class music; }
|
||
|
QT_END_NAMESPACE
|
||
|
|
||
|
class FloatingButton;
|
||
|
/* 媒体信息结构体 */
|
||
|
struct MediaObjectInfo {
|
||
|
/* 用于保存歌曲文件名 */
|
||
|
QString fileName;
|
||
|
/* 用于保存歌曲文件路径 */
|
||
|
QString filePath;
|
||
|
};
|
||
|
|
||
|
class music : public QMainWindow
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
|
music(QWidget *parent = nullptr);
|
||
|
~music();
|
||
|
int angle = 0;
|
||
|
private:
|
||
|
|
||
|
Ui::music *ui;
|
||
|
/* 媒体播放器,用于播放音乐 */
|
||
|
QMediaPlayer *musicPlayer;
|
||
|
|
||
|
/* 媒体列表 */
|
||
|
QMediaPlaylist *mediaPlaylist;
|
||
|
|
||
|
/* 音乐列表 */
|
||
|
QListWidget *listWidget;
|
||
|
|
||
|
/* 媒体信息存储 */
|
||
|
QVector<MediaObjectInfo> mediaObjectInfo;
|
||
|
/* 用于遮罩 */
|
||
|
QWidget *listMask;
|
||
|
|
||
|
FloatingButton *floatingbutton;
|
||
|
|
||
|
/* 扫描歌曲 */
|
||
|
void scanSongs();
|
||
|
|
||
|
/* 媒体播放器类初始化 */
|
||
|
void mediaPlayerInit();
|
||
|
/* 音乐布局函数 */
|
||
|
void musicLayout();
|
||
|
|
||
|
void image_rotate();
|
||
|
private slots:
|
||
|
|
||
|
/* 播放按钮点击 */
|
||
|
void btn_play_clicked();
|
||
|
|
||
|
/* 下一曲按钮点击*/
|
||
|
void btn_next_clicked();
|
||
|
|
||
|
/* 上一曲按钮点击 */
|
||
|
void btn_previous_clicked();
|
||
|
|
||
|
/* 媒体状态改变 */
|
||
|
void mediaPlayerStateChanged(QMediaPlayer::State);
|
||
|
|
||
|
/* 列表单击 */
|
||
|
void listWidgetCliked(QListWidgetItem*);
|
||
|
|
||
|
/* 媒体列表项改变 */
|
||
|
void mediaPlaylistCurrentIndexChanged(int);
|
||
|
|
||
|
/* 媒体总长度改变 */
|
||
|
void musicPlayerDurationChanged(qint64);
|
||
|
|
||
|
/* 媒体播放位置改变 */
|
||
|
void mediaPlayerPositionChanged(qint64);
|
||
|
/* 控制音量条显示 */
|
||
|
void on_btn_volume_toggled(bool checked);
|
||
|
|
||
|
/* 播放进度条松开 */
|
||
|
void durationSliderReleased();
|
||
|
|
||
|
/* 音量控制 */
|
||
|
void volume_change();
|
||
|
/*悬浮球 */
|
||
|
void onButtonPressed();
|
||
|
signals:
|
||
|
void music_close(bool t);
|
||
|
|
||
|
};
|
||
|
#endif
|