The main character of this article is the universal player in Linux:Mplayer
Mplayer is open-source, so it is loved by developers. Download mplayer-1.0rc2.tar.bz2 to Linux. After configure, make, and make install, you can use mplayer to play video and audio files in Linux. However, the form is very ugly and its appearance inherits from the system. The effect is as follows: (the playback effect is not card, but the recording effect is not good. Next, >_<)
In embedded devices, we need to pack mplayer with DIY skins to implement our own player.
Let's first consider how to make mplayer look better and how to make skin.
There are two ideas:
One method is to dissect mplayer and directly modify the code in it, so that the interface we have done can be integrated with mplayer (of course, any library and. O documentation, which can be seamlessly integrated into the program ).
The second method of slave is the so-called slave mode of mplayer. The slave mode means that mplayer can receive users' input command lines during running. The specific command lines supported can be obtained through the mplayer-input cmdlist command, in slave mode, mplayer can interact with standard input and output of the system. We can use Linux C programming to control and obtain information about the mplayer in slave mode. For example: mkfifo ("/tmp/FIFO", 0777 );
Qt provides us with a more convenient implementation method: Call the compiled mplayer by defining a qprocess object. Of course, this also belongs to the second type: slave mode.
I wrote a simple example with the taste of DIY. This is my purpose.
Main function: Click the play button to play video resources.
Mainwindow: mainwindow (qwidget * parent ):
Qmainwindow (parent ),
UI (new UI: mainwindow)
{
UI-> setupui (this );
Playform = new qwidget (this );
Playform-> setsizepolicy (qsizepolicy: preferred, qsizepolicy: preferred ));
Playform-> setattribute (QT: wa_opaquepaintevent );
Playform-> move (110,100 );
Playform-> setminimumsize (320,240 );
}
Mainwindow ::~ Mainwindow ()
{
Delete UI;
}
Void mainwindow: on_pushbutton_clicked ()
{
Qprocess * process = new qprocess (this );
// Process-> Start ("mplayer-AC mad Unbelivable-23.avi ");
Qstringlist ARGs;
ARGs <"-slave ";
ARGs <"-quiet ";
ARGs <"-wid" <qstring: Number (this-> playform-> winid ());
ARGs <"Unbelivable-23.avi ";
Process-> setprocesschannelmode (qprocess: mergedchannels );
Process-> Start ("mplayer", argS );
}
Of course, mplayer's powerful functions are not used yet. There are also some basic functions that are easy to implement:
Suspend Function
Process-> write ("Pause \ n ");
Obtains the total time and current playback progress of a playback file.
Process-> write ("get_time_pos \ n ");
Process-> write ("get_time_length \ n ");
Fast forward feature
Seek <value> [type]
Seek to some place in the movie.
0 is a relative seek of +/-<value> seconds (default ).
1 is a seek to <value> % in the movie.
2 is a seek to an absolute position of <value> seconds.
Process-> write ("seek ** 1 \ n ");
Volume Adjustment
Volume <value> [ABS]
Increase/decrease volume or set it to <value> If [ABS] is nonzero.
Process-> write ("volume-1 \ n"); // decrease the volume
Process-> write ("volume + 1 \ n"); // increase the volume
Mute function
Mute [value]
Toggle sound output muting or set it to [value] When [value]> = 0
(1 = on, 0 = OFF ).
Process-> write ("mute 0 \ n"); // enable mute
Process-> write ("mute 1 \ n"); // disable mute
Detailed mplayer introduction here: Detailed mplayer Introduction
My simple multimedia player instance has the required resources: mplayer-1.0rc2.tar.bz21_libmad-0.15.1b.tar.gz.
You have uploaded csdn resources, which are green and healthy, and are non-toxic and pollution-free. Resource Package download
Welcome to the discussion.
Author: yiyaaixuexi published on 3:09:03 Original article link reading: 3228 comments: 40 views comments