Commit 0f8bdb39 authored by Carola Nitz's avatar Carola Nitz

VLCPlaybackController: Decouple Metadata and controlcenter code from playback

parent ce03cb9c
Pipeline #216 failed with stage
in 0 seconds
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
*****************************************************************************/ *****************************************************************************/
#import "VLCPlaybackInfoMediaInfoTVViewController.h" #import "VLCPlaybackInfoMediaInfoTVViewController.h"
#import "VLCMetadata.h"
@interface VLCPlaybackInfoMediaInfoTVViewController () @interface VLCPlaybackInfoMediaInfoTVViewController ()
...@@ -46,7 +47,7 @@ ...@@ -46,7 +47,7 @@
- (void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated
{ {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
self.titleLabel.text = vpc.mediaTitle; self.titleLabel.text = vpc.metadata.title;
VLCMediaPlayer *player = vpc.mediaPlayer; VLCMediaPlayer *player = vpc.mediaPlayer;
VLCMedia *media = player.media; VLCMedia *media = player.media;
...@@ -104,7 +105,7 @@ ...@@ -104,7 +105,7 @@
NSLocalizedString(@"DURATION", nil), NSLocalizedString(@"DURATION", nil),
media.length.verboseStringValue]; media.length.verboseStringValue];
} }
if (!vpc.audioOnlyPlaybackSession) { if (!vpc.metadata.isAudioOnly) {
metaDataString = [metaDataString stringByAppendingFormat:@"%@: %@ (%@)\n", metaDataString = [metaDataString stringByAppendingFormat:@"%@: %@ (%@)\n",
NSLocalizedString(@"VIDEO_DIMENSIONS", nil), NSLocalizedString(@"VIDEO_DIMENSIONS", nil),
[NSString stringWithFormat:NSLocalizedString(@"FORMAT_VIDEO_DIMENSIONS", nil), [NSString stringWithFormat:NSLocalizedString(@"FORMAT_VIDEO_DIMENSIONS", nil),
...@@ -144,7 +145,7 @@ ...@@ -144,7 +145,7 @@
- (void)updateMediaTitle - (void)updateMediaTitle
{ {
self.titleLabel.text = [VLCPlaybackController sharedInstance].mediaTitle; self.titleLabel.text = [VLCPlaybackController sharedInstance].metadata.title;
} }
@end @end
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#import "VLCPlaybackInfoSubtitlesFetcherViewController.h" #import "VLCPlaybackInfoSubtitlesFetcherViewController.h"
#import "MetadataFetcherKit.h" #import "MetadataFetcherKit.h"
#import "NSString+Locale.h" #import "NSString+Locale.h"
#import "VLCMetadata.h"
#define SPUDownloadReUseIdentifier @"SPUDownloadReUseIdentifier" #define SPUDownloadReUseIdentifier @"SPUDownloadReUseIdentifier"
#define SPUDownloadHeaderReUseIdentifier @"SPUDownloadHeaderReUseIdentifier" #define SPUDownloadHeaderReUseIdentifier @"SPUDownloadHeaderReUseIdentifier"
...@@ -95,7 +96,7 @@ ...@@ -95,7 +96,7 @@
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
_osoFetcher.subtitleLanguageId = [defaults stringForKey:kVLCSettingLastUsedSubtitlesSearchLanguage]; _osoFetcher.subtitleLanguageId = [defaults stringForKey:kVLCSettingLastUsedSubtitlesSearchLanguage];
[_osoFetcher searchForSubtitlesWithQuery:vpc.mediaTitle]; [_osoFetcher searchForSubtitlesWithQuery:vpc.metadata.title];
} }
- (void)MDFOSOFetcher:(MDFOSOFetcher *)aFetcher didFindSubtitles:(NSArray<MDFSubtitleItem *> *)subtitles forSearchRequest:(NSString *)searchRequest - (void)MDFOSOFetcher:(MDFOSOFetcher *)aFetcher didFindSubtitles:(NSArray<MDFSubtitleItem *> *)subtitles forSearchRequest:(NSString *)searchRequest
......
//
// VLCMediaPlayer + Metadata.h
// VLC
//
// Created by Carola Nitz on 9/27/17.
// Copyright © 2017 VideoLAN. All rights reserved.
//
@interface VLCMetaData: NSObject
@property(readwrite, copy) NSString *title;
@property(readwrite) UIImage *artworkImage;
@property(readwrite, copy) NSString *artist;
@property(readwrite, copy) NSString *albumName;
@property(readwrite, assign) BOOL isAudioOnly;
@property(readwrite) NSNumber *trackNumber;
@property(readwrite) NSNumber *playbackDuration;
@property(readwrite) NSNumber *elapsedPlaybackTime;
@property(readwrite) NSNumber *playbackRate;
- (void)updateMetadataFromMediaPlayer:(VLCMediaPlayer *)mediaPlayer;
@end
//
// VLCMediaPlayer + Metadata.m
// VLC
//
// Created by Carola Nitz on 9/27/17.
// Copyright © 2017 VideoLAN. All rights reserved.
//
#import "VLCMetadata.h"
#import <MediaPlayer/MediaPlayer.h>
#import "VLCPlaybackController.h"
#if TARGET_OS_IOS
#import "VLCKeychainCoordinator.h"
#import "VLCThumbnailsCache.h"
#endif
@implementation VLCMetaData
- (instancetype)init
{
self = [super init];
if (self) {
}
return self;
}
- (void)updateMetadataFromMediaPlayer:(VLCMediaPlayer *)mediaPlayer;
{
#if TARGET_OS_IOS
MLFile *item;
if ([VLCPlaybackController sharedInstance].mediaList) {
NSArray *matches = [MLFile fileForURL:mediaPlayer.media.url];
item = matches.firstObject;
}
if (item) {
if (item.isAlbumTrack) {
self.title = item.albumTrack.title;
self.artist = item.albumTrack.artist;
self.albumName = item.albumTrack.album.name;
} else
self.title = item.title;
/* MLKit knows better than us if this thing is audio only or not */
self.isAudioOnly = [item isSupportedAudioFile];
} else {
#endif
NSDictionary * metaDict = mediaPlayer.media.metaDictionary;
if (metaDict) {
self.title = metaDict[VLCMetaInformationNowPlaying] ? metaDict[VLCMetaInformationNowPlaying] : metaDict[VLCMetaInformationTitle];
self.artist = metaDict[VLCMetaInformationArtist];
self.albumName = metaDict[VLCMetaInformationAlbum];
self.trackNumber = metaDict[VLCMetaInformationTrackNumber];
}
#if TARGET_OS_IOS
}
#endif
if (!self.isAudioOnly) {
/* either what we are playing is not a file known to MLKit or
* MLKit fails to acknowledge that it is audio-only.
* Either way, do a more expensive check to see if it is really audio-only */
NSArray *tracks = mediaPlayer.media.tracksInformation;
NSUInteger trackCount = tracks.count;
self.isAudioOnly = YES;
for (NSUInteger x = 0 ; x < trackCount; x++) {
if ([[tracks[x] objectForKey:VLCMediaTracksInformationType] isEqualToString:VLCMediaTracksInformationTypeVideo]) {
self.isAudioOnly = NO;
break;
}
}
}
if (self.isAudioOnly) {
#if TARGET_OS_IOS
self.artworkImage = [VLCThumbnailsCache thumbnailForManagedObject:item];
if (self.artworkImage) {
if (self.artist)
self.title = [self.title stringByAppendingFormat:@" — %@", self.artist];
if (self.albumName)
self.title = [self.title stringByAppendingFormat:@" — %@", self.albumName];
}
#endif
if (self.title.length < 1)
self.title = [[mediaPlayer.media url] lastPathComponent];
}
self.playbackDuration = @(mediaPlayer.media.length.intValue / 1000.);
self.playbackRate = @(mediaPlayer.rate);
self.elapsedPlaybackTime = @(mediaPlayer.media.length.intValue / 1000.);
[[NSNotificationCenter defaultCenter] postNotificationName:VLCPlaybackControllerPlaybackMetadataDidChange object:self];
#if TARGET_OS_IOS
if ([[VLCKeychainCoordinator defaultCoordinator] passcodeLockEnabled]) return;
#endif
[self populateInfoCenterFromMetadata];
}
- (void)populateInfoCenterFromMetadata
{
NSMutableDictionary *currentlyPlayingTrackInfo = [NSMutableDictionary dictionary];
currentlyPlayingTrackInfo[MPMediaItemPropertyPlaybackDuration] = self.playbackDuration;
currentlyPlayingTrackInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = self.elapsedPlaybackTime;
currentlyPlayingTrackInfo[MPNowPlayingInfoPropertyPlaybackRate] = self.playbackRate;
currentlyPlayingTrackInfo[MPMediaItemPropertyTitle] = self.title;
currentlyPlayingTrackInfo[MPMediaItemPropertyArtist] = self.artist;
currentlyPlayingTrackInfo[MPMediaItemPropertyAlbumTitle] = self.albumName;
if ([self.trackNumber intValue] > 0)
currentlyPlayingTrackInfo[MPMediaItemPropertyAlbumTrackNumber] = self.trackNumber;
#if TARGET_OS_IOS
if (self.artworkImage) {
MPMediaItemArtwork *mpartwork = [[MPMediaItemArtwork alloc] initWithImage:self.artworkImage];
currentlyPlayingTrackInfo[MPMediaItemPropertyArtwork] = mpartwork;
}
#endif
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = currentlyPlayingTrackInfo;
}
@end
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
*****************************************************************************/ *****************************************************************************/
#import "VLCPlayerControlWebSocket.h" #import "VLCPlayerControlWebSocket.h"
#import "VLCMetadata.h"
@implementation VLCPlayerControlWebSocket @implementation VLCPlayerControlWebSocket
...@@ -122,7 +123,7 @@ ...@@ -122,7 +123,7 @@
if (media) { if (media) {
NSURL *url = media.url; NSURL *url = media.url;
NSString *mediaTitle = vpc.mediaTitle; NSString *mediaTitle = vpc.metadata.title;
if (!mediaTitle) if (!mediaTitle)
mediaTitle = url.lastPathComponent; mediaTitle = url.lastPathComponent;
NSDictionary *mediaDict = @{ @"id" : url.absoluteString, NSDictionary *mediaDict = @{ @"id" : url.absoluteString,
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#import "NSString+SupportedMedia.h" #import "NSString+SupportedMedia.h"
#import "UIDevice+VLC.h" #import "UIDevice+VLC.h"
#import "VLCHTTPUploaderController.h" #import "VLCHTTPUploaderController.h"
#import "VLCMetaData.h"
#if TARGET_OS_IOS #if TARGET_OS_IOS
#import "VLCThumbnailsCache.h" #import "VLCThumbnailsCache.h"
...@@ -463,7 +464,7 @@ ...@@ -463,7 +464,7 @@
return [[HTTPErrorResponse alloc] initWithErrorCode:404]; return [[HTTPErrorResponse alloc] initWithErrorCode:404];
} }
NSString *mediaTitle = vpc.mediaTitle; NSString *mediaTitle = vpc.metadata.title;
if (!mediaTitle) if (!mediaTitle)
mediaTitle = @""; mediaTitle = @"";
NSDictionary *mediaDict = @{ @"id" : media.url.absoluteString, NSDictionary *mediaDict = @{ @"id" : media.url.absoluteString,
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#import "VLCMiniPlaybackView.h" #import "VLCMiniPlaybackView.h"
#import "VLCPlaybackController.h" #import "VLCPlaybackController.h"
#import "VLCPlayerDisplayController.h" #import "VLCPlayerDisplayController.h"
#import "VLCMetadata.h"
#if TARGET_OS_IOS #if TARGET_OS_IOS
#import "VLCLibraryViewController.h" #import "VLCLibraryViewController.h"
...@@ -208,16 +209,11 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -208,16 +209,11 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
[self updatePlayPauseButton]; [self updatePlayPauseButton];
} }
- (void)displayMetadataForPlaybackController:(VLCPlaybackController *)controller - (void)displayMetadataForPlaybackController:(VLCPlaybackController *)controller metadata:(VLCMetaData *)metadata
title:(NSString *)title
artwork:(UIImage *)artwork
artist:(NSString *)artist
album:(NSString *)album
audioOnly:(BOOL)audioOnly
{ {
if (audioOnly) { if (metadata.isAudioOnly) {
_artworkView.contentMode = UIViewContentModeScaleAspectFill; _artworkView.contentMode = UIViewContentModeScaleAspectFill;
_artworkView.image = artwork ? artwork : [UIImage imageNamed:@"no-artwork"]; _artworkView.image = metadata.artworkImage?: [UIImage imageNamed:@"no-artwork"];
if (_videoView) { if (_videoView) {
[_videoView removeFromSuperview]; [_videoView removeFromSuperview];
_videoView = nil; _videoView = nil;
...@@ -242,14 +238,14 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -242,14 +238,14 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
} }
NSString *metaDataString; NSString *metaDataString;
if (artist) if (metadata.artist)
metaDataString = artist; metaDataString = metadata.artist;
if (album) if (metadata.albumName)
metaDataString = [metaDataString stringByAppendingFormat:@" — %@", album]; metaDataString = [metaDataString stringByAppendingFormat:@" — %@", metadata.albumName];
if (metaDataString) if (metaDataString)
metaDataString = [metaDataString stringByAppendingFormat:@"\n%@", title]; metaDataString = [metaDataString stringByAppendingFormat:@"\n%@", metadata.title];
else else
metaDataString = title; metaDataString = metadata.title;
_metaDataLabel.text = metaDataString; _metaDataLabel.text = metaDataString;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#import "VLCMovieViewControlPanelView.h" #import "VLCMovieViewControlPanelView.h"
#import "VLCPlaybackController.h" #import "VLCPlaybackController.h"
#import "VLCMetadata.h"
@interface VLCMovieViewControlPanelView () @interface VLCMovieViewControlPanelView ()
...@@ -246,7 +247,7 @@ static const CGFloat maxCompactWidth = 420.0; ...@@ -246,7 +247,7 @@ static const CGFloat maxCompactWidth = 420.0;
[self updatePlayPauseButton]; [self updatePlayPauseButton];
self.trackSwitcherButton.hidden = !self.playbackController.currentMediaHasTrackToChooseFrom; self.trackSwitcherButton.hidden = !self.playbackController.currentMediaHasTrackToChooseFrom;
self.videoFilterButton.hidden = self.playbackController.audioOnlyPlaybackSession; self.videoFilterButton.hidden = self.playbackController.metadata.isAudioOnly;
} }
- (void)updatePlayPauseButton - (void)updatePlayPauseButton
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#import "VLCSlider.h" #import "VLCSlider.h"
#import "VLCLibraryViewController.h" #import "VLCLibraryViewController.h"
#import "VLCTrackSelectorView.h" #import "VLCTrackSelectorView.h"
#import "VLCMetadata.h"
#define FORWARD_SWIPE_DURATION 30 #define FORWARD_SWIPE_DURATION 30
#define BACKWARD_SWIPE_DURATION 10 #define BACKWARD_SWIPE_DURATION 10
...@@ -992,28 +993,23 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -992,28 +993,23 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
}]; }];
} }
- (void)displayMetadataForPlaybackController:(VLCPlaybackController *)controller - (void)displayMetadataForPlaybackController:(VLCPlaybackController *)controller metadata:(VLCMetaData *)metadata
title:(NSString *)title
artwork:(UIImage *)artwork
artist:(NSString *)artist
album:(NSString *)album
audioOnly:(BOOL)audioOnly
{ {
if (!_viewAppeared) if (!_viewAppeared)
return; return;
self.trackNameLabel.text = title; self.trackNameLabel.text = metadata.title;
self.artworkImageView.image = artwork; self.artworkImageView.image = metadata.artworkImage;
if (!artwork) { if (!metadata.artworkImage) {
self.artistNameLabel.text = artist; self.artistNameLabel.text = metadata.artist;
self.albumNameLabel.text = album; self.albumNameLabel.text = metadata.albumName;
} else } else
self.artistNameLabel.text = self.albumNameLabel.text = nil; self.artistNameLabel.text = self.albumNameLabel.text = nil;
[self hideShowAspectratioButton:audioOnly]; [self hideShowAspectratioButton:metadata.isAudioOnly];
[_controllerPanel updateButtons]; [_controllerPanel updateButtons];
_audioOnly = audioOnly; _audioOnly = metadata.isAudioOnly;
} }
- (IBAction)playPause - (IBAction)playPause
......
...@@ -22,6 +22,7 @@ extern NSString *const VLCPlaybackControllerPlaybackMetadataDidChange; ...@@ -22,6 +22,7 @@ extern NSString *const VLCPlaybackControllerPlaybackMetadataDidChange;
extern NSString *const VLCPlaybackControllerPlaybackPositionUpdated; extern NSString *const VLCPlaybackControllerPlaybackPositionUpdated;
@class VLCPlaybackController; @class VLCPlaybackController;
@class VLCMetaData;
@protocol VLCPlaybackControllerDelegate <NSObject> @protocol VLCPlaybackControllerDelegate <NSObject>
@optional @optional
...@@ -33,12 +34,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -33,12 +34,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
forPlaybackController:(VLCPlaybackController *)controller; forPlaybackController:(VLCPlaybackController *)controller;
- (void)prepareForMediaPlayback:(VLCPlaybackController *)controller; - (void)prepareForMediaPlayback:(VLCPlaybackController *)controller;
- (void)showStatusMessage:(NSString *)statusMessage forPlaybackController:(VLCPlaybackController *)controller; - (void)showStatusMessage:(NSString *)statusMessage forPlaybackController:(VLCPlaybackController *)controller;
- (void)displayMetadataForPlaybackController:(VLCPlaybackController *)controller - (void)displayMetadataForPlaybackController:(VLCPlaybackController *)controller metadata:(VLCMetaData *)metadata;
title:(NSString *)title
artwork:(UIImage *)artwork
artist:(NSString *)artist
album:(NSString *)album
audioOnly:(BOOL)audioOnly;
@end @end
...@@ -67,6 +63,8 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -67,6 +63,8 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
@property (nonatomic, weak) id<VLCPlaybackControllerDelegate> delegate; @property (nonatomic, weak) id<VLCPlaybackControllerDelegate> delegate;
@property (nonatomic, readonly) VLCMediaPlayerState mediaPlayerState; @property (nonatomic, readonly) VLCMediaPlayerState mediaPlayerState;
@property (nonatomic, readonly) VLCMetaData *metadata;
@property (nonatomic, readonly) NSInteger mediaDuration; @property (nonatomic, readonly) NSInteger mediaDuration;
@property (nonatomic, readonly) BOOL isPlaying; @property (nonatomic, readonly) BOOL isPlaying;
@property (nonatomic, readwrite) VLCRepeatMode repeatMode; @property (nonatomic, readwrite) VLCRepeatMode repeatMode;
...@@ -77,8 +75,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -77,8 +75,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
@property (nonatomic, readonly) BOOL currentMediaHasChapters; @property (nonatomic, readonly) BOOL currentMediaHasChapters;
@property (nonatomic, readonly) BOOL currentMediaHasTrackToChooseFrom; @property (nonatomic, readonly) BOOL currentMediaHasTrackToChooseFrom;
@property (nonatomic, readonly) BOOL activePlaybackSession; @property (nonatomic, readonly) BOOL activePlaybackSession;
@property (nonatomic, readonly) BOOL audioOnlyPlaybackSession;
@property (nonatomic, readonly) NSString *mediaTitle;
@property (nonatomic, readwrite) BOOL fullscreenSessionRequested; @property (nonatomic, readwrite) BOOL fullscreenSessionRequested;
@property (nonatomic, readonly) NSDictionary *mediaOptionsDictionary; @property (nonatomic, readonly) NSDictionary *mediaOptionsDictionary;
@property (nonatomic, readonly) NSTimer* sleepTimer; @property (nonatomic, readonly) NSTimer* sleepTimer;
......
...@@ -20,17 +20,10 @@ ...@@ -20,17 +20,10 @@
#import <CommonCrypto/CommonDigest.h> #import <CommonCrypto/CommonDigest.h>
#import "UIDevice+VLC.h" #import "UIDevice+VLC.h"
#import <AVFoundation/AVFoundation.h> #import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
#import "VLCPlayerDisplayController.h" #import "VLCPlayerDisplayController.h"
#import "VLCConstants.h" #import "VLCConstants.h"
#import "VLCRemoteControlService.h" #import "VLCRemoteControlService.h"
#import "VLCMetadata.h"
#if TARGET_OS_IOS
#import "VLCKeychainCoordinator.h"
#import "VLCThumbnailsCache.h"
#import "VLCLibraryViewController.h"
#import <WatchKit/WatchKit.h>
#endif
NSString *const VLCPlaybackControllerPlaybackDidStart = @"VLCPlaybackControllerPlaybackDidStart"; NSString *const VLCPlaybackControllerPlaybackDidStart = @"VLCPlaybackControllerPlaybackDidStart";
NSString *const VLCPlaybackControllerPlaybackDidPause = @"VLCPlaybackControllerPlaybackDidPause"; NSString *const VLCPlaybackControllerPlaybackDidPause = @"VLCPlaybackControllerPlaybackDidPause";
...@@ -63,18 +56,10 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -63,18 +56,10 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
NSUInteger _currentAspectRatio; NSUInteger _currentAspectRatio;
float _currentPlaybackRate;
UIView *_videoOutputViewWrapper; UIView *_videoOutputViewWrapper;
UIView *_actualVideoOutputView; UIView *_actualVideoOutputView;
UIView *_preBackgroundWrapperView; UIView *_preBackgroundWrapperView;
/* cached stuff for the VC */
NSString *_title;
UIImage *_artworkImage;
NSString *_artist;
NSString *_albumName;
BOOL _mediaIsAudioOnly;
BOOL _needsMetadataUpdate; BOOL _needsMetadataUpdate;
BOOL _mediaWasJustStarted; BOOL _mediaWasJustStarted;
BOOL _recheckForExistingThumbnail; BOOL _recheckForExistingThumbnail;
...@@ -127,6 +112,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -127,6 +112,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
[defaultCenter addObserver:self selector:@selector(applicationDidEnterBackground:) [defaultCenter addObserver:self selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification object:nil]; name:UIApplicationDidEnterBackgroundNotification object:nil];
_metadata = [VLCMetaData new];
_dialogProvider = [[VLCDialogProvider alloc] initWithLibrary:[VLCLibrary sharedLibrary] customUI:NO]; _dialogProvider = [[VLCDialogProvider alloc] initWithLibrary:[VLCLibrary sharedLibrary] customUI:NO];
_playbackSessionManagementLock = [[NSLock alloc] init]; _playbackSessionManagementLock = [[NSLock alloc] init];
...@@ -487,7 +473,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -487,7 +473,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
- (NSInteger)mediaDuration - (NSInteger)mediaDuration
{ {
return _listPlayer.mediaPlayer.media.length.intValue;; return _mediaPlayer.media.length.intValue;;
} }
- (BOOL)isPlaying - (BOOL)isPlaying
...@@ -520,38 +506,27 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -520,38 +506,27 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
return _activeSession; return _activeSession;
} }
- (BOOL)audioOnlyPlaybackSession
{
return _mediaIsAudioOnly;
}
- (NSString *)mediaTitle
{
return _title;
}
- (float)playbackRate - (float)playbackRate
{ {
float f_rate = _mediaPlayer.rate; return _mediaPlayer.rate;
_currentPlaybackRate = f_rate;
return f_rate;
} }
- (void)setPlaybackRate:(float)playbackRate - (void)setPlaybackRate:(float)playbackRate
{ {
if (_currentPlaybackRate != playbackRate) [_mediaPlayer setRate:playbackRate];
[_mediaPlayer setRate:playbackRate]; _metadata.playbackRate = @(_mediaPlayer.rate);
_currentPlaybackRate = playbackRate;
} }
- (void)setAudioDelay:(float)audioDelay - (void)setAudioDelay:(float)audioDelay
{ {
_mediaPlayer.currentAudioPlaybackDelay = 1000000.*audioDelay; _mediaPlayer.currentAudioPlaybackDelay = 1000000.*audioDelay;
} }
- (float)audioDelay - (float)audioDelay
{ {
return _mediaPlayer.currentAudioPlaybackDelay/1000000.; return _mediaPlayer.currentAudioPlaybackDelay/1000000.;
} }
-(void)setSubtitleDelay:(float)subtitleDeleay -(void)setSubtitleDelay:(float)subtitleDeleay
{ {