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