Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Media Element to use Media3 #2076

Open
wants to merge 87 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
ed2aebc
Migrate to AndroidX Media3 library
ne0rrmatrix Jul 31, 2024
712a022
Update AndroidX packages and refactor MediaManager
ne0rrmatrix Jul 31, 2024
d097e97
Refactor MediaManager and update to AndroidX Media3
ne0rrmatrix Aug 1, 2024
524c3e0
Update AndroidX packages and enhance MediaManager
ne0rrmatrix Aug 1, 2024
13e8144
Refactor MediaManager and update package references
ne0rrmatrix Aug 2, 2024
643f7f4
Merge branch 'CommunityToolkit:main' into Media3
ne0rrmatrix Aug 2, 2024
86fbb29
Add TODO and note with request for help solving async issue with seek…
ne0rrmatrix Aug 2, 2024
81bf905
Merge branch 'main' into Media3
ne0rrmatrix Aug 2, 2024
92fdcd9
Simplify player state handling and seeking operations
ne0rrmatrix Aug 4, 2024
02a7520
Merge branch 'main' into Media3
ne0rrmatrix Aug 4, 2024
294f6d2
Update .NET version, playback states, and error handling
ne0rrmatrix Aug 4, 2024
7139e1a
Refactor player control and resource disposal
ne0rrmatrix Aug 4, 2024
9992bcf
Merge branch 'main' into Media3
ne0rrmatrix Aug 8, 2024
5743aff
Merge branch 'main' into Media3
ne0rrmatrix Aug 9, 2024
5b39d8a
Merge branch 'main' into Media3
ne0rrmatrix Aug 9, 2024
c967d6b
Merge branch 'main' into Media3
ne0rrmatrix Aug 9, 2024
56ce4ba
Update changes from media2 for playerView poster to media3 version th…
ne0rrmatrix Aug 9, 2024
e306d86
Merge branch 'CommunityToolkit:main' into Media3
ne0rrmatrix Aug 10, 2024
9d2aca9
Add `SafeFireAndForget`
brminnick Aug 12, 2024
391422e
Merge branch 'main' into Media3
ne0rrmatrix Aug 19, 2024
a9803df
Merge branch 'CommunityToolkit:main' into Media3
ne0rrmatrix Aug 19, 2024
25d1a83
Update nuget version and apply fixes for changes
ne0rrmatrix Aug 20, 2024
c091d74
Merge branch 'Media3' of https://github.com/ne0rrmatrix/MauiOld into …
ne0rrmatrix Aug 20, 2024
3491641
Merge branch 'CommunityToolkit:main' into Media3
ne0rrmatrix Aug 21, 2024
a077367
Merge branch 'CommunityToolkit:main' into Media3
ne0rrmatrix Aug 22, 2024
eb760b9
Merge branch 'CommunityToolkit:main' into Media3
ne0rrmatrix Aug 29, 2024
6f7227f
Merge branch 'main' into Media3
ne0rrmatrix Sep 2, 2024
86d0339
Merge branch 'main' into Media3
ne0rrmatrix Sep 4, 2024
0a833d9
Merge branch 'main' into Media3
brminnick Sep 5, 2024
e966505
Merge branch 'CommunityToolkit:main' into Media3
ne0rrmatrix Sep 9, 2024
8f42eea
Merge branch 'main' into Media3
ne0rrmatrix Sep 10, 2024
e772a54
Update .NET, Maui, and AndroidX versions; refactor MediaManager
ne0rrmatrix Sep 10, 2024
7da3e66
Refactor media controls to use modern Android APIs
ne0rrmatrix Sep 11, 2024
f2d7c66
Merge branch 'Media3' of https://github.com/ne0rrmatrix/MauiOld into …
ne0rrmatrix Sep 11, 2024
2ce91d9
Merge branch 'CommunityToolkit:main' into Media3
ne0rrmatrix Sep 11, 2024
4ce68b2
Merge branch 'CommunityToolkit:main' into Media3
ne0rrmatrix Sep 12, 2024
817f74b
Refactor notification handling with INotificationService
ne0rrmatrix Sep 13, 2024
23d9b1b
Merge branch 'Media3' of https://github.com/ne0rrmatrix/MauiOld into …
ne0rrmatrix Sep 13, 2024
1786dd0
Merge branch 'main' into Media3
ne0rrmatrix Sep 13, 2024
041a06c
- Fix dependancy chain for Media Element after switching from local t…
ne0rrmatrix Sep 13, 2024
34537a0
Remove duplicate `PackageReference`
ne0rrmatrix Sep 13, 2024
8028abe
Update media session to use random id.
ne0rrmatrix Sep 16, 2024
58c5b70
Merge branch 'main' into Media3
ne0rrmatrix Sep 16, 2024
d31e5b9
- Fix buttons receiver log error.
ne0rrmatrix Sep 16, 2024
d27bdb9
removed commented code that is no longer relevent
ne0rrmatrix Sep 16, 2024
3410f00
Remove unused method
ne0rrmatrix Sep 16, 2024
f3b372e
Merge branch 'main' into Media3
ne0rrmatrix Sep 16, 2024
2f51474
Update src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.andr…
ne0rrmatrix Sep 17, 2024
4d97679
Merge branch 'main' into Media3
ne0rrmatrix Sep 17, 2024
419329e
- Remove `INotiifcation` Interface
ne0rrmatrix Sep 17, 2024
f8e82cd
Merge branch 'Media3' of https://github.com/ne0rrmatrix/MauiOld into …
ne0rrmatrix Sep 17, 2024
1ef0f9b
- Fix issue with variable name mismatch
ne0rrmatrix Sep 17, 2024
457d31c
- Update all classes to use a single type of check for API level on A…
ne0rrmatrix Sep 17, 2024
4f4d2ad
- Fix one more API check
ne0rrmatrix Sep 17, 2024
c29f3f5
- Remove suppression no longer required
ne0rrmatrix Sep 17, 2024
c72e80d
Merge branch 'main' into Media3
ne0rrmatrix Sep 17, 2024
f0be701
Add comment about `p0` event args parameter
ne0rrmatrix Sep 17, 2024
2347e4f
Merge branch 'Media3' of https://github.com/ne0rrmatrix/MauiOld into …
ne0rrmatrix Sep 17, 2024
6ead14e
Merge branch 'CommunityToolkit:main' into Media3
ne0rrmatrix Sep 18, 2024
251be66
Refactor MediaManager to use AndroidX libraries
ne0rrmatrix Sep 20, 2024
627c102
Refactor Code
brminnick Sep 20, 2024
853705c
Delete CommunityToolkit.Maui.MediaElement.sln
brminnick Sep 20, 2024
6c7d86b
Improve resource management and notifications
ne0rrmatrix Sep 21, 2024
f1b6e13
Merge branch 'Media3' of https://github.com/ne0rrmatrix/MauiOld into …
ne0rrmatrix Sep 21, 2024
b9699ff
Merge branch 'main' into Media3
ne0rrmatrix Sep 21, 2024
9070895
Refactor media handling and notification updates
ne0rrmatrix Sep 22, 2024
24b2086
Migrate to AndroidX Media3 and enhance media controls
ne0rrmatrix Sep 22, 2024
c7616e0
Remove fonts added for testing
ne0rrmatrix Sep 22, 2024
e858911
Merge branch 'main' into Media3
ne0rrmatrix Sep 22, 2024
b245c92
Refactored media service to inherit player. Behavior previously was M…
ne0rrmatrix Sep 23, 2024
785df3f
Refactor MediaElement and MediaControlsService
ne0rrmatrix Sep 23, 2024
12332c3
remove unused variable. Added null checks.
ne0rrmatrix Sep 23, 2024
c3bbe8e
Enhance null safety and refactor notification updates
ne0rrmatrix Sep 23, 2024
11bd2d4
Refactor notification ID handling in MediaControlsService
ne0rrmatrix Sep 23, 2024
bb55fe8
Merge branch 'main' into Media3
ne0rrmatrix Sep 23, 2024
f97ebd0
Merge branch 'main' into Media3
ne0rrmatrix Sep 24, 2024
76ecf47
Update service behavior. If notifications are disabled do not start s…
ne0rrmatrix Sep 24, 2024
75ffa0d
Merge branch 'Media3' of https://github.com/ne0rrmatrix/MauiOld into …
ne0rrmatrix Sep 24, 2024
3b0eec4
Remove unused using directives in MediaControlsService
ne0rrmatrix Sep 24, 2024
005eb79
Updated to address null intent. Added rebind override to add notifica…
ne0rrmatrix Sep 24, 2024
6b8c952
Update nugets for media 3
ne0rrmatrix Sep 24, 2024
ab9cb9d
Merge branch 'main' into Media3
ne0rrmatrix Sep 27, 2024
1d4dbf0
Merge branch 'main' into Media3
ne0rrmatrix Oct 1, 2024
ad2edac
Merge branch 'main' into Media3
ne0rrmatrix Oct 4, 2024
31417c6
Merge branch 'main' into Media3
ne0rrmatrix Oct 15, 2024
2b430f2
Merge branch 'main' into Media3
ne0rrmatrix Oct 15, 2024
46bd46b
Merge branch 'main' into Media3
ne0rrmatrix Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,8 @@
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
<PackageReference Include="Xamarin.AndroidX.Camera.View" Version="1.3.1.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.Camera2" Version="1.3.1.1" />

