StorageFile file = await filePicker.PickSingleFileAsync() Set picker start location to the video libraryįilePicker.SuggestedStartLocation = PickerLocationId.VideosLibrary Add your fileTypes to the FileTypeFilter list of filePicker. make a collection of all video types you want to support (for testing we are adding just 3). Finally, set the media source as the playback source for the MediaElement by calling the SetPlaybackSource method. With the StorageFile object returned from the picker's PickSingleFileAsync method, initialize a new MediaObject by calling MediaSource.CreateFromStorageFile. To allow the user to pick a media file to play, use a FileOpenPicker. MediaSource _mediaSource ĭeclare a variable to store the MediaPlayer object and, if you want to render the media content in XAML, add a MediaPlayerElement control to your page. For the examples in this article, the media source is declared as a class member so that it can be accessed from multiple locations. using ĭeclare a variable of type MediaSource. You will need to include the and namespaces in order to complete this scenario. INQSCRIBE PLAYLIST OPEN NO MEDIA HOW TOThe following example shows how to play back a user-selected media file in a MediaPlayer using MediaSource. For more information on using MediaPlayer, see Play audio and video with MediaPlayer. This is the preferred method over using MediaElement. INQSCRIBE PLAYLIST OPEN NO MEDIA WINDOWSStarting with Windows 10, version 1607, you can assign a MediaPlayer to a MediaPlayerElement by calling SetMediaPlayer in order to render the media player content in a XAML page. Create and play a MediaSourceĬreate a new instance of MediaSource by calling one of the factory methods exposed by the class:Īfter creating a MediaSource you can play it with a MediaPlayer by setting the Source property. MediaPlaybackList allows you to create playback lists from one or more media playback items. The MediaPlaybackItem class extends the functionality of MediaSource, allowing you to manage and select from multiple audio, video, and metadata tracks contained in a media item. This article shows you how to use the MediaSource class, which provides a common way to reference and play back media from different sources such as local or remote files and exposes a common model for accessing media data, regardless of the underlying media format.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |