Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Use media element play method when is looping is true and media is played to end (ios) #2006

Conversation

FedericoNembrini
Copy link
Contributor

Description of Bug

Speed is lost when IsLooping=True because avPlayerViewController.Player?.Play(); is used to restart the player.

By using Play() the speed is respected.

protected virtual void Play()
{
var audioSession = AVAudioSession.SharedInstance();
var err = audioSession.SetCategory(AVAudioSession.CategoryPlayback);
if (err != null)
Log.Warning("MediaElement", "Failed to set AVAudioSession Category {0}", err.Code);
audioSession.SetMode(AVAudioSession.ModeMoviePlayback, out err);
if (err != null)
Log.Warning("MediaElement", "Failed to set AVAudioSession Mode {0}", err.Code);
err = audioSession.SetActive(true);
if (err != null)
Log.Warning("MediaElement", "Failed to set AVAudioSession Active {0}", err.Code);
if (avPlayerViewController.Player != null)
{
avPlayerViewController.Player.Play();
Controller.CurrentState = MediaElementState.Playing;
UpdateSpeed();
}
if (Element.KeepScreenOn)
SetKeepScreenOn(true);
}

Issues Fixed

Behavioral Changes

PR Checklist

  • Has a linked Issue, and the Issue has been approved
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Updated documentation

@jfversluis
Copy link
Member

Now that we're so close to the sunsetting of Xamarin (and therefore also Xamarin Community Toolkit) unfortunately we won't be able to take this in anymore, we're really sorry about that. Nevertheless, thank you so much for your time and effort that you have put into this PR, we really appreciate it.

Please have a look at the evolution of the Xamarin Community Toolkit, The .NET MAUI Community Toolkit. A lot of development has been going on there. Hopefully this issue was already fixed in that codebase. If not, feel free to port this over to there.

Again, thank you so much for being a contributor and Xamarin user!

@jfversluis jfversluis closed this Apr 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] MediaElement bugs when 'IsLoop' is set to true
2 participants