<!-- Xamarin.AndroidX.Camera 1.3.1.1 depends on Xamarin.AndroidX.Lifecycle.LiveData 2.7.0.1:
https://www.nuget.org/packages/Xamarin.AndroidX.Camera.Core/#dependencies-body-tab
However, Dotnet MAUI still implicitly references Xamarin.AndroidX.Lifecycle.LiveData 2.6.1.3:
https://github.com/dotnet/maui/blob/main/eng/AndroidX.targets
This causes build error "Detected package downgrade":
https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1605
Workaround: add a package reference to the higher version of the package. Possibly can be removed when MAUI bumps the implicit reference version.
-->
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.7.0.1" />

<!--Adding the above package reference requires Workaround for https://github.com/xamarin/AndroidX/issues/800#issuecomment-1774639627 -->
<!-- Tracking issue https://github.com/xamarin/AndroidX/issues/764 -->
<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.4.0.1" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.4.0.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.View" Version="1.3.4.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.Camera2" Version="1.3.4.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,38 @@
</PropertyGroup>

<ItemGroup>
<None Include="..\..\build\nuget.png" PackagePath="icon.png" Pack="true"/>
<None Include="ReadMe.txt" pack="true" PackagePath="."/>
<None Include="..\..\build\nuget.png" PackagePath="icon.png" Pack="true" />
<None Include="ReadMe.txt" pack="true" PackagePath="." />
</ItemGroup>

