Esempio n. 1
0
		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));

			}

		}
Esempio n. 2
0
        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));
            }
        }
Esempio n. 3
0
        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.
        }
Esempio n. 4
0
 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));
     }
 }