Play a video on phonon

Source: Internet
Author: User

 

# Include <qtgui>

# Include <qwidget>

# Include <qvboxlayout>

# Include <qhboxlayout>

# Include <phonon/mediaobject>

 

# Include <phonon/videoplayer>

 

# Include <phonon/backendcapabilities>

# Include <qurl>

Myplayer: myplayer (qwidget * parent ):

Qdialog (parent ),

UI (new UI: myplayer)

{

UI-> setupui (this );

}

// Home/projects/qtmplayer-Build-desktop/../qtmplayer/myplayer. cpp: 4: Error: qphonon: No file or directory

Myplayer ::~ Myplayer ()

{

Delete UI;

}

 

Void myplayer: on_playstart_clicked ()

{

 

 

 

 

Qwidget * widget = new qwidget;

Widget-> setwindowtitle ("Media Player ");

Widget-> resize (700,600 );

 

Phonon: mediaobject * Media = new phonon: mediaobject;

Media-> setcurrentsource (phonon: mediasource ("xmuming. mpg "));

 

Phonon: videowidget * vwidget = new phonon: videowidget (widget );

Phonon: createpath (Media, vwidget );

Vwidget-> setaspectratio (phonon: videowidget: aspectratioauto );

Phonon: audiooutput * aoutput = new phonon: audiooutput (phonon: videocategory );

Phonon: createpath (Media, aoutput );

 

Qlabel * label = new qlabel ("volume :");

Phonon: volumeslider * volumeslider = new phonon: volumeslider;

Volumeslider-> setaudiooutput (aoutput );

Volumeslider-> setsizepolicy (qsizepolicy: Maximum, qsizepolicy: Maximum );

 

Phonon: seekslider * seekslider = new phonon: seekslider;

Seekslider-> setmediaobject (media );

 

Qhboxlayout * hlayout = new qhboxlayout;

Hlayout-> addwidget (Label );

Hlayout-> addwidget (volumeslider );

Hlayout-> addstretch ();

 

Qvboxlayout * vlayout = new qvboxlayout;

Vlayout-> addwidget (vwidget );

Vlayout-> addwidget (seekslider );

Vlayout-> addlayout (hlayout );

 

Widget-> setlayout (vlayout );

 

Widget-> show ();

Media-> play ();

/*

This-> setwindowtitle ("My test video player ");

Phonon: videoplayer * player = new phonon: videoplayer (phonon: videocategory, UI-> widget );

Player-> load (phonon: mediasource ("/home/Video/xmuming. mpg "));

Player-> play ();

 

 

Phonon: mediaobject * mediaobject = new phonon: mediaobject (this );

Phonon: videowidget * videowidget = new phonon: videowidget (this );

Phonon: createpath (mediaobject, videowidget );

Phonon: audiooutput * audiooutput = new phonon: audiooutput (phonon: videocategory, this );

Phonon: createpath (mediaobject, audiooutput );

Mediaobject-> setcurrentsource (phonon: mediasource ("d :\\ 001.wmv "));

Mediaobject-> play ();

 

Phonon: mediaobject * Music =

Phonon: createplayer (phonon: musiccategory,

Phonon: mediasource ("/home/Video/caiyan. rmvb "));

Music-> play ();

 

 

Phonon: mediaobject * mediaobject = new phonon: mediaobject (this );

Mediaobject-> setcurrentsource (phonon: mediasource ("/mymusic/barbiegirl.wav "));

Phonon: audiooutput * audiooutput =

New phonon: audiooutput (phonon: musiccategory, this );

Phonon: Path = phonon: createpath (mediaobject, audiooutput );

 

// Play the video

Phonon: mediaobject * Music =

Phonon: createplayer (phonon: videocategory,

Phonon: mediasource ("/home/Video/caiyan. rmvb "));

Music-> play ();

*/

// Label = new qlabel (this );

// Label-> setscaledcontents (true );

// Movie = new qmovie ("tp.gif ");

// Label-> setmovie (movie );

// Movie-> Start ();

 

}

 

If you still cannot play the video, you need to convert it to the FFMPEG decoding library.

Sudo apt-Get install libxine1-ffmpeg

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.