<ItemGroup>
<None Include="..\CommunityToolkit.Maui.MediaElement.Analyzers\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Maui.MediaElement.Analyzers.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false"/>
<None Include="..\CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false"/>
<None Include="..\CommunityToolkit.Maui.MediaElement.Analyzers\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Maui.MediaElement.Analyzers.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="..\CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
<PackageReference Include="Xam.Plugins.Android.ExoPlayer" Version="[2.19.1,)"/>
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Transformer" Version="[2.19.1,)"/>
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.MediaSession" Version="[2.19.1,)"/>
</ItemGroup>
<PackageReference Include="Xamarin.AndroidX.Media3.ExoPlayer" Version="1.0.2" />
<PackageReference Include="Xamarin.AndroidX.Media3.UI" Version="1.0.2" />
<PackageReference Include="Xamarin.AndroidX.Media3.ExoPlayer.Rtsp" Version="1.0.2" />
<PackageReference Include="Xamarin.AndroidX.Media3.ExoPlayer.Hls" Version="1.0.2" />
<PackageReference Include="Xamarin.AndroidX.Media3.ExoPlayer.Dash" Version="1.0.2" />
<PackageReference Include="Xamarin.AndroidX.Media3.Session" Version="1.0.2" />

<!--Adding the above package reference requires Workaround for https://github.com/xamarin/AndroidX/issues/800#issuecomment-1774639627 -->
<!-- Tracking issue https://github.com/xamarin/AndroidX/issues/764 -->

