UWP XMAL c# -- Most effective way to use the MediaPlaybackList

CyberSteve 156 Reputation points
2020-09-10T23:28:22.59+00:00

Hi,

I'm just learning UWP and hope you can help. I'm looking for just a general outline for the best approach for doing the following.

Load audio files from a playlist into a MediaPlaybackList associated with a MediaPlayerElement. I can do this with no problem.

Now how do I create a list of all the file names in a list located beside the MediaPlayerElement? This way the user can select a item in the list and jump directly to it. I've seen several approaches for doing this and not sure which one is best. I also want the bitrate, duration and path to be available for display when requested.

Finally any changes will be saved back to the playlist.

Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Roy Li - MSFT 32,051 Reputation points Microsoft Vendor
    2020-09-11T03:15:27.463+00:00

    Hello,

    Welcome to Microsoft Q&A!

    @CyberSteve Since that you've found some approaches already, my suggestion is that you can try them all and choose one that is most suitable for your scenario.

    I also want the bitrate, duration and path to be available for display when requested.

    You could use VideoProperties Class or MusicProperties Class to get the bitrate, duration of the media file.

                //if it's a video file.   
                Windows.Storage.FileProperties.VideoProperties videoProperties = await file.Properties.GetVideoPropertiesAsync();  
                //if it's a song file  
                Windows.Storage.FileProperties.MusicProperties musicProperties = await file.Properties.GetMusicPropertiesAsync();  
      
      
                Duration videoDuration = videoProperties.Duration;  
                uint videoBitrate = videoProperties.Bitrate;  
                string videoPath = file.Path;  
    

    Thank you.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. CyberSteve 156 Reputation points
    2020-10-08T00:18:22.207+00:00

    Your answer was helpful. I thought I'd get notified through email. Sorry...still getting used to the new system. Anyway, one more thing. I use the MusicProperties class or VideoProperties class like in the sample you provided. Next I create a custom class to store only those properties I need. Then I add my class in a ObservableCollection bound to a listview. However, I feel like I'm duplicating data that's already contained in the MediaPlaybackItems or MediaPlaybackList.


  2. CyberSteve 156 Reputation points
    2020-10-08T21:34:47.873+00:00

    Thanks. That really does help.

    0 comments No comments