lock screen hack

Post on 29-Nov-2014

1.450 Views

Category:

Technology

9 Downloads

Preview:

Click to see full reader

DESCRIPTION

Conference With Developers2 の LT で話した資料

TRANSCRIPT

ロック画面ハック してみた

田村 航弥 @tamotamago

田村 航弥 @tamotamago2014年 02 月 株式会社ミクシィを退職しました

mixi for iPhone PoPolly

初級~中級者向け 電子書籍 only 2 月発売予定

ロックスクリーンハックon Android

PoPolly for Android

youtube 動画

iOS でごりってみた

youtube 動画

iOS でごりってみたBackGround で動きましょう

音楽ボタンのイベント を拾いましょう

アートワークを いじりましょう

BackGround で動きましょう

音楽ボタンのイベント を拾いましょう

アートワークをいじりましょう

Background Modes

Background Modes

MPMoviePlayerController

MPMoviePlayerController• 無音 MP3 をエンドレスループ

_moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:[[NSBundle mainBundle] URLForResource:@"Silent3sec" withExtension:@“mp3"]]; !_moviePlayerController.repeatMode = MPMovieRepeatModeOne;

AVAudioSession

AVAudioSession• バックグラウンドに移ったときの振る舞いを設定

[[AVAudioSession sharedInstance] setDelegate: self]; NSError *error; // Initialize the AVAudioSession here. if (![[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error]) { // Handle the error here. NSLog(@"Audio Session error %@, %@", error, [error userInfo]); }

AVAudioSessionCategoryPlayback : ロックスクリーンに行っても出力のみし続ける

BackGround 動きましょう

音楽ボタンのイベント を拾いましょう

アートワークをいじりましょう

RemoteControlEvents

RemoteControlEvents

これ

RemoteControlEvents• イベント受け取ります宣言

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

RemoteControlEvents• イベント受け取り- (void)remoteControlReceivedWithEvent:(UIEvent *)event { switch (event.subtype) { case UIEventSubtypeRemoteControlPlay: case UIEventSubtypeRemoteControlPause: case UIEventSubtypeRemoteControlStop: case UIEventSubtypeRemoteControlTogglePlayPause: NSLog(@"pushed center button"); break; case UIEventSubtypeRemoteControlNextTrack: NSLog(@"pushed right button"); break; case UIEventSubtypeRemoteControlPreviousTrack: NSLog(@"pushed left button"); break; default: break; } }

RemoteControlEvents

// for UIEventTypeRemoteControl, available in iOS 4.0 UIEventSubtypeRemoteControlPlay = 100, UIEventSubtypeRemoteControlPause = 101, UIEventSubtypeRemoteControlStop = 102, UIEventSubtypeRemoteControlTogglePlayPause = 103, UIEventSubtypeRemoteControlNextTrack = 104, UIEventSubtypeRemoteControlPreviousTrack = 105, UIEventSubtypeRemoteControlBeginSeekingBackward = 106, UIEventSubtypeRemoteControlEndSeekingBackward = 107, UIEventSubtypeRemoteControlBeginSeekingForward = 108, UIEventSubtypeRemoteControlEndSeekingForward = 109,

BackGround 動きましょう

音楽ボタンのイベント を拾いましょう

アートワークを いじりましょう

MPNowPlayingInfoCenter

MPNowPlayingInfoCenter• Now Playing な Information をセットできる

MPMediaItemArtwork *artwork = [[MPMediaItemArtwork alloc] initWithImage:[UIImage imageNamed:@"question"]]; // set NowPlaying. Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter"); if (playingInfoCenter) { MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter]; center.nowPlayingInfo = @{}; ! NSDictionary *songInfo = @{MPMediaItemPropertyTitle:@"どっちがすき?", MPMediaItemPropertyArtwork:artwork, MPMediaItemPropertyPlaybackDuration:[NSNumber numberWithDouble:20.0], MPNowPlayingInfoPropertyElapsedPlaybackTime:[NSNumber numberWithDouble:0.0], MPNowPlayingInfoPropertyPlaybackRate:[NSNumber numberWithDouble:1.0] }; center.nowPlayingInfo = songInfo; }

userInfo の key はMPNowPlayingInfoCenter.h に書いてあります

ボタンが押されたらアートワークを変更する

みなさん何か忘れていませんか?

Apple Review Guideline

Apple Review Guideline

• 2.16 Multitasking Apps may only use background services for their intended purposes: VoIP, audio playback, location, task completion, local notifications, etc.

結び

結び作る前に(レビューガイドラインを)読む!

top related