public override void DecoderError(AVAudioPlayer player, NSError error)
 {
     if (cbDecoderError != null)
     {
         cbDecoderError(player, new AVErrorEventArgs(error));
     }
 }
 public override void BeginInterruption(AVAudioPlayer player)
 {
     if (cbBeginInterruption != null)
     {
         cbBeginInterruption(player, EventArgs.Empty);
     }
 }
Пример #3
0
 public override void FinishedPlaying(AVAudioPlayer player, bool flag)
 {
     if (cbFinishedPlaying != null)
     {
         cbFinishedPlaying(player, new AVStatusEventArgs(flag));
     }
 }
Пример #4
0
		public override void FinishedPlaying (AVAudioPlayer player, bool flag)
		{
			if (cbFinishedPlaying != null)
				cbFinishedPlaying (player, new AVStatusEventArgs (flag));
			if (player.Handle == IntPtr.Zero)
				throw new ObjectDisposedException ("player", "the player object was Dispose()d during the callback, this has corrupted the state of the program");
		}
Пример #5
0
        public static AVAudioPlayer FromData(NSData data)
        {
            unsafe {
                var ap = new AVAudioPlayer (data, IntPtr.Zero);
                if (ap.Handle == IntPtr.Zero)
                    return null;

                return ap;
            }
        }
 public override void FinishedPlaying(AVAudioPlayer player, bool flag)
 {
     if (cbFinishedPlaying != null)
     {
         cbFinishedPlaying(player, new AVStatusEventArgs(flag));
     }
     if (player.Handle == IntPtr.Zero)
     {
         throw new ObjectDisposedException("player", "the player object was Dispose()d during the callback, this has corrupted the state of the program");
     }
 }
Пример #7
0
        public static AVAudioPlayer FromData(NSData data)
        {
            unsafe {
                var ap = new AVAudioPlayer(data, IntPtr.Zero);
                if (ap.Handle == IntPtr.Zero)
                {
                    return(null);
                }

                return(ap);
            }
        }
Пример #8
0
        public static AVAudioPlayer FromUrl(NSUrl url)
        {
            unsafe {
                var ap = new AVAudioPlayer(url, IntPtr.Zero);
                if (ap.Handle == IntPtr.Zero)
                {
                    return(null);
                }

                return(ap);
            }
        }
Пример #9
0
        public static AVAudioPlayer FromData(NSData data, out NSError error)
        {
            unsafe {
                IntPtr errhandle;
                IntPtr ptrtohandle = (IntPtr) (&errhandle);

                var ap = new AVAudioPlayer (data, ptrtohandle);
                if (ap.Handle == IntPtr.Zero){
                    error = (NSError) Runtime.GetNSObject (errhandle);
                    return null;
                } else
                    error = null;
                return ap;
            }
        }
Пример #10
0
        public static AVAudioPlayer FromUrl(NSUrl url, out NSError error)
        {
            unsafe {
                IntPtr errhandle;
                IntPtr ptrtohandle = (IntPtr)(&errhandle);

                var ap = new AVAudioPlayer(url, ptrtohandle);
                if (ap.Handle == IntPtr.Zero)
                {
                    error = Runtime.GetNSObject <NSError> (errhandle);
                    return(null);
                }
                else
                {
                    error = null;
                }
                return(ap);
            }
        }
Пример #11
0
        public static AVAudioPlayer FromData(NSData data, out NSError error)
        {
            unsafe {
                IntPtr errhandle;
                IntPtr ptrtohandle = (IntPtr)(&errhandle);

                var ap = new AVAudioPlayer(data, ptrtohandle);
                if (ap.Handle == IntPtr.Zero)
                {
                    error = (NSError)Runtime.GetNSObject(errhandle);
                    return(null);
                }
                else
                {
                    error = null;
                }
                return(ap);
            }
        }
Пример #12
0
 public override void DecoderError(AVAudioPlayer player, NSError  error)
 {
     if (cbDecoderError != null)
         cbDecoderError (player, new AVErrorEventArgs (error));
 }
		public override void Close()
		{
			base.Close();

			soundEffect = null;
		}
		public override void Open(string fileName, int soundId)
		{
			base.Open(fileName, soundId);

			string relFilePath = Path.Combine(CCContentManager.SharedContentManager.RootDirectory, fileName);
			string absFilePath = null;

			// First let's try loading with the file extension type if one exists
			var ext = Path.GetExtension(fileName);

			if (!string.IsNullOrEmpty(ext))
			{
				// trim off extension
				fileName = fileName.Substring(0, fileName.Length - ext.Length);
				// create 
				relFilePath = Path.Combine(CCContentManager.SharedContentManager.RootDirectory, fileName);
				// strip off the period
				ext = ext.Substring(1);
				//  now try loading the resource using the extenion as the file type
				absFilePath = NSBundle.MainBundle.PathForResource(relFilePath, ext);
			}

			if (string.IsNullOrEmpty(absFilePath))
				foreach(string formatType in CCSimpleAudioEngine.AllowedTypesMac)
				{
					absFilePath = NSBundle.MainBundle.PathForResource(relFilePath, formatType);
					if(absFilePath !=null)
						break;
				}

			if (absFilePath == null)
				CCLog.Log("CocosSharp: File Name: " + fileName + " was not found.");

			if (absFilePath != null)
			{
				try 
				{
					soundEffect = AVAudioPlayer.FromUrl(new NSUrl(absFilePath, false));
				}
				catch 
				{
					CCLog.Log("CocosSharp: File Name: " + fileName + " could not be loaded.");
				}
			}

		}
Пример #15
0
        public static AVAudioPlayer FromUrl(NSUrl url)
        {
            unsafe {
                var ap = new AVAudioPlayer (url, IntPtr.Zero);
                if (ap.Handle == IntPtr.Zero)
                    return null;

                return ap;
            }
        }
Пример #16
0
 public override void EndInterruption(AVAudioPlayer player)
 {
     if (cbEndInterruption != null)
         cbEndInterruption (player, EventArgs.Empty);
 }
Пример #17
0
 public override void FinishedPlaying(AVAudioPlayer player, bool flag)
 {
     if (cbFinishedPlaying != null)
         cbFinishedPlaying (player, new AVStatusEventArgs (flag));
 }
		public override void Close()
		{
			base.Close();
			music = null;
		}