Search in sources :

Example 1 with WaitCallback

use of cli.System.Threading.WaitCallback in project playn by threerings.

the class IOSAudio method createAVAP.

Sound createAVAP(NSUrl url) {
    final IOSSoundAVAP sound = new IOSSoundAVAP();
    ThreadPool.QueueUserWorkItem(new WaitCallback(new WaitCallback.Method() {

        public void Invoke(Object arg) {
            NSUrl url = (NSUrl) arg;
            NSError[] error = new NSError[1];
            AVAudioPlayer player = AVAudioPlayer.FromUrl(url, error);
            if (error[0] == null) {
                dispatchLoaded(sound, player);
            } else {
                platform.log().warn("Error loading sound [" + url + ", " + error[0] + "]");
                dispatchLoadError(sound, new Exception(error[0].ToString()));
            }
        }
    }), url);
    return sound;
}
Also used : AVAudioPlayer(cli.MonoTouch.AVFoundation.AVAudioPlayer) WaitCallback(cli.System.Threading.WaitCallback) NSUrl(cli.MonoTouch.Foundation.NSUrl) NSError(cli.MonoTouch.Foundation.NSError)

Example 2 with WaitCallback

use of cli.System.Threading.WaitCallback in project playn by threerings.

the class IOSAudio method createOAL.

Sound createOAL(String assetPath) {
    final IOSSoundOAL sound = new IOSSoundOAL(this);
    ThreadPool.QueueUserWorkItem(new WaitCallback(new WaitCallback.Method() {

        public void Invoke(Object arg) {
            String path = (String) arg;
            int bufferId = 0;
            try {
                bufferId = AL.GenBuffer();
                CAFLoader.load(path, bufferId);
                dispatchLoaded(sound, bufferId);
            } catch (Throwable t) {
                if (bufferId != 0)
                    AL.DeleteBuffer(bufferId);
                dispatchLoadError(sound, t);
            }
        }
    }), assetPath);
    return sound;
}
Also used : WaitCallback(cli.System.Threading.WaitCallback)

Aggregations

WaitCallback (cli.System.Threading.WaitCallback)2 AVAudioPlayer (cli.MonoTouch.AVFoundation.AVAudioPlayer)1 NSError (cli.MonoTouch.Foundation.NSError)1 NSUrl (cli.MonoTouch.Foundation.NSUrl)1