adrianstevens / Xamarin-Plugins

Cross-platform Plugins for Xamarin, Xamarin.Forms and Windows
https://www.nuget.org/packages/Xam.Plugin.SimpleAudioPlayer/
MIT License
132 stars 53 forks source link

Notifying property ? #81

Closed melakhvision closed 2 years ago

melakhvision commented 3 years ago

Hello How can we notify a property with the playing even.I don't see an explanation or example on the sample.

    private void Play()
    {
        var assembly = typeof(App).GetTypeInfo().Assembly;
        Stream audioStream = assembly.GetManifestResourceStream("Bemuslim.Resource.IslamVoice.mp3");
        var audio = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
        audio.Load(audioStream);
        audio.Play();
        if (CrossSimpleAudioPlayer.Current.IsPlaying == true)
        {
            PrayerTimeLayout.IsVisible = true;
        }
    }

I tried this but doesn't work

adrianstevens commented 3 years ago

@melakhvision you can subscribe to the PlaybackEnded event to find out when the audio completes.

In your case, you could set IsVisible to true when you call audio.Play() and then set it to false when the event triggers.