iOSã¢ããªããããªã¥ã¼ã ãã¿ã³ãæ¼ããããã¨ãæ¤åºããæ¹æ³
ãã¾ã«ã¯iOSã¢ããªéçºãã¿ãã
ã«ã¡ã©ã¢ããªãä½ãã¨ããUIImagePickerControllerã使ãã¨ããªã¥ã¼ã ãã¿ã³ã§ã·ã£ãã¿ã¼ãåããã®ã§ãããAVCaptureã使ã£ãå ´åã¯ãããã§ããªãã®ã§ãAVSystemController_SystemVolumeDidChangeNotificationã使ã£ã¦èªåã§ããªã¥ã¼ã ãã¿ã³ãæ¼ããããã¨ãæ¤åºããå¿ è¦ãããã¾ãã
ã°ã°ãã¨ããããã³ã¼ããåºã¦ããã®ã§ããããã®ã¾ã¾ããªã¥ã¼ã ãå¤ãã£ã¦ãã¾ã£ãããæ¥æ¬ã®iPhoneã®æ®å½±æã®é³éå¤åãæ¤åºããã¦ãã¾ã£ãããå°ã試è¡é¯èª¤ãå¿ è¦ã§ããã
ã¨ããããã§ã以ä¸ãã³ã¼ãã§ãã
2012.11.9追è¨
è¨è¿°ãæãã¦ããé¨åã¨ããã¯ã°ã©ã¦ã³ãå¨ãã§ã®ä¸å
·åããã£ãã®ã§ã³ã¼ããä¿®æ£ãã¾ããã
地図絶一門ã®[twitter:@TeamMOSA2]ããããææãããã¨ããããã¾ããã
//.h float initialVolume; //.m #import <MediaPlayer/MediaPlayer.h> #import <AudioToolbox/AudioToolbox.h> - (void)viewDidLoad { [self setVolumeNotification]; //MPVolumeViewããªãã¹ã¯ãªã¼ã³ã«ã CGRect frame = CGRectMake(-100, -100, 100, 100); MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:frame]; [volumeView sizeToFit]; [self.view addSubview:volumeView]; AudioSessionInitialize(NULL, NULL, NULL, NULL); UInt32 category = kAudioSessionCategory_AmbientSound; AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(category), &category); AudioSessionSetActive(true); initialVolume = [MPMusicPlayerController applicationMusicPlayer].volume; NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; [center addObserver:self selector:@selector(applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil]; [center addObserver:self selector:@selector(applicationWillEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:nil]; } - (void)setVolumeNotification { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeChanged:) name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil]; } - (void)volumeChanged:(NSNotification *)notification{ //æ示çã«ããªã¥ã¼ã å¤æ´ããããæã®ã¿ if ([[[notification userInfo]objectForKey:@"AVSystemController_AudioVolumeChangeReasonNotificationParameter"]isEqualToString:@"ExplicitVolumeChange"]) { //ããã§æ®å½±ããããªãã¡ã½ããçãå¼ã¶ //ä¸æ¦NSNotificationCenterããAVSystemController_SystemVolumeDidChangeNotificationãå¤ãã¦ãããªã¥ã¼ã ãå ã«æ»ã [[NSNotificationCenter defaultCenter]removeObserver:self name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil]; [MPMusicPlayerController applicationMusicPlayer].volume = initialVolume; [self performSelector:@selector(setVolumeNotification) withObject:nil afterDelay:0.2]; } } - (void)applicationDidEnterBackground:(NSNotification *)notification { [[NSNotificationCenter defaultCenter]removeObserver:self name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil]; AudioSessionSetActive(false); } - (void)applicationWillEnterForeground:(NSNotification *)notification { initialVolume = [MPMusicPlayerController applicationMusicPlayer].volume; [self setVolumeNotification]; AudioSessionSetActive(true); }