Skip to content

Commit 39ba194

Browse files
Merge branch 'main' into Remove-All-Static-References-From-CreateDefaultValue
2 parents 0d7cfa7 + 9e9797a commit 39ba194

3 files changed

Lines changed: 90 additions & 2 deletions

File tree

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitati
2323

2424
<!-- MAUI Specific -->
2525
<MauiXamlInflator>SourceGen</MauiXamlInflator>
26-
<MauiPackageVersion>10.0.30</MauiPackageVersion>
26+
<MauiPackageVersion>10.0.41</MauiPackageVersion>
2727
<MauiStrictXamlCompilation>true</MauiStrictXamlCompilation>
2828
<SkipValidateMauiImplicitPackageReferences>true</SkipValidateMauiImplicitPackageReferences>
2929
<MauiEnableXamlCBindingWithSourceCompilation>true</MauiEnableXamlCBindingWithSourceCompilation>

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 IsAndroidForegroundServiceEnabled { get; private set; } = true;
23+
internal static bool IsAndroidForegroundServiceEnabled { get; private set; }
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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,93 @@ public void UseMauiCommunityToolkitMediaElement_ShouldSetDefaultAndroidViewType(
166166

167167
MediaElementOptions.DefaultAndroidViewType.Should().Be(AndroidViewType.TextureView);
168168
}
169+
170+
[Fact]
171+
public void UseMauiCommunityToolkitMediaElement_isAndroidForegroundServiceEnabledParameterFalse_IgnoreIsAndroidForegroundServiceEnabled_AndroidForegroundServiceShouldRemainDisabled()
172+
{
173+
MediaElementOptions.IsAndroidForegroundServiceEnabled.Should().Be(false);
174+
175+
var builder = MauiApp.CreateBuilder();
176+
builder.UseMauiCommunityToolkitMediaElement(isAndroidForegroundServiceEnabled: false, static options =>
177+
{
178+
options.SetDefaultAndroidViewType(AndroidViewType.TextureView);
179+
});
180+
181+
MediaElementOptions.IsAndroidForegroundServiceEnabled.Should().Be(false);
182+
}
183+
184+
[Fact]
185+
public void UseMauiCommunityToolkitMediaElement_isAndroidForegroundServiceEnabledParameterTrue_IgnoreIsAndroidForegroundServiceEnabled_ShouldEnableAndroidForegroundService()
186+
{
187+
MediaElementOptions.IsAndroidForegroundServiceEnabled.Should().Be(false);
188+
189+
var builder = MauiApp.CreateBuilder();
190+
builder.UseMauiCommunityToolkitMediaElement(isAndroidForegroundServiceEnabled: true, static options =>
191+
{
192+
options.SetDefaultAndroidViewType(AndroidViewType.TextureView);
193+
});
194+
195+
MediaElementOptions.IsAndroidForegroundServiceEnabled.Should().Be(true);
196+
}
197+
198+
[Fact]
199+
public void UseMauiCommunityToolkitMediaElement_isAndroidForegroundServiceEnabledParameterFalse_SetIsAndroidForegroundServiceEnabledFalse_AndroidForegroundServiceShouldRemainDisabled()
200+
{
201+
MediaElementOptions.IsAndroidForegroundServiceEnabled.Should().Be(false);
202+
203+
var builder = MauiApp.CreateBuilder();
204+
builder.UseMauiCommunityToolkitMediaElement(isAndroidForegroundServiceEnabled: false, static options =>
205+
{
206+
options.SetDefaultAndroidViewType(AndroidViewType.TextureView);
207+
options.SetIsAndroidForegroundServiceEnabled(false);
208+
});
209+
210+
MediaElementOptions.IsAndroidForegroundServiceEnabled.Should().Be(false);
211+
}
212+
213+
[Fact]
214+
public void UseMauiCommunityToolkitMediaElement_isAndroidForegroundServiceEnabledParameterTrue_SetIsAndroidForegroundServiceEnabledTrue_ShouldEnableAndroidForegroundService()
215+
{
216+
MediaElementOptions.IsAndroidForegroundServiceEnabled.Should().Be(false);
217+
218+
var builder = MauiApp.CreateBuilder();
219+
builder.UseMauiCommunityToolkitMediaElement(isAndroidForegroundServiceEnabled: true, static options =>
220+
{
221+
options.SetDefaultAndroidViewType(AndroidViewType.TextureView);
222+
options.SetIsAndroidForegroundServiceEnabled(true);
223+
});
224+
225+
MediaElementOptions.IsAndroidForegroundServiceEnabled.Should().Be(true);
226+
}
227+
228+
[Fact]
229+
public void UseMauiCommunityToolkitMediaElement_isAndroidForegroundServiceEnabledParameterFalse_SetIsAndroidForegroundServiceEnabledTrue_ShouldEnableAndroidForegroundService()
230+
{
231+
MediaElementOptions.IsAndroidForegroundServiceEnabled.Should().Be(false);
232+
233+
var builder = MauiApp.CreateBuilder();
234+
builder.UseMauiCommunityToolkitMediaElement(isAndroidForegroundServiceEnabled: false, static options =>
235+
{
236+
options.SetDefaultAndroidViewType(AndroidViewType.TextureView);
237+
options.SetIsAndroidForegroundServiceEnabled(true);
238+
});
239+
240+
MediaElementOptions.IsAndroidForegroundServiceEnabled.Should().Be(true);
241+
}
242+
243+
[Fact]
244+
public void UseMauiCommunityToolkitMediaElement_isAndroidForegroundServiceEnabledParameterTrue_SetIsAndroidForegroundServiceEnabledFalse_ShouldEnableAndroidForegroundService()
245+
{
246+
MediaElementOptions.IsAndroidForegroundServiceEnabled.Should().Be(false);
247+
248+
var builder = MauiApp.CreateBuilder();
249+
builder.UseMauiCommunityToolkitMediaElement(isAndroidForegroundServiceEnabled: true, static options =>
250+
{
251+
options.SetDefaultAndroidViewType(AndroidViewType.TextureView);
252+
options.SetIsAndroidForegroundServiceEnabled(false);
253+
});
254+
255+
MediaElementOptions.IsAndroidForegroundServiceEnabled.Should().Be(true);
256+
}
169257
}
170258
#pragma warning restore CA1416

0 commit comments

Comments
 (0)