Coder Social home page Coder Social logo

media's Introduction

Hi there, I'm Christian πŸ‘‹

Buy me a β˜• coffee if you want to support me 😎

media's People

Contributors

celies-e avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

media's Issues

Get assets filesize and get PHAsset

Thank you for a really good lib.

How can I get the filesize (in bytes) of the asset (video or image). And the PHAsset properties are not public so I cannot get it to use.

PHCachingImageManager

I have an issue. I need to fetch same asset multiple times. Does the library using apple's default PHCachingMamager or something like that for this purpose?

how to fetch all assets?

How to fetch all assets like this:

 @FetchAssets(sort: [Media.Sort(key: .creationDate, ascending: false)])
 private var assets: [AnyMedia]

AnyMedia is not conform to MediaProtocol.
So, i try this:

let assets = Albums.smart
        .filter { $0.localizedTitle == "Recents" }
        .first?
        .allMedia

But localization is a tricky problem...

Real world example of album.add

I find some of the APIs in Media very difficult to understand. A real-world example of album.add() would be very helpful.

I am downloading random images, png, Jpeg or webp and would like to save in an album I have created. How does one construct a Photo object conforming to MediaProtocol?

I have a UIImage or cGImage and cannot figure out how to create the Photo...

// image was downloaded via KingFisher
let album = try Album.with(identifier: DEFAULT_ALBUM_NAME)

album?.add() <-- I have a UIImage or CGImage instance, how do I convert it to a `Photo`?
           
image

How Could I ask user again for the access to the photos like the original one while current permission is .authorized.

Environment

  • Xcode 12.5
  • SwiftUI

Code

Problem

  1. I using the code below:
struct GalleryView: View {
   @State private var permissionGranted: Bool = false
   @State private var permissionError: PermissionError?

   var body: some View {
       NavigationView {
           VStack {
               List(Media.Photos.all) { photo in
                   NavigationLink(destination: PhotoView(photo: photo)) {
                       Text(photo.id)
                   }
               }.navigationBarTitle("Photos", displayMode: .inline)
           
               Button(action: {
                   self.requestPermission()
               }) {
                   Text("Trigger permission request")
               }
           }
       }
   }
}

extension GalleryView {
   private func requestPermission() {
       Media.requestPermission { result in
           switch result {
           case .success:
               self.permissionGranted = true
               self.permissionError = nil
           case .failure(let error):
               self.permissionGranted = false
               self.permissionError = error
           }
       }
   }
}
  1. I start the app first time, the Alert ask for permission to access to the photo library, I choose [Select photos..] option in the alert below:

ζˆͺ屏2021-03-10 δΈ‹εˆ2 04 00

3. I start the app 2nd, I try to tap [Trigger permission request] button in the above code, I expect for the alert below, but nothing happened.

ζˆͺ屏2021-03-10 δΈ‹εˆ2 04 17

So, How could I open the photo permission selection again in my application? Thanks a lot.

RAW?

This looks really nice! Is there a straightforward way to figure out whether a file is available with both JPG+RAW images as a property?

Album photos count always return the overall count

I am trying to fetch all the photos in a specific album but the Album.photos always return all the images in my library rather than the actual count.

Eg in simulator

print(albumInfo.photos.count) returns 6
print(albumInfo.metadata?.estimatedAssetCount) returns 2

I tried looking into the tests as well but there is nowhere I can find an implementation where you are pulling count from the individual album or using the assets from it. I am just starting with this library, thanks for creating an excellent wrapper.

@crelies

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.