それはHLS(ストリーミング)ビデオでない場合は、次のコードで解像度情報を取得することができます。
サンプルコード:
// player is playing
if (_player.rate != 0 && _player.error == nil)
{
AVAssetTrack *track = [[_player.currentItem.asset tracksWithMediaType:AVMediaTypeVideo] firstObject];
if (track != nil)
{
CGSize naturalSize = [track naturalSize];
naturalSize = CGSizeApplyAffineTransform(naturalSize, track.preferredTransform);
NSInteger width = (NSInteger) naturalSize.width;
NSInteger height = (NSInteger) naturalSize.height;
NSLog(@"Resolution : %ld x %ld", width, height);
}
}
しかし、HLSビデオのために、上記のコードは動作しません。 私はこれを別の方法で解決しました。 ビデオを再生したとき、ビデオからイメージを取得し、その解像度を計算しました。ここで
はサンプルコードです:HLSの動画の場合はresponse.Butため
// player is playing
if (_player.rate != 0 && _player.error == nil)
{
AVAssetTrack *track = [[_player.currentItem.asset tracksWithMediaType:AVMediaTypeVideo] firstObject];
CMTime currentTime = _player.currentItem.currentTime;
CVPixelBufferRef buffer = [_videoOutput copyPixelBufferForItemTime:currentTime itemTimeForDisplay:nil];
NSInteger width = CVPixelBufferGetWidth(buffer);
NSInteger height = CVPixelBufferGetHeight(buffer);
NSLog(@"Resolution : %ld x %ld", width, height);
}
おかげで、.ActuallyのiOSは自動的に私はguess.Butネットワーク速度に基づいて、それらを処理する利用可能異なる解像度があるかもしれませんそれらのデータを取得してそれらの間で切り替えることができるかどうかを尋ねています。私は単一のビデオURLについて話しています。異なるストリームが単一のURLで利用可能かもしれません。 – abhi1992