Skip to content

How to Dispose the MediaElement in .NET 8? #1663

Closed Answered by marco-skizza
marco-skizza asked this question in Q&A
Discussion options

You must be logged in to vote

Hi

An updated answer for .NET 9 and CommunityToolkit.Maui.MediaElement version 4.1.2.
At it seems, you can now just call the following for iOS, Android and Windows:

    protected override void OnHandlerChanging(HandlerChangingEventArgs args)
    {
        base.OnHandlerChanging(args);

        if (args.NewHandler != null)
        {
            return;
        }

        MyMediaElement.Handler?.DisconnectHandler();
    }

See also my sample project here.

Replies: 2 comments 14 replies

Comment options

You must be logged in to vote
14 replies
@pictos
Comment options

pictos Jan 30, 2024
Collaborator

@PureWeen
Comment options

@pictos
Comment options

pictos Feb 9, 2024
Collaborator

@marco-skizza
Comment options

Answer selected by marco-skizza
@pictos
Comment options

pictos Mar 9, 2024
Collaborator

@marco-skizza
Comment options

@bzd3y
Comment options

@jo-ruch
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants