Search code examples
apache-flexairosmf

OSMF with Basic Authentication


How would one create a video or audio stream using OSMF when there must be basic authentication on the url?

Can one feed in Audio/Video using HTTPService to provide the header authentication?

All the examples available ignore the authentication portion!


Solution

  • credentials is a string with "username:password" encoded in Base64 For Audio:

            private function auth_play(reqestURL:URLRequest) : void {
    
                stream = new Sound();
    
                var credsHeader:URLRequestHeader = new URLRequestHeader("Authorization", "Basic " + credentials);
                reqestURL.requestHeaders.push(credsHeader);
    
                var context:SoundLoaderContext = new SoundLoaderContext(1000, true);
    
                stream.load(reqestURL, context);                
            }
    

    For Video I couldn't find anything but I SUSPECT this will work with netconnection and netstream:

    nc.addHeader("Authorization", true, "Basic " + credentials);