MAUI MediaElement: How to Include Access Token in Subsequent Video Requests?

Manjunath Vadigeri 0 Reputation points
2024-07-18T01:59:48.6966667+00:00

I'm using MAUI's MediaElement to stream a video from a server. The video is being served as a static resource, and it's protected, so I need to send an access token when requesting the video.

I have the initial URL to fetch the .m3u8 file as follows:

mediaElement.Source = "http://localhost:5099/ContentFiles/Lesson1/index.m3u8?access_token=sampleToken";

Once this .m3u8 file is set as the source, the MediaElement generates the subsequent URLs from the content of the .m3u8 file and starts fetching the video files periodically to play.

Example URLs formed by MediaElement:

http://localhost:5099/ContentFiles/Lesson1/video1.ts 

The issue is that MediaElement sends these requests without an access token, but the .ts video files are protected and require an access token.

Is there any way to instruct MediaElement to include the access token in the subsequent video requests?

Thanks in advance!

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,777 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,369 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 41,601 Reputation points Microsoft Vendor
    2024-07-19T05:42:04.0466667+00:00

    Hello,

    Thanks for your feedback.

    According to the description of MediaElement, this control currently does not provide relevant APIs for access with tokens.

    For this feature, you could publish it as a feature request to the official repository of CommunityToolkit to make our development team aware of it.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.