public boolean setActive(boolean active) throws NSErrorException { NSError.NSErrorPtr ptr = new NSError.NSErrorPtr(); boolean result = setActive(active, ptr); if (ptr.get() != null) { throw new NSErrorException(ptr.get()); } return result; } @Method(selector = "setActive:error:")
/** * @since Available in iOS 6.0 and later. */ public static NSObject observeInterruption(final VoidBlock1<AVAudioSessionInterruptionNotification> block) { return NSNotificationCenter.getDefaultCenter().addObserver(InterruptionNotification(), null, NSOperationQueue.getMainQueue(), new VoidBlock1<NSNotification>() { @Override public void invoke(NSNotification a) { NSDictionary<?, ?> userInfo = a.getUserInfo(); AVAudioSessionInterruptionNotification data = null; if (userInfo != null) { data = new AVAudioSessionInterruptionNotification(userInfo); } block.invoke(data); } }); }
/** * @since Available in iOS 7.0 and later. */ public static NSObject observeMediaServicesWereLost(final Runnable block) { return NSNotificationCenter.getDefaultCenter().addObserver(MediaServicesWereLostNotification(), null, NSOperationQueue.getMainQueue(), new VoidBlock1<NSNotification>() { @Override public void invoke(NSNotification a) { block.run(); } }); } /**
public RoboAudio(RoboPlatform plat, int numSources) { this.plat = plat; session = AVAudioSession.getSharedInstance(); try { session.setActive(true, AVAudioSessionSetActiveOptions.None); } catch (NSErrorException e) { plat.log().error("Unable to activate audio session: " + e);
public boolean setCategory(AVAudioSessionCategory category) throws NSErrorException { NSError.NSErrorPtr ptr = new NSError.NSErrorPtr(); boolean result = setCategory(category, ptr); if (ptr.get() != null) { throw new NSErrorException(ptr.get()); } return result; } @Method(selector = "setCategory:error:")
@Override public void invoke(NSNotification a) { NSDictionary<?, ?> userInfo = a.getUserInfo(); AVAudioSessionSilenceSecondaryAudioHintType type = null; if (userInfo.containsKey(SilenceSecondaryAudioHintTypeKey())) { NSNumber val = (NSNumber)userInfo.get(SilenceSecondaryAudioHintTypeKey()); type = AVAudioSessionSilenceSecondaryAudioHintType.valueOf(val.intValue()); } block.invoke(type); } });
/** * @since Available in iOS 6.0 and later. */ public static NSObject observeMediaServicesWereReset(final Runnable block) { return NSNotificationCenter.getDefaultCenter().addObserver(MediaServicesWereResetNotification(), null, NSOperationQueue.getMainQueue(), new VoidBlock1<NSNotification>() { @Override public void invoke(NSNotification a) { block.run(); } }); } /**
/** * @since Available in iOS 6.0 and later. */ public boolean overrideOutputAudioPort(AVAudioSessionPortOverride portOverride) throws NSErrorException { NSError.NSErrorPtr ptr = new NSError.NSErrorPtr(); boolean result = overrideOutputAudioPort(portOverride, ptr); if (ptr.get() != null) { throw new NSErrorException(ptr.get()); } return result; } /**
/** * @since Available in iOS 6.0 and later. */ public boolean setInputDataSource(AVAudioSessionDataSourceDescription dataSource) throws NSErrorException { NSError.NSErrorPtr ptr = new NSError.NSErrorPtr(); boolean result = setInputDataSource(dataSource, ptr); if (ptr.get() != null) { throw new NSErrorException(ptr.get()); } return result; } /**
/** * @since Available in iOS 6.0 and later. */ public static NSObject observeRouteChange(final VoidBlock1<AVAudioSessionRouteChangeNotification> block) { return NSNotificationCenter.getDefaultCenter().addObserver(RouteChangeNotification(), null, NSOperationQueue.getMainQueue(), new VoidBlock1<NSNotification>() { @Override public void invoke(NSNotification a) { NSDictionary<?, ?> userInfo = a.getUserInfo(); AVAudioSessionRouteChangeNotification data = null; if (userInfo != null) { data = new AVAudioSessionRouteChangeNotification(userInfo); } block.invoke(data); } }); } /**
/** * @since Available in iOS 8.0 and later. */ public static NSObject observeSilenceSecondaryAudioHint(final VoidBlock1<AVAudioSessionSilenceSecondaryAudioHintType> block) { return NSNotificationCenter.getDefaultCenter().addObserver(SilenceSecondaryAudioHintNotification(), null, NSOperationQueue.getMainQueue(), new VoidBlock1<NSNotification>() { @Override public void invoke(NSNotification a) { NSDictionary<?, ?> userInfo = a.getUserInfo(); AVAudioSessionSilenceSecondaryAudioHintType type = null; if (userInfo.containsKey(SilenceSecondaryAudioHintTypeKey())) { NSNumber val = (NSNumber)userInfo.get(SilenceSecondaryAudioHintTypeKey()); type = AVAudioSessionSilenceSecondaryAudioHintType.valueOf(val.intValue()); } block.invoke(type); } }); } }
this.platform = platform; session = AVAudioSession.getSharedInstance(); try { session.setActive(true, AVAudioSessionSetActiveOptions.None); } catch (NSErrorException nse) { platform.log().warn("Unable to initialize audio session", nse);
/** * @since Available in iOS 6.0 and later. */ public boolean setCategory(AVAudioSessionCategory category, AVAudioSessionCategoryOptions options) throws NSErrorException { NSError.NSErrorPtr ptr = new NSError.NSErrorPtr(); boolean result = setCategory(category, options, ptr); if (ptr.get() != null) { throw new NSErrorException(ptr.get()); } return result; } /**
@Override public void invoke(NSNotification a) { NSDictionary<?, ?> userInfo = a.getUserInfo(); AVAudioSessionSilenceSecondaryAudioHintType type = null; if (userInfo.containsKey(SilenceSecondaryAudioHintTypeKey())) { NSNumber val = (NSNumber)userInfo.get(SilenceSecondaryAudioHintTypeKey()); type = AVAudioSessionSilenceSecondaryAudioHintType.valueOf(val.intValue()); } block.invoke(type); } });
/** * @since Available in iOS 6.0 and later. */ public static NSObject observeMediaServicesWereReset(final Runnable block) { return NSNotificationCenter.getDefaultCenter().addObserver(MediaServicesWereResetNotification(), null, NSOperationQueue.getMainQueue(), new VoidBlock1<NSNotification>() { @Override public void invoke(NSNotification a) { block.run(); } }); } /**
/** * @since Available in iOS 6.0 and later. */ public boolean overrideOutputAudioPort(AVAudioSessionPortOverride portOverride) throws NSErrorException { NSError.NSErrorPtr ptr = new NSError.NSErrorPtr(); boolean result = overrideOutputAudioPort(portOverride, ptr); if (ptr.get() != null) { throw new NSErrorException(ptr.get()); } return result; } /**
/** * @since Available in iOS 6.0 and later. */ public boolean setInputDataSource(AVAudioSessionDataSourceDescription dataSource) throws NSErrorException { NSError.NSErrorPtr ptr = new NSError.NSErrorPtr(); boolean result = setInputDataSource(dataSource, ptr); if (ptr.get() != null) { throw new NSErrorException(ptr.get()); } return result; } /**
/** * @since Available in iOS 6.0 and later. */ public static NSObject observeRouteChange(final VoidBlock1<AVAudioSessionRouteChangeNotification> block) { return NSNotificationCenter.getDefaultCenter().addObserver(RouteChangeNotification(), null, NSOperationQueue.getMainQueue(), new VoidBlock1<NSNotification>() { @Override public void invoke(NSNotification a) { NSDictionary<?, ?> userInfo = a.getUserInfo(); AVAudioSessionRouteChangeNotification data = null; if (userInfo != null) { data = new AVAudioSessionRouteChangeNotification(userInfo); } block.invoke(data); } }); } /**
/** * @since Available in iOS 8.0 and later. */ public static NSObject observeSilenceSecondaryAudioHint(final VoidBlock1<AVAudioSessionSilenceSecondaryAudioHintType> block) { return NSNotificationCenter.getDefaultCenter().addObserver(SilenceSecondaryAudioHintNotification(), null, NSOperationQueue.getMainQueue(), new VoidBlock1<NSNotification>() { @Override public void invoke(NSNotification a) { NSDictionary<?, ?> userInfo = a.getUserInfo(); AVAudioSessionSilenceSecondaryAudioHintType type = null; if (userInfo.containsKey(SilenceSecondaryAudioHintTypeKey())) { NSNumber val = (NSNumber)userInfo.get(SilenceSecondaryAudioHintTypeKey()); type = AVAudioSessionSilenceSecondaryAudioHintType.valueOf(val.intValue()); } block.invoke(type); } }); } }
/** * @since Available in iOS 6.0 and later. */ public boolean setActive(boolean active, AVAudioSessionSetActiveOptions options) throws NSErrorException { NSError.NSErrorPtr ptr = new NSError.NSErrorPtr(); boolean result = setActive(active, options, ptr); if (ptr.get() != null) { throw new NSErrorException(ptr.get()); } return result; } /**