Giter Club home page Giter Club logo

cachingplayeritem's People

Contributors

hungnguyen1791 avatar sukov avatar wzio 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

Watchers

 avatar  avatar

cachingplayeritem's Issues

Does it work well with URL with Parameters

For instance the URL looks like https://ddomain.com/myfile.mp4?token=adajah828hhy297
Will the player play it and cache it in such a way that even if the token changes it will still refer to the same file locally?

Large video does not start playing after download finishes

Issue

Hello! Thanks for the great snippet.
I've been struggling with figuring out why a large video (300MB) does not play after it's downloaded. Smaller size videos (10MB even 100MB) play fine. The video is a basic mp4 without moov item in the beginning so they have to be completely downloaded before they start playing. The larger video downloads successfully but then the player is stuck in waitingToPlayAtSpecifiedRate with reason noItemToPlay. Any ideas of what might be the problem?

I'm referring to caching initializers. It also takes way longer than regular AVPlayerItem to play if it's the caching case basically only stars playing when the entire file is downloaded while AVPlayerItem starts playing way way sooner.

Example

Here's the video url for reference.

Environment

iOS 17.0.1
Xcode 15.0.1

Thanks a lot!

I can't get the Caching to a file to Work I get an error `No such file or directory`

I want to be able to play media while caching to a file. There is an option called saveFilePath, also custom extension (I also don't know why I have to set it manually while all my url has extensions) Now I need the library to save file at the given directory and later on when I play it again to use the local copy instead of streaming (Isn't that the importance of caching?)

My current example of implementations is:

let playerItem = CachingPlayerItem(url: url, saveFilePath: "nDNtKz3BQogGuLtg6XRI.mp4", customFileExtension: "mp4")

The error I get:
FileAttribute error: Error Domain=NSCocoaErrorDomain Code=260 "The file “nDNtKz3BQogGuLtg6XRI.mp4” couldn’t be opened because there is no such file." UserInfo={NSFilePath=nDNtKz3BQogGuLtg6XRI.mp4, NSUnderlyingError=0x283d055f0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}FileAttribute error: Error Domain=NSCocoaErrorDomain Code=260 "The file “nDNtKz3BQogGuLtg6XRI.mp4” couldn’t be opened because there is no such file." UserInfo={NSFilePath=nDNtKz3BQogGuLtg6XRI.mp4, NSUnderlyingError=0x283d055f0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

How do I get this to work. Stream while downloading, later play the downloaded file not streaming again??

Crash for init CachingPlayerItem

when add a looper on queueplayer, crash for init

like this:

looper = AVPlayerLooper(player: queuePlayer, templateItem: loopPlayerItems.first!)

how can I resolve this?

Integrating with UICollectionViewDataSourcePrefetching

did you attempt to integrate with
collectionview.isPrefetchingEnabled = true

extension VideoViewController: UICollectionViewDataSourcePrefetching {

    func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) {

        for indexPath in indexPaths {
            if let cell = feedCV.cellForItem(at: indexPath) as? VideoCollectionCell {
                cell.setUpPlayer()
            }
        }
    }

    func collectionView(_ collectionView: UICollectionView, cancelPrefetchingForItemsAt indexPaths: [IndexPath]) {
        // Cancel any requests for data for the specified index paths.
         // how can we target any rogue downloads if user jumps to another screen???
    }
}

Still got crash when play with AVPlayerLooper

Using CachingPlayerItem with code like this will make the crash happen
`
let url = URL(string: "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4")!
let playerItem = CachingPlayerItem(url: url, avUrlAssetOptions: nil)

    let queuePlayer = AVQueuePlayer(playerItem: playerItem)

    // Create a new player looper with the queue player and template item
    self.avPlayerLooper = AVPlayerLooper(player: queuePlayer, templateItem: playerItem)

    let playerLayer = AVPlayerLayer(player: queuePlayer)
    playerLayer.frame = self.view.bounds
    playerLayer.videoGravity = .resizeAspect
    self.view.layer.addSublayer(playerLayer)

    queuePlayer.play()

`
Screen Shot 2023-05-30 at 08 59 15

DemoCrash.zip

Crash for init CachingPlayerItem

Crash when init CachingPlayerItem: CachingPlayerItem(url: url):

CachingPlayerItem/CachingPlayerItem.swift:185: Fatal error: CachingPlayerItem error: init(asset:automaticallyLoadedAssetKeys:) not implemented

I checked the code base, different places call the super.init, not this one.

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.