소스 검색

VLCMedia: add a selector to trigger synchronous parsing and fix tracksInformation

Felix Paul Kühne 12 년 전
부모
커밋
4585ba99e3
2개의 변경된 파일13개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 0
      Headers/Public/VLCMedia.h
  2. 7 2
      Sources/VLCMedia.m

+ 6 - 0
Headers/Public/VLCMedia.h

@@ -382,6 +382,12 @@ extern NSString *VLCMediaTracksInformationTypeUnknown;
 - (void)parse;
 
 /**
+ * Trigger a synchronous parsing of the media
+ * the selector won't return until parsing finished
+ */
+- (void)synchronousParse;
+
+/**
  * Add options to the media, that will be used to determine how
  * VLCMediaPlayer will read the media. This allow to use VLC advanced
  * reading/streaming options in a per-media basis

+ 7 - 2
Sources/VLCMedia.m

@@ -312,6 +312,12 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
         libvlc_media_parse_async(p_md);
 }
 
+- (void)synchronousParse
+{
+    if (p_md)
+        libvlc_media_parse(p_md);
+}
+
 - (void)addOptions:(NSDictionary*)options
 {
     if (p_md) {
@@ -549,8 +555,7 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
 
 - (NSArray *)tracksInformation
 {
-    // Trigger parsing if needed
-    [self parseIfNeeded];
+    [self synchronousParse];
 
     libvlc_media_track_t **tracksInfo;
     unsigned int count = libvlc_media_tracks_get(p_md, &tracksInfo);