我正在寫一個iPod應用程序更換,在我的「正在播放」視圖中,我希望有一個像iPod應用程序一樣的進度指示器,它顯示當前位置,並允許用戶拖動以更改播放位置。如何創建音樂進度指示器/控件,如iPod應用程序?
我該怎麼做?
我使用UISlider和UIProgressView嗎?
我正在寫一個iPod應用程序更換,在我的「正在播放」視圖中,我希望有一個像iPod應用程序一樣的進度指示器,它顯示當前位置,並允許用戶拖動以更改播放位置。如何創建音樂進度指示器/控件,如iPod應用程序?
我該怎麼做?
我使用UISlider和UIProgressView嗎?
在這裏和那裏省略了一些東西,但它足以在堵塞
// .h
IBOutlet UISlider *progressSlider;
NSTimer *progressTimer;
@property (nonatomic, retain) UISlider *progressSlider;
@property (nonatomic, retain) NSTimer *progressTimer;
- (void)updateSlider;
- (void)resetTimer:(NSTimer *)timer;
// .m
// synthesize variables
- (void)handleNowPlayingItemChanged:(id)notification {
NSNumber *duration = [item valueForProperty:MPMediaItemPropertyPlaybackDuration];
float totalTime = [duration floatValue];
progressSlider.maximumValue = totalTime;
}
- (void)updateSlider {
[progressSlider setValue:musicPlayer.currentPlaybackTime animated:YES];
}
- (void)resetTimer:(NSTimer *)timer {
[progressTimer invalidate];
progressTimer = nil;
progressTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self
selector:@selector(updateSlider)
userInfo:nil repeats:YES];
}
// init and release methods (together at the bottom with view controls
// (like viewDidLoad) for convenience)
//
// don't forget to register for notifications
@end
如果你想有一個示例應用程序。(唯一設備,iPod的庫),我可以寫一個,但它不會是比這更多。
謝謝** soooo **。這真的很有幫助。 – 2011-06-24 04:22:22
終於實現了這一點。 – 2013-04-24 22:25:54
一個UISlider就夠了。我也想試試這個,所以我會盡快發佈一個答案。 – Thromordyn 2011-06-21 13:46:58
還沒有運氣。主要是因爲我一直在研究設置而不是軌道掃描。明天我會爲此工作。 – Thromordyn 2011-06-21 20:59:12
我真的很感謝你給Thromordyn提供的任何幫助。 – 2011-06-21 22:03:37