Giter VIP home page Giter VIP logo

kevinjameshunt / avplayer-http-headers-example Goto Github PK

View Code? Open in Web Editor NEW
66.0 66.0 5.0 29 KB

A working example of how to augment and retrieve HTTP headers on requests made by the iOS AVPlayer using a reverse proxy server on the device.

Home Page: http://kevinjameshunt.com/other-projects/sending-and-receiving-avplayer-http-headers/

License: GNU General Public License v3.0

Objective-C 97.97% Ruby 2.03%

avplayer-http-headers-example's People

Contributors

kevinjameshunt 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

Watchers

 avatar  avatar  avatar

avplayer-http-headers-example's Issues

Can't play any m3u8 playlist..

Hey i'm unable to play any m3u8 playlist using your example. This is what i'm getting in the logs...

[DEBUG] Did open IPv4 listening socket 3
[DEBUG] Did open IPv6 listening socket 4
[INFO] GCDWebServer started on port 8080 and reachable at http://192.168.2.71:8080/
[DEBUG] Did open connection on socket 5
[DEBUG] Connection received 313 bytes on socket 5
[DEBUG] Connection on socket 5 preflighting request "GET /vod/smil:BigBuckBunny.smil/playlist.m3u8" with 313 bytes body
[DEBUG] Connection on socket 5 processing request "GET /vod/smil:BigBuckBunny.smil/playlist.m3u8" with 313 bytes body
[DEBUG] Did connect
[DEBUG] Did start background task
[DEBUG] Connection sent 183 bytes on socket 5
[DEBUG] Connection sent 2273 bytes on socket 5
[DEBUG] Did close connection on socket 5
[VERBOSE] [::1:8080] ::1:65252 200 "GET /vod/smil:BigBuckBunny.smil/playlist.m3u8" (313 | 2456)
[DEBUG] Did open connection on socket 5
[DEBUG] Connection received 334 bytes on socket 5
[DEBUG] Connection on socket 5 preflighting request "GET /vod/smil:BigBuckBunny.smil/playlist.m3u8" with 334 bytes body
[DEBUG] Connection on socket 5 processing request "GET /vod/smil:BigBuckBunny.smil/playlist.m3u8" with 334 bytes body
[DEBUG] Connection sent 183 bytes on socket 5
[DEBUG] Connection sent 2273 bytes on socket 5
[DEBUG] Did close connection on socket 5
[VERBOSE] [::1:8080] ::1:65255 200 "GET /vod/smil:BigBuckBunny.smil/playlist.m3u8" (334 | 2456)
[DEBUG] Did disconnect
[DEBUG] Did end background task

am i forgetting something? The video just won't start...

How to add separate headers to the request that fetches the key only?

How do you add separate headers to the request that fetches the key only?

extension VideoPlayerViewController: AVAssetResourceLoaderDelegate {
    public func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool {
        guard let usersAccessToken = self.usersAccessToken else {
            return false
        }
        
        var redirectRequest = URLRequest(url: loadingRequest.request.url!)
        redirectRequest.setValue("Bearer \(usersAccessToken)", forHTTPHeaderField: "Authorization")
        loadingRequest.redirect = redirectRequest
        loadingRequest.finishLoading()
        return true
    }
}

But this doesn't add the http headers to the video.key request

HTTPS and other ports?

Really interesting solution.
Should this work with https urls? I'm getting an SSL error.

Also, I have an http audio stream url which requires connecting to port 8000.

Would I need to set up the reserve proxy for each of them? But using localhost port 443 for the secure urls and 8000 for the stream? (ie: To match them)

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.