<PackageReference Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.8.3.1" />
<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.4.2" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.4.2" />
<PackageReference Include="Xamarin.AndroidX.Collection.Jvm" Version="1.4.2" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Runtime.Ktx" Version="2.8.3.1" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData.Core" Version="2.8.3.1" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.ViewModelSavedState" Version="2.8.3.1" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Process" Version="2.8.3.1" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.ViewModel.Ktx" Version="2.8.3.1" />
<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.9.0.4" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiPackageVersion)"/>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Graphics;
using Android.Media;
using Android.OS;
using Android.Support.V4.Media.Session;
using AndroidX.Core.App;
using AndroidX.LocalBroadcastManager.Content;
using CommunityToolkit.Maui.Core.Views;
using Microsoft.Win32.SafeHandles;
using AndroidStream = Android.Media.Stream;
using Resource = Microsoft.Maui.Resource;

namespace CommunityToolkit.Maui.Media.Services;
Expand All @@ -32,7 +30,6 @@ class MediaControlsService : Service
PendingIntentFlags pendingIntentFlags;
SafeHandle? safeHandle = new SafeFileHandle(IntPtr.Zero, true);
MediaSessionCompat? mediaSession;
AudioManager? audioManager;
NotificationCompat.Builder? notification;
NotificationCompat.Action? actionPlay;
NotificationCompat.Action? actionPause;
Expand All @@ -46,23 +43,20 @@ class MediaControlsService : Service
public override StartCommandResult OnStartCommand([NotNull] Intent? intent, StartCommandFlags flags, int startId)
{
ArgumentNullException.ThrowIfNull(intent);

if (!string.IsNullOrEmpty(intent.Action) && receiveUpdates is not null)
{
BroadcastUpdate(ACTION_UPDATE_PLAYER, intent.Action);
}

StartForegroundService(intent).AsTask().ContinueWith(t =>
{
if (t.Exception is not null)
{
foreach (var exception in t.Exception.InnerExceptions)
{
System.Diagnostics.Trace.WriteLine($"[error] {exception}, {exception.Message}");
System.Diagnostics.Trace.TraceError($"[error] {exception}, {exception.Message}");
}
}
}, TaskContinuationOptions.OnlyOnFaulted);

return StartCommandResult.Sticky;
}

Expand Down Expand Up @@ -92,8 +86,6 @@ ValueTask StartForegroundService(Intent mediaManagerIntent, CancellationToken ca
LocalBroadcastManager.GetInstance(this).RegisterReceiver(receiveUpdates, new IntentFilter(ACTION_UPDATE_UI));
}

OnSetupAudioServices();

