How to check if AVPlayer has Video or just Audio?

后端 未结 4 1828
一向
一向 2021-01-12 09:48

I try to play some \"media\" but at the time the AVPlayer starts I don\'t know if it is audio or Video.

I connected the player Layer and it works fine.



        
4条回答
  •  我在风中等你
    2021-01-12 10:29

    From Apple’s sample code project AVSimplePlayer:

    // Set up an AVPlayerLayer according to whether the asset contains video.
    if ([[(AVAsset *)asset tracksWithMediaType:AVMediaTypeVideo] count] != 0)
    

提交回复
热议问题