Skip to content

Commit f6407f6

Browse files
committed
Set service on by default
Fix tests Service needs to be on by default in android as that will unify behavior
1 parent 0feee28 commit f6407f6

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/CommunityToolkit.Maui.MediaElement/MediaElementOptions.shared.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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; } = false;
23+
internal static bool AndroidForegroundServiceEnabled { get; private set; } = true;
2424

2525
/// <summary>
2626
/// Set Android View type for MediaElement as SurfaceView or TextureView on construction

src/CommunityToolkit.Maui.UnitTests/Extensions/AppBuilderExtensionsTests.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,27 +139,24 @@ public void UseMauiCommunityToolkitMediaElement_ShouldSetDefaultAndroidViewType(
139139

140140
MediaElementOptions.DefaultAndroidViewType.Should().Be(AndroidViewType.TextureView);
141141
}
142-
/* Needs to be fixed! If it is run by itself it works, but when run with the rest of the tests it fails.
142+
143143
[Fact]
144-
public void UseMauiCommunityToolkitMediaElement_ShouldSetAndroidServiceByDefaultToFalse()
144+
public void UseMauiCommunityToolkitMediaElement_ShouldSetAndroidServiceByDefault()
145145
{
146-
MediaElementOptions.AndroidForegroundServiceEnabled.Should().Be(false);
147146
var builder = MauiApp.CreateBuilder();
148147
builder.UseMauiCommunityToolkitMediaElement();
149-
MediaElementOptions.AndroidForegroundServiceEnabled.Should().Be(false);
148+
MediaElementOptions.AndroidForegroundServiceEnabled.Should().Be(true);
150149
}
151-
*/
150+
152151
[Fact]
153-
public void UseMauiCommunityToolkitMediaElement_ServiceCanBeEnabled()
152+
public void UseMauiCommunityToolkitMediaElement_ServiceCanBeDisabled()
154153
{
155-
MediaElementOptions.AndroidForegroundServiceEnabled.Should().Be(false);
156-
157154
var builder = MauiApp.CreateBuilder();
158155
builder.UseMauiCommunityToolkitMediaElement(static options =>
159156
{
160-
options.SetDefaultAndroidForegroundService(true);
157+
options.SetDefaultAndroidForegroundService(false);
161158
});
162-
MediaElementOptions.AndroidForegroundServiceEnabled.Should().Be(true);
159+
MediaElementOptions.AndroidForegroundServiceEnabled.Should().Be(false);
163160
}
164161
}
165162
#pragma warning restore CA1416

0 commit comments

Comments
 (0)