pendingIntentFlags = Build.VERSION.SdkInt >= BuildVersionCodes.S
? PendingIntentFlags.UpdateCurrent | PendingIntentFlags.Immutable
: PendingIntentFlags.UpdateCurrent;
Expand All @@ -112,9 +104,8 @@ async ValueTask InitializeNotification(MediaSessionCompat mediaSession, Intent m

if (Build.VERSION.SdkInt >= BuildVersionCodes.S)
{
style.SetShowActionsInCompactView(0, 1, 2, 3);
style.SetShowActionsInCompactView(0,1,2);
}

if (Build.VERSION.SdkInt < BuildVersionCodes.Tiramisu
&& notification is null)
{
Expand All @@ -124,7 +115,7 @@ async ValueTask InitializeNotification(MediaSessionCompat mediaSession, Intent m
}

notification ??= new NotificationCompat.Builder(Platform.AppContext, "1");

notification.SetStyle(style);
notification.SetSmallIcon(_Microsoft.Android.Resource.Designer.Resource.Drawable.exo_styled_controls_audiotrack);
notification.SetAutoCancel(false);
Expand Down Expand Up @@ -170,60 +161,51 @@ void OnReceiveUpdatesPropertyChanged(object? sender, PropertyChangedEventArgs e)
notification.Build();
}

void OnSetupAudioServices()
{
audioManager = GetSystemService(Context.AudioService) as AudioManager;
ArgumentNullException.ThrowIfNull(audioManager);
audioManager.RequestAudioFocus(null, AndroidStream.Music, AudioFocus.Gain);
audioManager.SetParameters("Ducking=true");
audioManager.SetStreamVolume(AndroidStream.Music, audioManager.GetStreamVolume(AndroidStream.Music), 0);
}

async Task OnSetContent(Intent mediaManagerIntent, CancellationToken cancellationToken)
{
var albumArtUri = mediaManagerIntent.GetStringExtra("albumArtUri") ?? string.Empty;
var bitmap = await MediaManager.GetBitmapFromUrl(albumArtUri, cancellationToken).ConfigureAwait(false);
var title = mediaManagerIntent.GetStringExtra("title") ?? string.Empty;
var artist = mediaManagerIntent.GetStringExtra("artist") ?? string.Empty;
notification?.SetContentTitle(title);
notification?.SetContentText(artist);
notification?.SetLargeIcon(bitmap);
}

void OnSetIntents()
{
var pause = new Intent(this, typeof(MediaControlsService));
pause.SetAction("MediaAction.pause");
var pPause = PendingIntent.GetService(this, 1, pause, pendingIntentFlags);
actionPause ??= new NotificationCompat.Action.Builder(Resource.Drawable.exo_controls_pause, ACTION_PAUSE, pPause).Build();

var play = new Intent(this, typeof(MediaControlsService));
play.SetAction("MediaAction.play");
var pPlay = PendingIntent.GetService(this, 1, play, pendingIntentFlags);
actionPlay ??= new NotificationCompat.Action.Builder(Resource.Drawable.exo_controls_play, ACTION_PLAY, pPlay).Build();

var previous = new Intent(this, typeof(MediaControlsService));
previous.SetAction("MediaAction.rewind");
var pPrevious = PendingIntent.GetService(this, 1, previous, pendingIntentFlags);
actionPrevious ??= new NotificationCompat.Action.Builder(Resource.Drawable.exo_controls_rewind, ACTION_REWIND, pPrevious).Build();

var next = new Intent(this, typeof(MediaControlsService));
next.SetAction("MediaAction.fastForward");
var pNext = PendingIntent.GetService(this, 1, next, pendingIntentFlags);
actionNext ??= new NotificationCompat.Action.Builder(Resource.Drawable.exo_controls_fastforward, ACTION_FASTFORWARD, pNext).Build();
async Task OnSetContent(Intent mediaManagerIntent, CancellationToken cancellationToken)
{
var albumArtUri = mediaManagerIntent.GetStringExtra("albumArtUri") ?? string.Empty;
var bitmap = await MediaManager.GetBitmapFromUrl(albumArtUri, cancellationToken).ConfigureAwait(false);
var title = mediaManagerIntent.GetStringExtra("title") ?? string.Empty;
var artist = mediaManagerIntent.GetStringExtra("artist") ?? string.Empty;
notification?.SetContentTitle(title);
notification?.SetContentText(artist);
notification?.SetLargeIcon(bitmap);
}

notification?.AddAction(actionPrevious);
notification?.AddAction(actionPause);
notification?.AddAction(actionNext);
}
void OnSetIntents()
{
var pause = new Intent(this, typeof(MediaControlsService));
pause.SetAction("MediaAction.pause");
var pPause = PendingIntent.GetService(this, 1, pause, pendingIntentFlags);
actionPause ??= new NotificationCompat.Action.Builder(Resource.Drawable.exo_icon_pause, ACTION_PAUSE, pPause).Build();

var play = new Intent(this, typeof(MediaControlsService));
play.SetAction("MediaAction.play");
var pPlay = PendingIntent.GetService(this, 1, play, pendingIntentFlags);
actionPlay ??= new NotificationCompat.Action.Builder(Resource.Drawable.exo_icon_play, ACTION_PLAY, pPlay).Build();

var previous = new Intent(this, typeof(MediaControlsService));
previous.SetAction("MediaAction.rewind");
var pPrevious = PendingIntent.GetService(this, 1, previous, pendingIntentFlags);
actionPrevious ??= new NotificationCompat.Action.Builder(Resource.Drawable.exo_icon_rewind, ACTION_REWIND, pPrevious).Build();

var next = new Intent(this, typeof(MediaControlsService));
next.SetAction("MediaAction.fastForward");
var pNext = PendingIntent.GetService(this, 1, next, pendingIntentFlags);
actionNext ??= new NotificationCompat.Action.Builder(Resource.Drawable.exo_icon_fastforward, ACTION_FASTFORWARD, pNext).Build();

notification?.AddAction(actionPrevious);
notification?.AddAction(actionPause);
notification?.AddAction(actionNext);
}

static void BroadcastUpdate(string receiver, string action)
{
if (Build.VERSION.SdkInt >= BuildVersionCodes.Tiramisu)
{
System.Diagnostics.Trace.WriteLine($"{LocalBroadcastManager.GetInstance} not supported on Android 13 and above.");
return;
}
}
var intent = new Intent(receiver);
intent.PutExtra("ACTION", action);
LocalBroadcastManager.GetInstance(Platform.AppContext).SendBroadcast(intent);
Expand All @@ -238,9 +220,6 @@ protected override void Dispose(bool disposing)
safeHandle?.Dispose();
safeHandle = null;
}
audioManager?.AbandonAudioFocus(null);
audioManager?.SetParameters("Ducking=false");
audioManager?.Dispose();
mediaSession?.Release();
mediaSession?.Dispose();
mediaSession = null;
Expand All @@ -257,7 +236,6 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}
}

