Example #1
0
		public bool Play (IMusicTrack music, bool loop) {
			var avfMusic = (AvfMusicTrack)music;
			if (avfMusic == null)
				throw new ArgumentException ("Music must be an AvfBackgroundMusic object.", "music");
			_music = avfMusic;

			if (_player != null)
				_player.Dispose ();

			_player = AVAudioPlayer.FromUrl (new NSUrl (Assets.ResolvePath (avfMusic.Path)));
			_player.Volume = _volume;
			_player.NumberOfLoops = loop ? -1 : 0;
			return _player.Play ();
		}
Example #2
0
		public bool Play (IMusicTrack music, bool loop = false) {

			var aMusic = music as AndroidMusicTrack;
			if (aMusic == null)
				throw new ArgumentException ("Music must be an AndroidMusicTrack.", "music");
			_music = aMusic;

			Reset ();
			_player.Looping = loop;
			var asset = aMusic.Asset;
			_player.SetDataSource (asset.FileDescriptor, asset.StartOffset, asset.Length);
			_player.Prepare ();
			_player.Start ();

			return _player.IsPlaying;
		}
Example #3
0
		public bool Play (IMusicTrack music, bool loop) {
			var sdlMusic = music as SDL2MusicTrack;
			if (sdlMusic == null)
				throw new ArgumentException("Music must be an SDL2 music track.", "music");

			Stop();
			_music = sdlMusic;
			_isLooping = loop;
			Play();

			return false;
		}