基于QT的在线音乐播放器设计与实现

ui设计界面

基于QT的在线音乐播放器设计与实现_第1张图片

运行界面

基于QT的在线音乐播放器设计与实现_第2张图片

桌面歌词

基于QT的在线音乐播放器设计与实现_第3张图片

widget.h

#ifndef WIDGET_H
#define WIDGET_H

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “showlrctodesktop.h”
#include
#include
#include
#include
#include

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
Q_OBJECT

public:
Widget(QWidget *parent = nullptr);
~Widget();
void getMusicWord(const QString &qstrFileName);
void addMusic();
void start_lrc_mask(qint64 intervaltime);
void QTransformMusicWord(QString qstrAllLine);

private slots:
void on_pushButton_open_clicked();
void on_pushButton_pause_clicked();
void on_pushButton_back_clicked();
void on_pushButton_next_clicked();
void on_pushButton_volumn_clicked();
void on_listWidget_doubleClicked(const QModelIndex &index);
void on_horizontalSlider_time_sliderReleased();
void on_horizontalSlider_volumn_sliderMoved(int position);
void on_pushButton_xunhuan_clicked();
void on_pushButton_find_clicked();
void on_pushButton_openlrc_clicked();
void on_pushButton_online_clicked();

private:
Ui::Widget *ui;
QMediaPlayer *player;
QMediaPlaylist *playlist;
bool b_isPlay;
QMap map_lrc;
QStringList fileList; //音乐列表

//歌词显示
QLinearGradient linear_gradient;
QLinearGradient mask_linear_gradient;
double lrc_mask_width;
double lrc_mask_width_interval;
qint64 interval_time;
QString m_strMusicCurWord;
QString m_strMusicNextWord;
QTimer *timer;
QTimer *timerLrc;
//桌面歌词显示类
ShowLrcToDeskTop *showlrc;
//在线搜索
QTcpSocket *tcpsocket;
bool isConnectedServer;
bool isLoacalMuisc;
//获得网络歌词
QNetworkAccessManager *m_NetManger;
QNetworkReply* m_Reply;

protected:
void paintEvent(QPaintEvent *painter);
};
#endif // WIDGET_H

showlrctodesktop.h

#ifndef SHOWLRCTODESKTOP_H
#define SHOWLRCTODESKTOP_H

#include
#include
#include
#include
#include
#include
#include
#include
#include

class ShowLrcToDeskTop : public QWidget
{
Q_OBJECT
public:
explicit ShowLrcToDeskTop(QWidget *parent = nullptr);
~ShowLrcToDeskTop();
//显示歌词接口
void showMusicLrc(qint64 time,const QString strMusicLrcData,bool isPlayStatus);
//歌词动态显示
void start_lrc_mask(qint64 intervaltime,bool isPlayStatus);
void stopLrcTimer();
void startLrcTimer(int ms);

signals:
void showLrcDesktopSignal();

protected:
void paintEvent(QPaintEvent *painter);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);

private:
QString *m_CurMusicData;
QLinearGradient linear_gradient;
QLinearGradient mask_linear_gradient;
qreal lrc_mask_width;
qreal lrc_mask_width_interval;
QPoint m_pPoint;
QPoint m_pWindowPoint;

QTimer *timerLrc;
//是否移动的标志
bool m_bMoveFlag;

};

#endif SHOWLRCTODESKTOP_H

完整代码已上传到百度网盘

链接:https://pan.baidu.com/s/1-o9ei2UWUcLiXQSam1Ie5Q
提取码:8uqt

你可能感兴趣的:(linux,windows)