Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question VideoPlayer url header

Discussion in 'Audio & Video' started by danb1, Sep 23, 2021.

  1. danb1

    danb1

    Joined:
    Jun 14, 2019
    Posts:
    24
    Hello,

    Does anybody know if it's possible to add an HTTP header to a VideoPlayer url? I need to pass a username/password to my server when downloading an mp4 file...

    Thanks!
     
  2. Andrew_S1

    Andrew_S1

    Joined:
    Oct 10, 2018
    Posts:
    5
  3. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    Unfortunately, you can't do it directly in the VideoPlayer. What you need to do is use an UnityWebRequest and SetRequestHeader. You can then set the VideoPlayer.url to the downloaded file path when the file has finished downloading. It is a pain to manage, and we want to improve this. I sent your feedback for this feature to the team.
     
  4. danb1

    danb1

    Joined:
    Jun 14, 2019
    Posts:
    24
    Thanks for the update about that -- still helpful to know that you can do this by downloading the file directly!
     
  5. mattsoftwaredev

    mattsoftwaredev

    Joined:
    Jan 3, 2020
    Posts:
    1
    Can this be done in WebGL without the user saving the video file to disk? I have clients who need to play videos hosted on 3rd party servers where the video can't be accessed without including an auth token in the header. The inability to add the token to the VideoPlayer's request header is turning into a big obstacle for us.
     
  6. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    Unfortunately, no, and we know it is a big issue. I recommend anyone with this issue add your feedback to our roadmap so we can work on this. https://unity.com/roadmap/unity-platform/audio-video
     
    mattsoftwaredev likes this.