Commit a70b6ace authored by Carola's avatar Carola
Browse files

VLCPlaybackController: remove currentlyPlayingMediaFile that returns MLFile...

VLCPlaybackController: remove currentlyPlayingMediaFile that returns MLFile and replace it with VLCMedia to be available on both platforms
parent bd8f22f9
Pipeline #229 passed with stage
in 0 seconds
......@@ -49,8 +49,7 @@
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
self.titleLabel.text = vpc.metadata.title;
VLCMediaPlayer *player = vpc.mediaPlayer;
VLCMedia *media = player.media;
VLCMedia *media = [vpc currentlyPlayingMedia];
NSArray *mediaTrackData = media.tracksInformation;
NSUInteger trackDataCount = mediaTrackData.count;
......
......@@ -45,27 +45,27 @@ Open a file in the libraryViewController without changing the playstate
- (void)openMediaLibraryObject:(NSManagedObject *)mediaObject
{
if (self.isPlaying) {
NSArray *files = [MLFile fileForURL:self.mediaPlayer.media.url];
MLFile *nowPlayingFile = (MLFile *)(NSManagedObject *)files.firstObject;
MLFile *newFile;
if ([mediaObject isKindOfClass:[MLAlbumTrack class]]) {
newFile = ((MLAlbumTrack *)mediaObject).anyFileFromTrack;
} else if ([mediaObject isKindOfClass:[MLShowEpisode class]]) {
newFile = ((MLShowEpisode *)mediaObject).anyFileFromEpisode;
} else if ([mediaObject isKindOfClass:[MLFile class]]) {
newFile = (MLFile *)mediaObject;
}
//if the newfile is not the currently playing one, stop and start the new one else do nothing
if (![nowPlayingFile isEqual:newFile]) {
[self stopPlayback];
[self playMediaLibraryObject:mediaObject];
}
if (!self.isPlaying) {
//if nothing is playing start playing
[self playMediaLibraryObject:mediaObject];
return;
}
//if nothing is playing start playing
[self playMediaLibraryObject:mediaObject];
MLFile *newFile;
if ([mediaObject isKindOfClass:[MLAlbumTrack class]]) {
newFile = ((MLAlbumTrack *)mediaObject).anyFileFromTrack;
} else if ([mediaObject isKindOfClass:[MLShowEpisode class]]) {
newFile = ((MLShowEpisode *)mediaObject).anyFileFromEpisode;
} else if ([mediaObject isKindOfClass:[MLFile class]]) {
newFile = (MLFile *)mediaObject;
}
//if the newfile is not the currently playing one, stop and start the new one else do nothing
VLCMedia *currentlyPlayingFile = self.currentlyPlayingMedia;
MLFile *currentMLFile = [MLFile fileForURL:currentlyPlayingFile.url].firstObject;
if (![currentMLFile isEqual:newFile]) {
[self stopPlayback];
[self playMediaLibraryObject:mediaObject];
}
}
- (void)configureWithFile:(MLFile *)file
......
......@@ -50,10 +50,9 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
@property (nonatomic, retain) VLCMediaList *mediaList;
#if TARGET_OS_IOS
/* returns nil if currently playing item is not a MLFile, e.g. a url */
@property (nonatomic, strong, readonly) MLFile *currentlyPlayingMediaFile;
#endif
/* returns nil if currently playing item is not available,*/
@property (nonatomic, strong, readonly) VLCMedia *currentlyPlayingMedia;
@property (nonatomic, weak) id<VLCPlaybackControllerDelegate> delegate;
......
......@@ -47,6 +47,7 @@ AVAudioSessionDelegate,
VLCMediaDelegate, VLCRemoteControlServiceDelegate>
{
VLCRemoteControlService *_remoteControlService;
VLCMediaPlayer *_mediaPlayer;
BOOL _playerIsSetup;
BOOL _shouldResumePlaying;
BOOL _sessionWillRestart;
......@@ -907,18 +908,16 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
#pragma mark - Managing the media item
#if TARGET_OS_IOS
- (MLFile *)currentlyPlayingMediaFile {
if (self.mediaList) {
NSArray *results = [MLFile fileForURL:_mediaPlayer.media.url];
return results.firstObject;
}
return nil;
- (VLCMedia *)currentlyPlayingMedia
{
return _mediaPlayer.media;
}
#endif
#pragma mark - metadata handling
- (void)performNavigationAction:(VLCMediaPlaybackNavigationAction)action
{
[_mediaPlayer performNavigationAction:action];
}
- (void)mediaDidFinishParsing:(VLCMedia *)aMedia
{
[self setNeedsMetadataUpdate];
......@@ -1108,7 +1107,6 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
{
self.playbackRate = playbackRate;
}
#pragma mark - helpers
- (NSDictionary *)mediaOptionsDictionary
......
......@@ -162,8 +162,9 @@ static VLCWatchCommunication *_singeltonInstance = nil;
if (nowPlayingInfo) {
response[@"nowPlayingInfo"] = nowPlayingInfo;
}
MLFile *currentFile = [VLCPlaybackController sharedInstance].currentlyPlayingMediaFile;
NSString *URIString = currentFile.objectID.URIRepresentation.absoluteString;
VLCMedia *currentFile = [VLCPlaybackController sharedInstance].currentlyPlayingMedia;
MLFile *mediaFile = [MLFile fileForURL:currentFile.url].firstObject;
NSString *URIString = mediaFile.objectID.URIRepresentation.absoluteString;
if (URIString) {
response[VLCWatchMessageKeyURIRepresentation] = URIString;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment