#include "iceplayer.h"
IcePlayer::IcePlayer(QWidget *parent)
: QWidget(parent)
{
ice_init_ui();
ice_init_player();
ice_init_connections();
ice_init_windows();
ice_init_menu_actions();
ice_init_network();
iceDir = QApplication::applicationDirPath();
ice_read_list();
}
IcePlayer::~IcePlayer()
{
}
void IcePlayer::ice_init_windows()
{
aboutForm = new ICE_About_Form(this);
iceLrc = new ICE_Lrc(this);
miniForm = new miniwindow();
miniForm->ICE_Set_Parent(this);
miniForm->hide();
}
void IcePlayer::ice_init_menu_actions()
{
modeSingal = new QAction(QString::fromLocal8Bit("单曲播放"), this);
modeListCircle = new QAction(QString::fromLocal8Bit("列表循环"), this);
modeSingalCircle = new QAction(QString::fromLocal8Bit("单曲循环"), this);
modeRandom = new QAction(QString::fromLocal8Bit("随机播放"), this);
connect(modeSingal, SIGNAL(triggered()), this, SLOT(ice_set_play_mode()));
connect(modeListCircle, SIGNAL(triggered()), this, SLOT(ice_set_play_mode()));
connect(modeSingalCircle, SIGNAL(triggered()), this, SLOT(ice_set_play_mode()));
connect(modeRandom, SIGNAL(triggered()), this, SLOT(ice_set_play_mode()));
modeActionGroup = new QActionGroup(this);
modeActionGroup->addAction(modeSingal);
modeActionGroup->addAction(modeListCircle);
modeActionGroup->addAction(modeSingalCircle);
modeActionGroup->addAction(modeRandom);
modeSingal->setCheckable(true);
modeListCircle->setCheckable(true);
modeSingalCircle->setCheckable(true);
modeRandom->setCheckable(true);
modeSingal->setChecked(true);
playModeMenu = new QMenu(modeButton);
playModeMenu->setStyleSheet(
"QMenu{padding:5px;background:white;border:1px solid gray;}"
"QMenu::item{padding:0px 40px 0px 30px;height:25px;}"
"QMenu::item:selected:enabled{background:#0096ff;color:white;}"
"QMenu::item:selected:!enabled{background:transparent;}"
"QMenu::separator{height:1px;background:lightgray;margin:5px 0px 5px 0px;}");
playModeMenu->addActions(modeActionGroup->actions());
contextMenuLess = new QMenu(playlistTable);
contextMenuMore = new QMenu(playlistTable);
addMusic = new QAction(QString::fromLocal8Bit("添加歌曲"),this);
addFileDiv = new QAction(QString::fromLocal8Bit("添加目录"),this);
removeCurr = new QAction(QString::fromLocal8Bit("移除本曲"),this);
removeAll = new QAction(QString::fromLocal8Bit("移除所有"),this);
connect(addMusic, SIGNAL(triggered()), this, SLOT(ice_open_music()));
connect(addFileDiv, SIGNAL(triggered()), this, SLOT(ice_open_dir()));
connect(removeCurr, SIGNAL(triggered()), this, SLOT(ice_remove_current_music()));
connect(removeAll, SIGNAL(triggered()), this, SLOT(ice_clear_list()));
contextMenuLess->addAction(addMusic);
contextMenuLess->addAction(addFileDiv);
contextMenuLess->addSeparator();
contextMenuLess->addAction(removeAll);
contextMenuMore->addAction(addMusic);
contextMenuMore->addAction(addFileDiv);
contextMenuMore->addSeparator();
contextMenuMore->addAction(removeCurr);
contextMenuMore->addAction(removeAll);
contextMenuLess->setStyleSheet(
"QMenu{padding:5px;background:white;border:1px solid gray;}"
"QMenu::item{padding:0px 40px 0px 30px;height:25px;}"
"QMenu::item:selected:enabled{background:#0096ff;color:white;}"
"QMenu::item:selected:!enabled{background:transparent;}"
"QMenu::separator{height:1px;background:lightgray;margin:5px 0px 5px 0px;}");
contextMenuMore->setStyleSheet(
"QMenu{padding:5px;background:white;border:1px solid gray;}"
"QMenu::item{padding:0px 40px 0px 30px;height:25px;}"
"QMenu::item:selected:enabled{background:#0096ff;color:white;}"
"QMenu::item:selected:!enabled{background:transparent;}"
"QMenu::separator{height:1px;background:lightgray;margin:5px 0px 5px 0px;}");
}
void IcePlayer::ice_init_player()
{
mediaPlayer = new QMediaPlayer(this);
mediaList = new QMediaPlaylist(this);
mediaPlayer->setPlaylist(mediaList);
playMode = ICE_Play_Mode::SINGAL;
preIndex = -1;
currentIndex = 0;
mediaList->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
}
void IcePlayer::ice_init_connections()
{
connect(mediaPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(ice_update_position(qint64)));
connect(mediaPlayer, SIGNAL(durationChanged(qint64)), this, SLOT(ice_update_duration(qint64)));
connect(mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)),this, SLOT(ice_update_state(QMediaPlayer::State)));
connect(mediaPlayer, SIGNAL(metaDataChanged()), this, SLOT(ice_update_meta_data()));
connect(playSlider, SIGNAL(sliderMoved(int)), this, SLOT(ice_set_play_position(int)));
connect(playSlider, SIGNAL(sliderReleased()), this, SLOT(ice_set_position()));
connect(volButton, SIGNAL(ICE_Volume_Changed(int)), mediaPlayer, SLOT(setVolume(int)));
connect(playlistTable, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(ice_playlisttable_cell_double_clicked(int, int)));
connect(playlistTable, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(ice_playlisttable_menu_requested(const QPoint &)));
connect(addButton, SIGNAL(clicked()), this, SLOT(ice_open_music()));
connect(exitButton, SIGNAL(clicked()), this, SLOT(close()));
connect(playButton, SIGNAL(clicked()), this, SLOT(ice_play_button_clicked()));
connect(lyricButton, SIGNAL(clicked()), this, SLOT(ice_lyric_button_clicked()));
connect(logoButton, SIGNAL(clicked()), this, SLOT(ice_logo_button_clicked()));
connect(modeButton, SIGNAL(clicked()), this, SLOT(ice_mode_button_clicked()));
connect(nextButton, SIGNAL(clicked()), this, SLOT(ice_next_button_clicked()));
connect(lastButton, SIGNAL(clicked()), this, SLOT(ice_last_button_clicked()));
connect(pauseButton, SIGNAL(clicked()), this, SLOT(ice_pause_button_clicked()));
connect(minButton, SIGNAL(clicked()), this, SLOT(ice_min_button_clicked()));
connect(mminButton, SIGNAL(clicked()), this, SLOT(showMinimized()));
//connect(this, SIGNAL(destroyed()), this, SLOT(ice_close()));
//connect(mediaList, SIGNAL(mediaInserted()), this, SLOT(ice_write_list()));
}
void IcePlayer::ice_init_ui()
{
picLabel = new QLabel( this);
picLabel->setGeometry(QRect(40, 45, 100, 100));
picLabel->setScaledContents(true);
picLabel->setPixmap(QPixmap(":/IcePlayer/Resources/default_album.jpg"));
nameLabel = new IceLabel(this);
nameLabel->setGeometry(QRect(150, 55, 220, 20));
musicianLabel = new QLabel(this);
musicianLabel->setGeometry(QRect(150, 85, 220, 15));
albumLabel = new QLabel(this);
albumLabel->setGeometry(QRect(150, 115, 220, 15));
playSlider = new QSlider( this);
playSlider->setObjectName(QStringLiteral("playSlider"));
playSlider->setStyleSheet("QSlider::groove:horizontal{border:0px;height:4px;}"
"QSlider::sub-page:horizontal{background:#0096ff;}"
"QSlider::add-page:horizontal{background:lightgray;} "
"QSlider::handle:horizontal{background:white;width:10px;border:#51b5fb 10px;border-radius:5px;margin:-3px 0px -3px 0px;}");
playSlider->setGeometry(QRect(40, 150, 290, 20));
playSlider->setOrientation(Qt::Horizontal);
timeLabel = new QLabel( this);
timeLabel->setObjectName(QStringLiteral("timeLabel"));
timeLabel->setGeometry(QRect(340, 150, 51, 16));
playlistTable = new QTableWidget( this);
playlistTable->setObjectName(QStringLiteral("playlistTable"));
playlistTable->setGeometry(QRect(25, 240, 350, 320));
playlistTable->setItemDelegate(new NoFocusDelegate());
addButton = new ICE_Ice_Button( this);
addButton->setObjectName(QStringLiteral("addButton"));
addButton->setGeometry(QRect(40, 190, 31, 31));
modeButton = new ICE_Ice_Button( this);
modeButton->setObjectName(QStringLiteral("modeButton"));
modeButton->setGeometry(QRect(290, 190, 31, 31));
lastButton = new ICE_Ice_Button( this);
lastButton->setObjectName(QStringLiteral("lastButton"));
lastButton->setGeometry(QRect(120, 185, 41, 41));
nextButton = new ICE_Ice_Button( this);
nextButton->setObjectName(QStringLiteral("nextButton"));
nextButton->setGeometry(QRect(240, 185, 41, 41));
lyricButton = new ICE_Ice_Button( this);
lyricButton->setObjectName(QStringLiteral("lyricButton"));
没有合适的资源?快使用搜索试试~ 我知道了~
使用 QT5 和 VS2013 的音乐播放器
共76个文件
png:37个
h:14个
cpp:13个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 118 浏览量
2024-04-28
15:20:26
上传
评论
收藏 407KB ZIP 举报
温馨提示
漂亮的音乐播放器 A Nice Music Player by Qt5 and C++
资源推荐
资源详情
资源评论
收起资源包目录
IcePlayer-master.zip (76个子文件)
IcePlayer-master
ICEPLAYER
single_application.cpp 2KB
icelabel.h 526B
iceButton.cpp 1KB
mini.h 1KB
network.cpp 573B
~AutoRecover.ICEPLAYER.vcxproj 69KB
resource.h 385B
icevolbutton.cpp 2KB
aboutform.h 335B
iceplayer.cpp 39KB
songinfo.h 4KB
icelabel.cpp 838B
iceplayer.h 5KB
nofocusdelegate.cpp 360B
aboutform.cpp 2KB
main.cpp 1KB
iceButton.h 800B
icevolbutton.h 838B
ICEPLAYER.vcxproj.filters 10KB
network.h 847B
single_application.h 594B
iceplayer.qrc 2KB
icelrc.h 469B
about.h 314B
lyric.h 792B
Resources
暂停按钮mini.png 20KB
default_album.jpg 107KB
缩小按钮2.png 18KB
logo-16.png 18KB
播放按钮-主界面.png 23KB
音量调节.png 19KB
上一曲2.png 20KB
上一曲.png 22KB
logo-48.png 21KB
添加歌曲2.png 18KB
左上角logo按钮2.png 29KB
歌词按钮.png 20KB
添加歌曲.png 18KB
播放模式.png 19KB
歌词按钮2.png 20KB
暂停按钮-主界面2.png 26KB
about.png 491KB
缩小按钮.png 18KB
迷你模式按钮.png 19KB
前进按钮mini.png 19KB
full.png 271KB
lrc_background.png 269KB
下一曲2.png 20KB
关闭按钮2.png 22KB
暂停按钮-主界面.png 25KB
background.png 22KB
播放按钮mini.png 19KB
mini底部窗口(2).png 26KB
左上角logo按钮.png 28KB
音量调节2.png 20KB
关闭按钮.png 21KB
播放模式2.png 22KB
mini.png 22KB
迷你模式按钮2.png 20KB
下一曲.png 19KB
lyric.png 19KB
logo-32.png 20KB
播放按钮-主界面2.png 25KB
iceplayer.ui 574B
lyric.cpp 4KB
ICEPLAYER.vcxproj 85KB
about.cpp 2KB
IcePlayer.rc 58B
IcePlayer.idc 1KB
logo.ico 13KB
nofocusdelegate.h 336B
mini.cpp 8KB
icelrc.cpp 1KB
ICEPLAYER.sln 1KB
.gitattributes 378B
.gitignore 2KB
共 76 条
- 1
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6713
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功