piemonte / Player

▶️ Play and stream media in Swift
MIT License
2.08k stars 334 forks source link

Setting up Player with AVPlayerItem. #235

Open lurui1029 opened 3 years ago

lurui1029 commented 3 years ago

Player stopped working when set up with an AVAsset downloaded from user's iCloud photo library using PHImageManager:

Error Domain=NSCocoaErrorDomain Code=257 UserInfo={NSURL=file:///var/mobile/Media/PhotoData/Metadata/DCIM/101APPLE/IMG_1858.small.MP4, NSUnderlyingError=0x2833487b0 {Error Domain=NSOSStatusErrorDomain Code=-12203 "(null)"}}

Related posts:

Swift AVAsset downloading from iCloud has no permission on iOS 14: error Code=257

Request AVAsset using iCloud PHAsset returns an AVAsset with no VideoTracks

Solution

Set up Player with an AVPlayerItem.

PHImageManager provides either an AVAsset or an AVPlayItem for a video request from user's photo library. This issue does not occur when working with an AVPlayerItem.