question

CyberSteve-2513 avatar image
CyberSteve-2513 asked ·

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

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.


windows-uwp-xaml
1 comment
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@CyberSteve-2513 I haven't heard from you for a while. Does my answer make sense? If you still have questions, please feel free to contact us.

0 Votes 0 · ·
RoyLi-MSFT avatar image
RoyLi-MSFT answered ·

Hello,


Welcome to Microsoft Q&A!

@CyberSteve-2513 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.


Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CyberSteve-2513 avatar image
CyberSteve-2513 answered ·

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.

1 comment Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The MediaPlaybackItem object contains a DurationLimit property but no properties for Bitrate and path. The MediaPlaybackList does not contain any properties that show the duration, path, and bitrate. So the bitrate and path are not duplicated data.


0 Votes 0 · ·
CyberSteve-2513 avatar image
CyberSteve-2513 answered ·

Thanks. That really does help.

Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.