MediaElement v8.0.0: Android Foreground Service is now optional
Contributors
CommunityToolkit.Maui.MediaElement v8.0.0
We heard your feedback! In this release using the Android Foreground Service is now optional. For developers requiring Background Playback and/or Rich Media Notifications, you’ll now opt-in to the Android Foreground Service. Everyone else now has the option to opt-out.
This does come with a breaking change to the way we initialize MediaElement in MauiProgram.cs to either opt-in or opt-out of the Android Foreground Service.
Initializing MediaElement
Opt-In to Android Foreground Service
To use MediaElement with Background Playback and/or Rich Media Notifications, opt-in to the Android Foreground Service when initializing CommunityToolkit.Maui.MediaElement:
.UseMauiCommunityToolkitMediaElement(isAndroidForegroundServiceEnabled: true, static options =>
{
options.SetDefaultAndroidViewType(AndroidViewType.TextureView);
})
Opt-out of Android Foreground Service
To use MediaElement without Background Playback and/or Rich Media Notifications, opt out of the Android Foreground Service when initializing CommunityToolkit.Maui.MediaElement:
.UseMauiCommunityToolkitMediaElement(isAndroidForegroundServiceEnabled: false, static options =>
{
options.SetDefaultAndroidViewType(AndroidViewType.TextureView);
})
What’s Changed
- Implement
[BindableProperty]for MediaElement by James Crutchley in https://github.com/CommunityToolkit/Maui/pull/2933 - Add missing AudioSessionIdChanged stub to android MediaElement by James Crutchley in https://github.com/CommunityToolkit/Maui/pull/2992
- Fix MediaElement windows fails to playback by James Crutchley in https://github.com/CommunityToolkit/Maui/pull/2915
- Add support to make AndroidForegroundService optional to MediaElement by James Crutchley in https://github.com/CommunityToolkit/Maui/pull/2658
- Fix memory leak by changing now playing artwork request handler by @MarcelStommel in https://github.com/CommunityToolkit/Maui/pull/3051
Full Changelog: https://github.com/CommunityToolkit/Maui/compare/7.0.0-mediaelement…8.0.0-mediaelement