From 69df1c4a563faae80f3887fcac36fbf61ea0e6d8 Mon Sep 17 00:00:00 2001 From: ne0rrmatrix Date: Tue, 26 Mar 2024 14:19:36 -0700 Subject: [PATCH 01/55] The most significant changes involve the addition of new metadata properties to the `MediaElement` class and the creation of a new `MediaElementSourceType.cs` file. The metadata properties allow the media player to display more information about the media being played, such as title, album, artist, genre, artwork, and source type. The `MediaElementSourceType.cs` file introduces a new `enum` type that represents different types of media sources. 1. Added new properties to the `MediaElement` class to support metadata such as title, album, artist, genre, artwork, and source type. This allows the media player to display more information about the media being played. 2. Updated the `MediaElementPage.xaml` and `MediaElementPage.xaml.cs` files to use the new metadata properties in the `MediaElement` class. 3. Added new code in the `MediaManager.macios.cs` and `MediaManager.windows.cs` files to handle the metadata properties when playing media. 4. Added new code in the `Info.plist` file to allow the app to play audio in the background on iOS. 5. Added a new `MetaDataExtensions` class to handle setting the metadata for the system media controls on iOS and Windows. 6. Updated the `IMediaElement` interface to include the new metadata properties. 7. Updated the `MediaElement.shared.cs` file to include the new bindable properties for the metadata. 8. Updated the `MediaManager` class to handle the metadata when the media source is changed. 9. Updated the `MediaManager` class to update the metadata when the media state changes. 10. Updated the `MediaManager` class to clear the metadata when the media source is reset. 11. Created a new file named `MediaElementSourceType.cs` in the `CommunityToolkit.Maui.Primitives` namespace. This file defines a new `enum` type named `MediaElementSourceType` that represents different types of media sources, including `Video`, `Audio`, and `Unknown`. --- .../Views/MediaElement/MediaElementPage.xaml | 10 +- .../MediaElement/MediaElementPage.xaml.cs | 30 ++- .../Platforms/iOS/Info.plist | 9 + .../Extensions/MetaDataExtensions.macios.cs | 242 ++++++++++++++++++ .../Extensions/MetaDataExtensions.shared.cs | 14 + .../Extensions/MetaDataExtensions.windows.cs | 79 ++++++ .../Interfaces/IMediaElement.cs | 31 +++ .../MediaElement.shared.cs | 97 +++++++ .../Primitives/MediaElementSourceType.cs | 28 ++ .../Views/MediaManager.macios.cs | 45 +++- .../Views/MediaManager.windows.cs | 21 +- 11 files changed, 598 insertions(+), 8 deletions(-) create mode 100644 src/CommunityToolkit.Maui.MediaElement/Extensions/MetaDataExtensions.macios.cs create mode 100644 src/CommunityToolkit.Maui.MediaElement/Extensions/MetaDataExtensions.shared.cs create mode 100644 src/CommunityToolkit.Maui.MediaElement/Extensions/MetaDataExtensions.windows.cs create mode 100644 src/CommunityToolkit.Maui.MediaElement/Primitives/MediaElementSourceType.cs diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/MediaElement/MediaElementPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Views/MediaElement/MediaElementPage.xaml index 49ac61bc6d..4ae6403295 100644 --- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/MediaElement/MediaElementPage.xaml +++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/MediaElement/MediaElementPage.xaml @@ -33,13 +33,19 @@ WidthRequest="{OnIdiom Tablet=410, Default=380}" ShouldAutoPlay="True" Source="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" - MediaEnded="OnMediaEnded" + MetadataArtwork="https://michellevella.com/cdn/shop/products/BeatlesLonelyHearts4UP_1728x.jpg?v=1660582971" + MetadataTitle="Big Buck Bunny" + MetadataAlbum="Sample" + MetadataArtist="Blender Foundation" + MetadataGenre="Animation" + SourceType="Audio" + MediaEnded="OnMediaEnded" MediaFailed="OnMediaFailed" MediaOpened="OnMediaOpened" PositionChanged="OnPositionChanged" StateChanged="OnStateChanged" SeekCompleted="OnSeekCompleted"/> - +