소스 검색

VLCMediaListPlayer: deprecate -playItemAtIndex and add thread-safe replacement

Felix Paul Kühne 9 년 전
부모
커밋
2143e4d79e
3개의 변경된 파일24개의 추가작업 그리고 1개의 파일을 삭제
  1. 11 1
      Headers/Public/VLCMediaListPlayer.h
  2. 3 0
      NEWS
  3. 10 0
      Sources/VLCMediaListPlayer.m

+ 11 - 1
Headers/Public/VLCMediaListPlayer.h

@@ -65,7 +65,17 @@ typedef NS_ENUM(NSInteger, VLCRepeatMode) {
  */
 @property (NS_NONATOMIC_IOSONLY, readonly) BOOL next;
 @property (NS_NONATOMIC_IOSONLY, readonly) BOOL previous;
-- (BOOL)playItemAtIndex:(int)index;
+
+/**
+ * play an item at at a given index in the media list attached to the player
+ * \note This method is not thread safe and is deprecated. Use playItemAtNumber: instead
+ */
+- (BOOL)playItemAtIndex:(int)index  __attribute__((deprecated));
+
+/**
+ * play an item at a given index in the media list attached to the player
+ */
+- (void)playItemAtNumber:(NSNumber *)index;
 
 /**
  * Playmode selection (don't repeat anything, repeat one, repeat all)

+ 3 - 0
NEWS

@@ -22,6 +22,7 @@ New APIs:
 - VLCMediaListPlayer
   - added selectors: initWithDrawable:
                      initWithOptions:andDrawable:
+                     playItemAtNumber:
 
 - VLCMediaPlayer
   - added properties: titleDescriptions, indexOfLongestTitle, numberOfTitles,
@@ -62,6 +63,8 @@ Deprecated APIs:
   - availableMediaDiscoverer, localizedName
 - VLCMediaPlayer
   - titles, chaptersForTitleIndex:, countOfTitles, framesPerSecond, openVideoSubTitlesFromFile:
+- VLCMediaListPlayer
+  - playItemAtIndex
 
 Removed APIs:
 - VLCMedia:

+ 10 - 0
Sources/VLCMediaListPlayer.m

@@ -177,6 +177,16 @@
     return libvlc_media_list_player_play_item_at_index(instance, index) == 0 ? YES : NO;
 }
 
+- (void)playItemAtNumber:(NSNumber *)index
+{
+    if ([NSThread isMainThread]) {
+        [self performSelectorInBackground:@selector(playItemAtNumber:) withObject:index];
+        return;
+    }
+
+    libvlc_media_list_player_play_item_at_index(instance, [index intValue]);
+}
+
 - (void)setRepeatMode:(VLCRepeatMode)repeatMode
 {
     libvlc_playback_mode_t mode;