Closed syedali1621 closed 5 years ago
Thanks for getting in touch. Whilst sending request headers is something we partially support (see platform list below), playing directly out of an AWS S3 bucket is something we have not tried.
To send send the data you will need to use the following 'open' function call:
bool OpenVideoFromFile(string path, long offset, string httpHeaderJson, uint sourceSamplerate = 0, uint sourceChannels = 0, int forceFileFormat = 0)
This can be used as follows: MediaPlayer.Control.OpenVideoFromFile(...)
The header information (httpHeaderJson) is structured as JSON data pairs. For example:
{ "param1": "hello", "param2": "world" }
Do let us know how you get on, and if we can help further.
Currently supported platform list:
Apple platforms: yes Android MediaPlayer API path: yes Android ExoPlayer API path: no (adding support is being looked into currently) Windows: no
i tried different ways in avpro simple controller script but it is not working and also this below function is not available. can you please share example code so i can better understand how to call video with header in avpro player ? Thank you MediaPlayer.Control.OpenVideoFromFile(...)
You can also add the JSON via the UI here:
In the simpleController script you can also set this field via:
_mediaPlayer.PlatformOptionsAndroid.httpHeaderJson = myJson; _mediaPlayer.PlatformOptionsIOS.httpHeaderJson = myJson; _mediaPlayer.PlatformOptionsMacOSX.httpHeaderJson = myJson;
After that, any time the video URL is opened on those platforms it use your json for custom HTTP headers.
I tried to add header via UI as you mentioned but still it is not playing my video. Below is my video url and my header.
https://dahajiexknxpy.cloudfront.net/Bear.mp4 ["mysupersecretheader":"MySuperSecretHeaderValue"]
@syedali1621 which platform is this on? Also, shouldn't the JSON be: { "mysupersecretheader":"MySuperSecretHeaderValue" }
As far as Android is concerned...
I have just tested your video using the header: { "mysupersecretheader":"MySuperSecretHeaderValue" }
I can playback your video on Android using the MediaPlayer API path, and also with a code fix using the ExoPlayer API path. The fix for ExoPlayer API path will be version >= 1.9.18
yes it is playing with header in unity for android and iphone.
Thank you
@AndrewRH would this work for Web? (i.e. unity built for webgl)
Is there a solution for webGL player for requesting URL with http headers
My videos are stored on AWS S3 bucket with security. To access my videos i need to send request with header can anyone please let me know how can i send request to my video with my secret header using avprovideoplayer unity ?