File tree Expand file tree Collapse file tree 4 files changed +19
-10
lines changed
samples/CommunityToolkit.Maui.Sample/Platforms/Android Expand file tree Collapse file tree 4 files changed +19
-10
lines changed Original file line number Diff line number Diff line change 44 android : supportsRtl =" true" >
55
66 <meta-data android : name =" com.google.android.geo.API_KEY" android : value =" PASTE-YOUR-API-KEY-HERE" />
7+
8+ <service android : name =" communityToolkit.maui.media.services" android : stopWithTask =" true" android : exported =" false" android : enabled =" true"
9+ android : foregroundServiceType =" mediaPlayback" >
10+ <intent-filter >
11+ <action android : name =" android.intent.action.MEDIA_BUTTON" />
12+ </intent-filter >
13+ <intent-filter >
14+ <action android : name =" androidx.media3.session.MediaSessionService" />
15+ </intent-filter >
16+ </service >
717 </application >
818
919 <uses-permission android : name =" android.permission.ACCESS_NETWORK_STATE" />
1020 <uses-permission android : name =" android.permission.READ_EXTERNAL_STORAGE" />
1121 <uses-permission android : name =" android.permission.WRITE_EXTERNAL_STORAGE" />
1222
23+ <uses-permission android : name =" android.permission.FOREGROUND_SERVICE" />
24+ <uses-permission android : name =" android.permission.POST_NOTIFICATIONS" />
25+ <uses-permission android : name =" android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
26+ <uses-permission android : name =" android.permission.MEDIA_CONTENT_CONTROL" />
1327 <!-- Samsung -->
1428 <uses-permission android : name =" com.sec.android.provider.badge.permission.READ" />
1529 <uses-permission android : name =" com.sec.android.provider.badge.permission.WRITE" />
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ internal MediaElementOptions(in MauiAppBuilder builder) : this()
2020 /// <summary>
2121 /// Set Android Foreground Service for MediaElement on construction
2222 /// </summary>
23- internal static bool AndroidForegroundServiceEnabled { get ; private set ; } = true ;
23+ internal static bool AndroidForegroundServiceEnabled { get ; private set ; } = false ;
2424
2525 /// <summary>
2626 /// Set Android View type for MediaElement as SurfaceView or TextureView on construction
Original file line number Diff line number Diff line change 88using AndroidX . Media3 . UI ;
99using CommunityToolkit . Maui . Views ;
1010
11- [ assembly: UsesPermission ( Android . Manifest . Permission . ForegroundServiceMediaPlayback ) ]
12- [ assembly: UsesPermission ( Android . Manifest . Permission . ForegroundService ) ]
13- [ assembly: UsesPermission ( Android . Manifest . Permission . MediaContentControl ) ]
14- [ assembly: UsesPermission ( Android . Manifest . Permission . PostNotifications ) ]
15-
1611namespace CommunityToolkit . Maui . Core . Views ;
1712
1813/// <summary>
Original file line number Diff line number Diff line change @@ -141,11 +141,11 @@ public void UseMauiCommunityToolkitMediaElement_ShouldSetDefaultAndroidViewType(
141141 }
142142
143143 [ Fact ]
144- public void UseMauiCommunityToolkitMediaElement_ShouldSetAndroidServiceByDefault ( )
144+ public void UseMauiCommunityToolkitMediaElement_ShouldSetAndroidServiceByDefaultToFalse ( )
145145 {
146146 var builder = MauiApp . CreateBuilder ( ) ;
147147 builder . UseMauiCommunityToolkitMediaElement ( ) ;
148- MediaElementOptions . AndroidForegroundServiceEnabled . Should ( ) . Be ( true ) ;
148+ MediaElementOptions . AndroidForegroundServiceEnabled . Should ( ) . Be ( false ) ;
149149 }
150150
151151 [ Fact ]
@@ -154,9 +154,9 @@ public void UseMauiCommunityToolkitMediaElement_ServiceCanBeDisabled()
154154 var builder = MauiApp . CreateBuilder ( ) ;
155155 builder . UseMauiCommunityToolkitMediaElement ( static options =>
156156 {
157- options . SetDefaultAndroidForegroundService ( false ) ;
157+ options . SetDefaultAndroidForegroundService ( true ) ;
158158 } ) ;
159- MediaElementOptions . AndroidForegroundServiceEnabled . Should ( ) . Be ( false ) ;
159+ MediaElementOptions . AndroidForegroundServiceEnabled . Should ( ) . Be ( true ) ;
160160 }
161161}
162162#pragma warning restore CA1416
You can’t perform that action at this time.
0 commit comments