exyte / MediaPicker

Customizable media picker written with SwiftUI
MIT License
334 stars 42 forks source link

Selecting videos gives .jpg url #8

Closed milesscherrer closed 1 year ago

milesscherrer commented 1 year ago

When selecting a video from camera roll, it returns a .jpg url for the first frame only. How do I get the video?

f3dm76 commented 1 year ago

@milesscherrer It is supposed to return a Media struct, not a jpg, and Media has getData(), is it not the case? Could you please attach your code if you not getting an actual Media? Have a nice day

milesscherrer commented 1 year ago

This makes it return a thumbnail if it is video:

func getUrl() async -> URL? {
        switch source {
        case .media(let assetMediaModel):
            if assetMediaModel.mediaType == .image {
                return await assetMediaModel.source.getURL()
            } else {
                return await assetMediaModel.source.getThumbnailURL()
            }

        case .url(let url):
            return url
        }
    }

But now something seems broken and I now get nil when using let url = await medias[0].getUrl()

milesscherrer commented 1 year ago

Using getData() instead I can turn the data into a UIImage but still no video available. Also in the picker camera roll preview state, the video never loads.

slimwangyue commented 1 year ago

Same here, the video is not playable, not sure why.

f3dm76 commented 1 year ago

Hey @milesscherrer @slimwangyue, thanks for bringing this to my attention, sorry for the late response, but I'm glad to say it's fixed now! Media now has url, thumbnailUrl, data and thumbnailData. Please check out version 1.0.0, and do let me know if you are still facing issues with the library. And be sure to have a marvellous day!