Explorar o código

media player: add convience API to get the number of media tracks

(cherry picked from commit 33f96d81d3913360024b6f005208df6c00d584e0)
Felix Paul Kühne %!s(int64=10) %!d(string=hai) anos
pai
achega
8cab30f52f
Modificáronse 3 ficheiros con 40 adicións e 0 borrados
  1. 18 0
      Headers/Public/VLCMediaPlayer.h
  2. 7 0
      NEWS
  3. 15 0
      Sources/VLCMediaPlayer.m

+ 18 - 0
Headers/Public/VLCMediaPlayer.h

@@ -282,6 +282,12 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
 @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoTrackIndexes;
 
 /**
+ * returns the number of video tracks available in the current media
+ * \return number of tracks
+ */
+@property (NS_NONATOMIC_IOSONLY, readonly) int numberOfVideoTracks;
+
+/**
  * Return the video tracks
  *
  * It includes the disabled fake track at index 0.
@@ -311,6 +317,12 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
 @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *videoSubTitlesIndexes;
 
 /**
+ * returns the number of SPU tracks available in the current media
+ * \return number of tracks
+ */
+@property (NS_NONATOMIC_IOSONLY, readonly) int numberOfSubtitlesTracks;
+
+/**
  * Return the video subtitle tracks
  * \note this property is deprecated. use (NSArray *)videoSubtitleNames instead.
  * It includes the disabled fake track at index 0.
@@ -381,6 +393,12 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
 @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *audioTrackIndexes;
 
 /**
+ * returns the number of audio tracks available in the current media
+ * \return number of tracks
+ */
+@property (NS_NONATOMIC_IOSONLY, readonly) int numberOfAudioTracks;
+
+/**
  * Return the audio tracks
  *
  * It includes the "Disable" fake track at index 0.

+ 7 - 0
NEWS

@@ -1,3 +1,10 @@
+Version 2.2.2:
+--------------
+New APIs:
+- VLCMediaPlayer
+  - added properties: numberOfVideoTracks, numberOfSubtitlesTracks
+    numberOfAudioTracks
+
 Version 2.2.0:
 --------------
 

+ 15 - 0
Sources/VLCMediaPlayer.m

@@ -341,6 +341,11 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
     return [NSArray arrayWithArray: tempArray];
 }
 
+- (int)numberOfVideoTracks
+{
+    return libvlc_video_get_track_count(_playerInstance);
+}
+
 #pragma mark -
 #pragma mark Subtitles
 
@@ -393,6 +398,11 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
     return [NSArray arrayWithArray: tempArray];
 }
 
+- (int)numberOfSubtitlesTracks
+{
+    return libvlc_video_get_spu_count(_playerInstance);
+}
+
 - (BOOL)openVideoSubTitlesFromFile:(NSString *)path
 {
     return libvlc_video_set_subtitle_file(_playerInstance, [path UTF8String]);
@@ -769,6 +779,11 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
     return [NSArray arrayWithArray: tempArray];
 }
 
+- (int)numberOfAudioTracks
+{
+    return libvlc_audio_get_track_count(_playerInstance);
+}
+
 - (void)setAudioChannel:(int)value
 {
     libvlc_audio_set_channel(_playerInstance, value);