Recently the code wrote a lot, but did not pass much, another day to find a time to comb under! Don't say much nonsense,
Qt5 seemingly in the audio and video processing and QT4 different, Qt4 with Phonon,qt5 with Qmediaplayer.
1. Modify the Pro file
Add QT +=multimedia//audio processing to Pro files
Add QT +=multimediawidget//Support Qvideowidget in pro file, play video
2.
Window set to support playback of video streams
setAttribute (Qt::wa_translucentbackground,true );
player = new qmediaplayer (th is,0);
Playlist = new Qmediaplaylist (this);
Videowidget = new Qvideowidget (this);
NEXTBTN = new Qpushbutton (tr ("Next"), this);
Qgridlayout *mainlayout = new Qgridlayout (this);
Add a media file to a playlist
Playlist->addmedia (Qurl::fromlocalfile ("C:/users/zgw/music/old.mp3"));
Playlist->addmedia (Qurl::fromlocalfile ("C:/users/zgw/music/her.mp3"));
Playlist->addmedia (Qurl::fromlocalfile ("C:/users/zgw/music/hua.mp3"));
Playlist->addmedia (Qurl::fromlocalfile ("c:/users/zgw/music/wildlife.wmv"));
Where the settings list starts playing
Playlist->setcurrentindex (Playindex);
Player->setplaylist (playlist);
Player->setvideooutput (Videowidget);
Videowidget->show ();
Mainlayout->addwidget (Videowidget, 1, 1, 3, 3);
Mainlayout->addwidget (NEXTBTN, 4, 1, 1, 1);
This->setlayout (mainlayout);
Set the volume to start playing
Player->setvolume (100);
Player->play (); Connect (nextbtn, SIGNAL (clicked ()), this, SLOT (On_next_click ()));
void mywidget::on_next_click()
{
if (Playindex = = 4)
{
Playindex = 1;
}
Else
{
playindex++;
}
Player->stop ();
Playlist->setcurrentindex (Playindex);
Player->play ();
The functionality is simple and the interface is simple--| | |. The next step continues to expand the function: 1, playlist visualization, 2, manually add playback files, 3, the realization of network functions (download songs, cache listen to songs) 4, lyrics function
QT5 Self-created simple music video player (basic version)