Prechádzať zdrojové kódy

vpc: add APIs to detect an active playback session and if it is audio-only

Felix Paul Kühne 10 rokov pred
rodič
commit
c36baa3b7f

+ 3 - 1
Sources/VLCPlaybackController.h

@@ -52,7 +52,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
 @property (nonatomic, retain) VLCMediaList *mediaList;
 @property (nonatomic, readwrite) int itemInMediaListToBePlayedFirst;
 
-/* returns nil if currenlty plaing item is not a MLFile, e.g. a url */
+/* returns nil if currently playing item is not a MLFile, e.g. a url */
 @property (nonatomic, strong, readonly) MLFile *currentlyPlayingMediaFile;
 
 @property (nonatomic, weak) id<VLCPlaybackControllerDelegate> delegate;
@@ -64,6 +64,8 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
 @property (nonatomic, readwrite) float playbackRate;
 @property (nonatomic, readonly) BOOL currentMediaHasChapters;
 @property (nonatomic, readonly) BOOL currentMediaHasTrackToChooseFrom;
+@property (nonatomic, readonly) BOOL activePlaybackSession;
+@property (nonatomic, readonly) BOOL audioOnlyPlaybackSession;
 
 + (VLCPlaybackController *)sharedInstance;
 

+ 16 - 0
Sources/VLCPlaybackController.m

@@ -23,6 +23,8 @@
 #import <MediaPlayer/MediaPlayer.h>
 #import "VLCThumbnailsCache.h"
 #import <WatchKit/WatchKit.h>
+#import "VLCAppDelegate.h"
+#import "VLCPlaylistViewController.h"
 
 @interface VLCPlaybackController () <AVAudioSessionDelegate, VLCMediaPlayerDelegate, VLCMediaDelegate>
 {
@@ -332,6 +334,7 @@
         _mediaPlayer.position = lastPosition;
 
     [self subscribeRemoteCommands];
+    [[(VLCAppDelegate *)[UIApplication sharedApplication].delegate playlistViewController] displayMiniPlaybackViewIfNeeded];
 
     _playerIsSetup = YES;
 }
@@ -451,6 +454,16 @@
     return [[_mediaPlayer audioTrackIndexes] count] > 2 || [[_mediaPlayer videoSubTitlesIndexes] count] > 1;
 }
 
+- (BOOL)activePlaybackSession
+{
+    return _mediaPlayer != nil;
+}
+
+- (BOOL)audioOnlyPlaybackSession
+{
+    return _mediaIsAudioOnly;
+}
+
 - (float)playbackRate
 {
     float f_rate = _mediaPlayer.rate;
@@ -594,6 +607,9 @@
 - (void)setVideoOutputView:(UIView *)videoOutputView
 {
     if (videoOutputView) {
+        if ([_actualVideoOutputView superview] != nil)
+            [_actualVideoOutputView removeFromSuperview];
+
         _mediaPlayer.currentVideoTrackIndex = 0;
         _actualVideoOutputView.frame = (CGRect){CGPointZero, videoOutputView.frame.size};
         [_actualVideoOutputView layoutSubviews];