/// <summary>
/// A <see cref="BroadcastReceiver"/> that listens for updates from the <see cref="MediaManager"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Android.Widget;
using AndroidX.CoordinatorLayout.Widget;
using AndroidX.Core.View;
using Com.Google.Android.Exoplayer2.UI;
using AndroidX.Media3.UI;
using CommunityToolkit.Maui.Views;

namespace CommunityToolkit.Maui.Core.Views;
Expand All @@ -15,7 +15,7 @@ namespace CommunityToolkit.Maui.Core.Views;
/// </summary>
public class MauiMediaElement : CoordinatorLayout
{
readonly StyledPlayerView playerView;
readonly PlayerView playerView;
int defaultSystemUiVisibility;
bool isSystemBarVisible;
bool isFullScreen;
Expand All @@ -34,8 +34,8 @@ public MauiMediaElement(nint ptr, JniHandleOwnership jni) : base(Platform.AppCon
/// Initializes a new instance of the <see cref="MauiMediaElement"/> class.
/// </summary>
/// <param name="context">The application's <see cref="Context"/>.</param>
/// <param name="playerView">The <see cref="StyledPlayerView"/> that acts as the platform media player.</param>
public MauiMediaElement(Context context, StyledPlayerView playerView) : base(context)
/// <param name="playerView">The <see cref="PlayerView"/> that acts as the platform media player.</param>
public MauiMediaElement(Context context, PlayerView playerView) : base(context)
{
this.playerView = playerView;

Expand All @@ -59,7 +59,7 @@ public override void OnDetachedFromWindow()
{
if (isFullScreen)
{
OnFullscreenButtonClick(this, new StyledPlayerView.FullscreenButtonClickEventArgs(!isFullScreen));
OnFullscreenButtonClick(this, new PlayerView.FullscreenButtonClickEventArgs(!isFullScreen));
}
base.OnDetachedFromWindow();
}
Expand Down Expand Up @@ -102,7 +102,7 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}

void OnFullscreenButtonClick(object? sender, StyledPlayerView.FullscreenButtonClickEventArgs e)
void OnFullscreenButtonClick(object? sender, PlayerView.FullscreenButtonClickEventArgs e)
{
// Ensure there is a player view
if (playerView is null)
Expand All @@ -111,7 +111,7 @@ void OnFullscreenButtonClick(object? sender, StyledPlayerView.FullscreenButtonCl
}
var layout = CurrentPlatformContext.CurrentWindow.DecorView as ViewGroup;

if (e.IsFullScreen)
if (e.P0)
ne0rrmatrix marked this conversation as resolved.
Show resolved Hide resolved
{
isFullScreen = true;
RemoveView(relativeLayout);
Expand Down
Loading