Commit ffc13911 authored by Carola Nitz's avatar Carola Nitz

VLCPlaybackInfoMediaInfoTVViewController, VLCHttpConnection and...

VLCPlaybackInfoMediaInfoTVViewController, VLCHttpConnection and VLCPlayerControlWebSocket: fixes for TVOS by switching to new methods
parent 6cc45270
Pipeline #230 passed with stage
in 0 seconds
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
videoWidth, videoHeight], videoWidth, videoHeight],
videoCodec]; videoCodec];
} }
NSInteger audioTrackCount = player.numberOfAudioTracks - 1; // minus fake disable track NSInteger audioTrackCount = [vpc numberOfAudioTracks] -1; // minus fake disable track
if (audioTrackCount > 0) { if (audioTrackCount > 0) {
if (audioTrackCount > 1) { if (audioTrackCount > 1) {
metaDataString = [metaDataString stringByAppendingFormat:NSLocalizedString(@"FORMAT_AUDIO_TRACKS", nil), metaDataString = [metaDataString stringByAppendingFormat:NSLocalizedString(@"FORMAT_AUDIO_TRACKS", nil),
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
} }
metaDataString = [metaDataString stringByAppendingFormat:@" (%@)\n", audioCodecs]; metaDataString = [metaDataString stringByAppendingFormat:@" (%@)\n", audioCodecs];
} }
NSInteger spuTrackCount = player.numberOfSubtitlesTracks - 1; // minus fake disable track NSInteger spuTrackCount = [vpc numberOfVideoSubtitlesIndexes] - 1; // minus fake disable track
if (spuTrackCount > 0) { if (spuTrackCount > 0) {
if (spuTrackCount > 1) { if (spuTrackCount > 1) {
metaDataString = [metaDataString stringByAppendingFormat:NSLocalizedString(@"FORMAT_SPU_TRACKS", nil), metaDataString = [metaDataString stringByAppendingFormat:NSLocalizedString(@"FORMAT_SPU_TRACKS", nil),
......
...@@ -116,36 +116,27 @@ ...@@ -116,36 +116,27 @@
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
NSDictionary *returnDict; NSDictionary *returnDict;
if (vpc.activePlaybackSession) { if (vpc.isPlaying) {
VLCMediaPlayer *player = vpc.mediaPlayer; VLCMedia *media = [vpc currentlyPlayingMedia];
if (player) {
VLCMedia *media = player.media;
if (media) { if (media) {
NSURL *url = media.url; NSURL *url = media.url;
NSString *mediaTitle = vpc.metadata.title; 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,
@"title" : mediaTitle, @"title" : mediaTitle,
@"duration" : @(media.length.intValue)}; @"duration" : @([vpc mediaDuration])};
returnDict = @{ @"currentTime" : @(player.time.intValue), returnDict = @{ @"currentTime" : @([vpc playedTime].intValue),
@"type" : @"playing", @"type" : @"playing",
@"media" : mediaDict }; @"media" : mediaDict };
} }
} }
}
if (!returnDict) { if (!returnDict) {
returnDict = [NSDictionary dictionary]; returnDict = [NSDictionary dictionary];
} }
[self sendDataWithDict:returnDict];
NSError *error;
NSData *returnData = [NSJSONSerialization dataWithJSONObject:returnDict options:0 error:&error];
if (error != nil) {
APLog(@"%s: JSON serialization failed %@", __PRETTY_FUNCTION__, error);
}
[self sendData:returnData];
} }
#pragma mark - play #pragma mark - play
...@@ -167,24 +158,11 @@ ...@@ -167,24 +158,11 @@
"currentTime": 42 "currentTime": 42
} }
*/ */
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
VLCMediaPlayer *player = vpc.mediaPlayer; NSDictionary *dict = @{ @"currentTime" : @([vpc playedTime].intValue),
if (player) {
VLCMedia *media = player.media;
if (media) {
NSDictionary *returnDict = @{ @"currentTime" : @(player.time.intValue),
@"type" : @"play" }; @"type" : @"play" };
[self sendDataWithDict:dict];
NSError *error;
NSData *returnData = [NSJSONSerialization dataWithJSONObject:returnDict options:0 error:&error];
if (error != nil) {
APLog(@"%s: JSON serialization failed %@", __PRETTY_FUNCTION__, error);
}
[self sendData:returnData];
}
}
} }
#pragma mark - pause #pragma mark - pause
...@@ -206,24 +184,26 @@ ...@@ -206,24 +184,26 @@
"currentTime": 42, "currentTime": 42,
} }
*/ */
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
VLCMediaPlayer *player = vpc.mediaPlayer; NSDictionary *dict = @{ @"currentTime" : @([vpc playedTime].intValue),
if (player) {
VLCMedia *media = player.media;
if (media) {
NSDictionary *returnDict = @{ @"currentTime" : @(player.time.intValue),
@"type" : @"pause" }; @"type" : @"pause" };
[self sendDataWithDict:dict];
}
- (void)sendDataWithDict:(NSDictionary *)dict
{
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
VLCMedia *media = [vpc currentlyPlayingMedia];
if (media) {
NSError *error; NSError *error;
NSData *returnData = [NSJSONSerialization dataWithJSONObject:returnDict options:0 error:&error]; NSData *returnData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:&error];
if (error != nil) { if (error != nil) {
APLog(@"%s: JSON serialization failed %@", __PRETTY_FUNCTION__, error); APLog(@"%s: JSON serialization failed %@", __PRETTY_FUNCTION__, error);
} }
[self sendData:returnData]; [self sendData:returnData];
} }
}
} }
#pragma mark - ended #pragma mark - ended
...@@ -241,23 +221,8 @@ ...@@ -241,23 +221,8 @@
"type": "ended" "type": "ended"
} }
*/ */
NSDictionary *dict = @{ @"type" : @"ended" };
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; [self sendDataWithDict:dict];
VLCMediaPlayer *player = vpc.mediaPlayer;
if (player) {
VLCMedia *media = player.media;
if (media) {
NSDictionary *returnDict = @{ @"type" : @"ended" };
NSError *error;
NSData *returnData = [NSJSONSerialization dataWithJSONObject:returnDict options:0 error:&error];
if (error != nil) {
APLog(@"%s: JSON serialization failed %@", __PRETTY_FUNCTION__, error);
}
[self sendData:returnData];
}
}
} }
#pragma mark - seek #pragma mark - seek
...@@ -271,16 +236,12 @@ ...@@ -271,16 +236,12 @@
} }
*/ */
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
VLCMediaPlayer *player = vpc.mediaPlayer;
if (!player) VLCMedia *media = [vpc currentlyPlayingMedia];
return;
VLCMedia *media = player.media;
if (!media) if (!media)
return; return;
player.position = [dictionary[@"currentTime"] floatValue] / (CGFloat)media.length.intValue; vpc.playbackPosition = [dictionary[@"currentTime"] floatValue] / (CGFloat)media.length.intValue;
} }
- (void)playbackSeekTo - (void)playbackSeekTo
...@@ -296,24 +257,12 @@ ...@@ -296,24 +257,12 @@
*/ */
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
VLCMediaPlayer *player = vpc.mediaPlayer; VLCMedia *media = [vpc currentlyPlayingMedia];
if (player) {
VLCMedia *media = player.media;
if (media) {
NSDictionary *mediaDict = @{ @"id" : media.url.absoluteString}; NSDictionary *mediaDict = @{ @"id" : media.url.absoluteString};
NSDictionary *returnDict = @{ @"currentTime" : @(player.time.intValue), NSDictionary *dict = @{ @"currentTime" : @([vpc playedTime].intValue),
@"type" : @"seekTo", @"type" : @"seekTo",
@"media" : mediaDict }; @"media" : mediaDict };
[self sendDataWithDict:dict];
NSError *error;
NSData *returnData = [NSJSONSerialization dataWithJSONObject:returnDict options:0 error:&error];
if (error != nil) {
APLog(@"%s: JSON serialization failed %@", __PRETTY_FUNCTION__, error);
}
[self sendData:returnData];
}
}
} }
#pragma mark - openURL #pragma mark - openURL
......
...@@ -455,11 +455,10 @@ ...@@ -455,11 +455,10 @@
*/ */
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
if (!vpc.activePlaybackSession) { if (!vpc.isPlaying) {
return [[HTTPErrorResponse alloc] initWithErrorCode:404]; return [[HTTPErrorResponse alloc] initWithErrorCode:404];
} }
VLCMediaPlayer *player = vpc.mediaPlayer; VLCMedia *media = [vpc currentlyPlayingMedia];
VLCMedia *media = player.media;
if (!media) { if (!media) {
return [[HTTPErrorResponse alloc] initWithErrorCode:404]; return [[HTTPErrorResponse alloc] initWithErrorCode:404];
} }
...@@ -469,8 +468,8 @@ ...@@ -469,8 +468,8 @@
mediaTitle = @""; mediaTitle = @"";
NSDictionary *mediaDict = @{ @"id" : media.url.absoluteString, NSDictionary *mediaDict = @{ @"id" : media.url.absoluteString,
@"title" : mediaTitle, @"title" : mediaTitle,
@"duration" : @(media.length.intValue)}; @"duration" : @([vpc mediaDuration])};
NSDictionary *returnDict = @{ @"currentTime" : @(player.time.intValue), NSDictionary *returnDict = @{ @"currentTime" : @([vpc playedTime].intValue),
@"media" : mediaDict }; @"media" : mediaDict };
NSError *error; NSError *error;
...@@ -526,7 +525,7 @@ ...@@ -526,7 +525,7 @@
*/ */
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
if (!vpc.activePlaybackSession || !vpc.mediaList) { if (!vpc.isPlaying || !vpc.mediaList) {
return [[HTTPErrorResponse alloc] initWithErrorCode:404]; return [[HTTPErrorResponse alloc] initWithErrorCode:404];
} }
......
...@@ -65,6 +65,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -65,6 +65,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
@property (nonatomic, assign, getter=isShuffleMode) BOOL shuffleMode; @property (nonatomic, assign, getter=isShuffleMode) BOOL shuffleMode;
@property (nonatomic, readwrite) float playbackRate; // default = 1.0 @property (nonatomic, readwrite) float playbackRate; // default = 1.0
@property (nonatomic, readwrite) float audioDelay; // in seconds, default = 0.0 @property (nonatomic, readwrite) float audioDelay; // in seconds, default = 0.0
@property (nonatomic, readwrite) float playbackPosition; // in seconds, default = 0.0
@property (nonatomic, readwrite) float subtitleDelay; // in seconds, default = 0.0 @property (nonatomic, readwrite) float subtitleDelay; // in seconds, default = 0.0
@property (readonly) NSInteger indexOfCurrentAudioTrack; @property (readonly) NSInteger indexOfCurrentAudioTrack;
@property (readonly) NSInteger indexOfCurrentSubtitleTrack; @property (readonly) NSInteger indexOfCurrentSubtitleTrack;
...@@ -81,7 +82,8 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -81,7 +82,8 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
@property (nonatomic, readonly) NSTimer* sleepTimer; @property (nonatomic, readonly) NSTimer* sleepTimer;
+ (VLCPlaybackController *)sharedInstance; + (VLCPlaybackController *)sharedInstance;
- (VLCTime *)playedTime;
#pragma mark - playback
- (void)startPlayback; - (void)startPlayback;
- (void)stopPlayback; - (void)stopPlayback;
- (void)playPause; - (void)playPause;
......
...@@ -147,6 +147,11 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -147,6 +147,11 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
self.isPlaying ? [self stopPlayback] : [self startPlayback]; self.isPlaying ? [self stopPlayback] : [self startPlayback];
} }
- (VLCTime *)playedTime
{
return [_mediaPlayer time];
}
- (void)startPlayback - (void)startPlayback
{ {
if (_playerIsSetup) { if (_playerIsSetup) {
...@@ -470,7 +475,17 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate> ...@@ -470,7 +475,17 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
return _mediaPlayer.currentAudioPlaybackDelay/1000000.; return _mediaPlayer.currentAudioPlaybackDelay/1000000.;
} }
-(void)setSubtitleDelay:(float)subtitleDeleay - (float)playbackPosition
{
return [_mediaPlayer position];
}
- (void)setPlaybackPosition:(float)position
{
_mediaPlayer.position = position;
}
- (void)setSubtitleDelay:(float)subtitleDeleay
{ {
_mediaPlayer.currentVideoSubTitleDelay = 1000000.*subtitleDeleay; _mediaPlayer.currentVideoSubTitleDelay = 1000000.*subtitleDeleay;
} }
......
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