@@ -992,33 +992,54 @@ - (void)loadAudioCodecDetails {
992992}
993993
994994- (void )loadVideoCodecDetails {
995+ // First read Player.GetProperties. If this is empty, use XBMC.GetInfoLabels.
996+ // Note: aspect ratio and resolution is only provided by XBMC.GetInfoLabels.
995997 [[Utilities getJsonRPC ]
996- callMethod: @" XBMC.GetInfoLabels"
997- withParameters: @{@" labels" : @[
998- @" VideoPlayer.VideoResolution" ,
999- @" VideoPlayer.VideoAspect" ,
1000- @" VideoPlayer.AudioCodec" ,
1001- @" VideoPlayer.VideoCodec" ,
1002- ]}
998+ callMethod: @" Player.GetProperties"
999+ withParameters: @{@" playerid" : @(currentPlayerID),
1000+ @" properties" : @[
1001+ @" currentvideostream" ,
1002+ @" currentaudiostream" ,
1003+ ]}
10031004 onCompletion: ^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) {
1005+ __block NSString *audiocodec, *videocodec, *aspect, *res;
10041006 if (error == nil && methodError == nil && [methodResult isKindOfClass: [NSDictionary class ]]) {
1005- NSString *codec = [Utilities getStringFromItem: methodResult[@" VideoPlayer.AudioCodec" ]];
1006- codec = [self processAudioCodecName: codec];
1007- [self setSongDetails: songNumChannels image: songNumChanImage item: codec];
1008- [self setSongDetails: songCodec image: songCodecImage item: methodResult[@" VideoPlayer.VideoResolution" ]];
1007+ audiocodec = [Utilities getStringFromItem: methodResult[@" currentaudiostream" ][@" codec" ]];
1008+ videocodec = [Utilities getStringFromItem: methodResult[@" currentvideostream" ][@" codec" ]];
1009+ }
1010+
1011+ // Use XBMC.GetInfoLabels to gather aspect ratio and resolution. Same for codecs, if empty yet.
1012+ [[Utilities getJsonRPC ]
1013+ callMethod: @" XBMC.GetInfoLabels"
1014+ withParameters: @{@" labels" : @[
1015+ @" VideoPlayer.VideoResolution" ,
1016+ @" VideoPlayer.VideoAspect" ,
1017+ @" VideoPlayer.AudioCodec" ,
1018+ @" VideoPlayer.VideoCodec" ,
1019+ ]}
1020+ onCompletion: ^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) {
1021+ if (error == nil && methodError == nil && [methodResult isKindOfClass: [NSDictionary class ]]) {
1022+ audiocodec = audiocodec.length ? audiocodec : [Utilities getStringFromItem: methodResult[@" VideoPlayer.AudioCodec" ]];
1023+ videocodec = videocodec.length ? videocodec : [Utilities getStringFromItem: methodResult[@" VideoPlayer.VideoCodec" ]];
1024+ aspect = aspect.length ? aspect : [Utilities getStringFromItem: methodResult[@" VideoPlayer.VideoAspect" ]];
1025+ res = res.length ? res : [Utilities getStringFromItem: methodResult[@" VideoPlayer.VideoResolution" ]];
1026+ }
10091027
1010- codec = [Utilities getStringFromItem: methodResult[@" VideoPlayer.VideoCodec" ]];
1011- codec = [self processVideoCodecName: codec];
1012- [self setSongDetails: songSampleRate image: songSampleRateImage item: codec];
1028+ audiocodec = [self processAudioCodecName: audiocodec];
1029+ [self setSongDetails: songNumChannels image: songNumChanImage item: audiocodec];
1030+
1031+ videocodec = [self processVideoCodecName: videocodec];
1032+ [self setSongDetails: songSampleRate image: songSampleRateImage item: videocodec];
1033+
1034+ [self setSongDetails: songCodec image: songCodecImage item: res];
10131035
1014- NSString *aspect = [Utilities getStringFromItem: methodResult[@" VideoPlayer.VideoAspect" ]];
10151036 aspect = [self processAspectString: aspect];
10161037 songBitRate.text = aspect;
10171038 songBitRateImage.image = [self loadImageFromName: @" icon_aspect" ];
10181039 songBitRateImage.hidden = songBitRate.hidden = aspect.length == 0 ;
10191040
10201041 itemDescription.font = [UIFont systemFontOfSize: descriptionFontSize];
1021- }
1042+ }];
10221043 }];
10231044}
10241045
0 commit comments