Video in WPF -- (1)

Source: Internet
Author: User

WPF The video support is also based on Mediaplayer Class and Its Related Mediaelement And Mediatimeline . Because Mediaplayer Is based on Windows Media Player 10 Or a later version, as long Windows Media Player Formats of videos that can be played (for example . Wmv,. Avi,. mpg ), In Mediaplayer Or Mediaelement Can be played in all (the premise is that the system must be installed Windows Media Player 10 Or higher ).

WPF The playing of the video in is similar to that of the audio (in use Mediaelement By setting Source The attribute is a video file. If you use Mediaplayer Because the video needs to be displayed in a window during playback Mediaplayer YesProgramCodeDesigned (not involved UI Display), to display Mediaplayer The loaded media must be used. Videodrawing Or Drawingcontext (In ( 2 ).

UseMediaelementThe code for playing a video is as follows:

<Grid>

<Mediaelement source = "C:" users "public" videos "sample Videos" bear. wmv "opacity =" 0.5 ">

<Mediaelement. Clip>

<Ellipsegeometry center = "220 220" radiusx = "220" radiusy = "220"/>

</Mediaelement. Clip>

<Mediaelement. layouttransform>

<Rotatetransform angle = "180"/>

</Mediaelement. layouttransform>

</Mediaelement>

<Mediaelement source = "C:" users "public" videos "sample Videos" bear. wmv "opacity =" 0.5 ">

<Mediaelement. Clip>

<Ellipsegeometry center = "220 220" radiusx = "220" radiusy = "220"/>

</Mediaelement. Clip>

</Mediaelement>

</GRID>

Use twoMediaelementPlay the same video file.180Degrees of rotation, as shown in:

 

To control video playback, you canMediatimelineUsed in combinationPausestoryboard,ResumestoryboadAnd other actions.

One issue that requires attention is that media files cannot be embedded resources.MediaplayerIt can be understood that the path is an absolute path, a relative file path, orURL.

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.