SPAsyncVideoView icon indicating copy to clipboard operation
SPAsyncVideoView copied to clipboard

Add property for video size

Open AndrewHartAR opened this issue 9 years ago • 1 comments

This library is awesome. Can't wait to see it grow.

I'm using this in a messaging app, and the only part missing is I need to know the size of the video, so I can lay it out appropriately. Using AVAsset for this inevitably causes a delay as it loads in the asset. If this property could be added that'd be awesome. Right now I'm doing it using AVAsset as follows:

extension AVAsset {
    func size() -> CGSize? {
        let tracks = self.tracksWithMediaType(AVMediaTypeVideo)

        if tracks.count > 0 {
            return tracks[0].naturalSize
        } else {
            return nil
        }
    }
}

AndrewHartAR avatar Jul 24 '16 13:07 AndrewHartAR

Hey @ProjectDent. Thank you for feedback, I very appreciate it! Due asynchronous nature of this view you can't get natural size without delay. Since 0.3.0 you can catch this size from delegate method:

asyncVideoView:didReceiveAssetNaturalSize:

Also, if you use autolayout, view should resize itself by natural size.

BTW, I'm strongly recommend to precache all meta info of your source file and store in the same place with URL.

xquezme avatar Jul 27 '16 20:07 xquezme