//宣告一個Handler
Handler myHandler = new Handler();
//幾秒後(delaySec)呼叫runTimerStop這個Runnable,再由這個Runnable去呼叫你想要做的事情
myHandler.postDelayed(runTimerStop,delaySec*1000);
//移除
myHandler.removeCallbacks(runTimerStop);
//主體
private Runnable runTimerStop = new Runnable()
{
@Override
public void run()
{
//想要做的事情
}
};
2013年4月26日 星期五
[Android]設定delay幾秒後,執行某函式的方法。
2013年4月16日 星期二
[Other]整理一些素材,提升網頁、App質感
剛開始整理,所以應該會很少,只是做個紀錄。
1.各式各樣的底圖,可以來這邊尋找。
subtle patterns: http://subtlepatterns.com/
2.idesign (各式各樣的背景圖)
http://idesigniphone.com
3.make app icon ( 製作符合iOS 或者Android的icon,給他一張1024X1024就可以產生所有的圖)
http://makeappicon.com
4.App Icon Template (提供psd的樣板可以修改,如果你會PS的話)
http://appicontemplate.com/ios8
1.各式各樣的底圖,可以來這邊尋找。
subtle patterns: http://subtlepatterns.com/
2.idesign (各式各樣的背景圖)
http://idesigniphone.com
3.make app icon ( 製作符合iOS 或者Android的icon,給他一張1024X1024就可以產生所有的圖)
http://makeappicon.com
4.App Icon Template (提供psd的樣板可以修改,如果你會PS的話)
http://appicontemplate.com/ios8
2013年4月10日 星期三
[iOS]使用MPMoviePlayerViewController來播放mp4,在iOS 6上無法順利播放問題解決方法。
在ios5的版本中,使用以下函式就可以順利播放mp4,但是這個函式在ios6卻會crash掉,最後終於找到在ios5與ios6可以使用的方法,詳情請參考該網址
原本在ios5上的寫法如下:(ios6將無法使用)
- (void)openMP4:(NSString*)s_url
{
object:playerVC.moviePlayer];
name:MPMoviePlayerPlaybackDidFinishNotification
object:playerVC.moviePlayer];
[playerVC.moviePlayer play];
}
- (void)movieFinishedCallback:(NSNotification*)aNotification
{
MPMoviePlayerController *moviePlayer = [aNotification object];
object:moviePlayer];
}
原本在ios5上的寫法如下:(ios6將無法使用)
- (void)openMP4:(NSString *)s_url
{
NSURL *fileURL = [NSURL URLWithString:s_url];
[player.moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
[player.moviePlayer setFullscreen:NO];
player = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
//弹出播放器窗口
[self presentMoviePlayerViewControllerAnimated:player ];
[player.moviePlayer setMovieSourceType:MPMovieSourceTypeFile];
[player.moviePlayer prepareToPlay];
[self.view addSubview:player.view];
//播放
[player.moviePlayer play];
//增加一個觀察者
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
}
- (void) moviePlayBackDidFinish:(NSNotification*) aNotification {
//移除觀察者
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
//播放器消失
[player dismissMoviePlayerViewControllerAnimated];
player=NULL;
}
相容ios5、ios6的寫法如下(來源):
{
// Initialize the movie player view controller with a video URL string
NSURL *fileURL = [NSURL URLWithString:s_url];
MPMoviePlayerViewController *playerVC = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
// Remove the movie player view controller from the "playback did finish" notification observers
[[NSNotificationCenter defaultCenter] removeObserver:playerVC
name:MPMoviePlayerPlaybackDidFinishNotificationobject:playerVC.moviePlayer];
// Register this class as an observer instead
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinishedCallback:)name:MPMoviePlayerPlaybackDidFinishNotification
object:playerVC.moviePlayer];
// Set the modal transition style of your choice
playerVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
// Present the movie player view controller
[self presentModalViewController:playerVC animated:YES];
// Start playback
[playerVC.moviePlayer prepareToPlay];[playerVC.moviePlayer play];
}
- (void)movieFinishedCallback:(NSNotification*)aNotification
{
// Obtain the reason why the movie playback finished
NSNumber *finishReason = [[aNotification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
// Dismiss the view controller ONLY when the reason is not "playback ended"
if ([finishReason intValue] != MPMovieFinishReasonPlaybackEnded)
{MPMoviePlayerController *moviePlayer = [aNotification object];
// Remove this class from the observers
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotificationobject:moviePlayer];
// Dismiss the view controller
[self dismissModalViewControllerAnimated:YES];
}}
訂閱:
文章 (Atom)