How to play an encrypted video through an API to MVC

Peter le Grand 21 Reputation points
2022-02-11T05:20:18.417+00:00

I want to user Azure Media Services through the portal to upload videos and set the encryption policy there related to the locator.

Once done, I want to use an API and an MVC application both developed in .Net Core to show the video.

The video should be protected thus only be shown for users that are logged in. If they provide the video URL to someone else it should not be shown.


I was able to upload the videos, encode them, have a content policy, and create a locator related to the video and content policy.
I am able to create an API and MVC application.
I could store the URL of the video in a db that is used by the API.

But how do I show the encrypted video in the MVC app including?

Also, I tried it earlier with Blazor but couldn't get the video playing, even without encryption.
Most of the documentation I see is about how to develop video upload functionality, encryption, and locator creation. But that part I can do for now in the Azure portal.

Any suggestions?

Thanks,

Peter

Azure Media Services
Azure Media Services
A group of Azure services that includes encoding, format conversion, on-demand streaming, content protection, and live streaming services.
308 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,227 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,410 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JasonPan - MSFT 4,386 Reputation points Microsoft Vendor
    2022-02-11T09:52:06.413+00:00

    Hi @Peter le Grand ,

    For best practices in azure media service, please refer to the official documentation.

    We recommend using azure media player to play videos. If you familiar with azure media player, you will get a good experience.

    From you description, we know you have save the media source url in your database, so we can generate the token to play the video.

    Reference Code:

    expires: DateTime.Now.AddMinutes(60),

    Console.WriteLine($"https://ampdemo.azureedge.net/?url={dashPath}&playready=true&widevine=true&token=Bearer%3D{token}");

    And the standard format of media source should like:

    https://amssamples.streaming.mediaservices.windows.net/3b970ae0-39d5-44bd-b3a3-3136143d6435/AzureMediaServicesPromo.ism/manifest

    not

    https://amssamples.streaming.mediaservices.windows.net/3b970ae0-39d5-44bd-b3a3-3136143d6435/AzureMediaServicesPromo.mp4 .


    If the answer is helpful, please click "Accept Answer" and upvote it.
    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.

    Best Regards,
    Jason

    0 comments No comments