[Mod] プレイリストの選択状態を再生位置に追随させるようにした
@@ -22,6 +22,7 @@ | ||
22 | 22 | |
23 | 23 | XspfQTMovieLoader *_loader; |
24 | 24 | BOOL _didJoin; |
25 | + BOOL ignoreChangeTrackEvent; | |
25 | 26 | } |
26 | 27 | |
27 | 28 | @property (retain) HMXSPFComponent *playlist; |
@@ -204,6 +204,7 @@ | ||
204 | 204 | { |
205 | 205 | if([keyPath isEqualToString:XspfQTCurrentTrackKey]) { |
206 | 206 | if(self.didJoin) { |
207 | + if(ignoreChangeTrackEvent) return; | |
207 | 208 | id number = [change objectForKey:NSKeyValueChangeNewKey]; |
208 | 209 | [self moveToStartPointNuber:number]; |
209 | 210 | [self.playingMovie play]; |
@@ -234,22 +235,32 @@ | ||
234 | 235 | // call from XspfQTMovieTimer. |
235 | 236 | - (void)fire |
236 | 237 | { |
237 | - | |
238 | - // not implementation | |
239 | - // TODO: Must implement | |
240 | 238 | // 現在のdurationを取得 |
239 | + QTTime duration = [self.playingMovie currentTime]; | |
241 | 240 | |
242 | 241 | // 選択トラックを取得 |
242 | + HMXSPFComponent *currentTrack = self.trackList.currentTrack; | |
243 | 243 | |
244 | 244 | // 選択トラックが再生中か? |
245 | + // durationに合うトラックを取得 | |
246 | + NSUInteger index = [self.trackList indexOfChild:currentTrack]; | |
247 | + NSUInteger playingIndex = NSNotFound; | |
248 | + | |
249 | + NSUInteger i = 0; | |
250 | + for(id time in durations) { | |
251 | + QTTime qtTime = [time QTTimeValue]; | |
252 | + if(QTTimeCompare(qtTime, duration) == NSOrderedDescending) { | |
253 | + playingIndex = i - 1; | |
254 | + break; | |
255 | + } | |
256 | + i++; | |
257 | + } | |
245 | 258 | // 再生中ならreturn |
259 | + if(index == playingIndex) return; | |
246 | 260 | |
247 | - // durationに合うトラックを取得 | |
248 | - // [[_playlist childAtIndex:0] removeObserver:self forKeyPath:XspfQTCurrentTrackKey]; | |
249 | - // [track select] | |
250 | -// [[_playlist childAtIndex:0] addObserver:self | |
251 | -// forKeyPath:XspfQTCurrentTrackKey | |
252 | -// options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld | |
253 | -// context:NULL]; | |
261 | + // 再生中トラックを選択 | |
262 | + ignoreChangeTrackEvent = YES; | |
263 | + self.trackList.selectionIndex = playingIndex; | |
264 | + ignoreChangeTrackEvent = NO; | |
254 | 265 | } |
255 | 266 | @end |