private void loadIos(String url) { _url = url; var mediaFile = NSUrl.FromFilename(_url); _player = AVAudioPlayer.FromUrl(mediaFile); if (null != _player) { if (_players.Count == NumberOfPlayers) { _players.Dequeue().Dispose(); } _players.Enqueue(_player); _player.PrepareToPlay(); _channel = new SoundChannel(); _channel.Player = _player; _player.DecoderError += delegate { this.dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR)); }; _player.FinishedPlaying += delegate { _channel.dispatchEvent (new Event (Event.SOUND_COMPLETE)); //_player.Dispose(); }; this.dispatchEvent(new Event(Event.COMPLETE)); } }
private void loadIos(String url) { _url = url; var mediaFile = NSUrl.FromFilename(_url); _player = AVAudioPlayer.FromUrl(mediaFile); if (null != _player) { if (_players.Count == NumberOfPlayers) { _players.Dequeue().Dispose(); } _players.Enqueue(_player); _player.PrepareToPlay(); _channel = new SoundChannel(); _channel.Player = _player; _player.DecoderError += delegate { this.dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR)); }; _player.FinishedPlaying += delegate { _channel.dispatchEvent(new Event(Event.SOUND_COMPLETE)); //_player.Dispose(); }; this.dispatchEvent(new Event(Event.COMPLETE)); } }
void OnFinishedPlaying(object sender, AVStatusEventArgs args) { lock (sSync) { sAsyncEventDispatcher.Add(() => { mChannel.dispatchEvent(new Event(Event.SOUND_COMPLETE)); }); } // We can't dispose the sound within the callback as it breaks the app state (callback from another thread?) // This will aynway automatically be taken care of next time a sound is played, and this player will be recycled. }
public void OnCompletion(MediaPlayer mp) { if (count < loopsCount) { count++; mp.SeekTo(0); mp.Start(); } else if (count >= loopsCount) { channel.dispatchEvent(new Event(Event.SOUND_COMPLETE)); } }