ASP.NET Core Universal Player integration
Download the .NET 10 sample, configure server credentials, authenticate viewers and embed DRM-X 6.0 Universal Player with a protected playback endpoint.
Cara pemutaran diotorisasi
Backend Anda menentukan siapa yang boleh menonton. DRM-X memberikan otorisasi pemutaran. Pemutar menggunakannya untuk meminta lisensi DRM.
- Penonton
Masuk ke layanan Anda dan meminta video.
- Backend Anda
Memeriksa pembelian, langganan, atau izin menonton lainnya milik pengguna.
- DRM-X
Menerapkan aturan yang dipilih dan mengembalikan konfigurasi serta otorisasi pemutaran.
- Pemutar
Menggunakan otorisasi yang diterima untuk meminta lisensi DRM yang diperlukan untuk pemutaran.
Before you begin#
Publish a protected video in DRM-X 6.0 and copy its Content ID. Create server integration credentials with license-tokens:create permission. Keep Site ID, Site Key and Access Key in server configuration; only short-lived playback data reaches the browser.
Serve the learning site over HTTPS. HTTP localhost works only on the same computer; an HTTP LAN address does not provide the secure context required for browser DRM. Test with a supported browser and your actual content.
Run the .NET 10 sample#
Download and extract the ASP.NET Core source ZIP. Open the aspnet directory, configure the server environment variables shown below and run dotnet run. Open http://127.0.0.1:8087 on the same computer. Select a trusted LicensePolicyTemplate in Program.cs that matches your published package.
DRMX_LOCAL_DEMO=1 explicitly enables a local demonstration identity. Remove the demonstration middleware and this switch before deployment, including deployment behind a loopback reverse proxy. Load real credentials through protected host configuration or a secret manager.
$env:DRMX_PLAYBACK_SITE_ID = "your-environment-uuid"
$env:DRMX_PLAYBACK_SITE_KEY = "drmx_your-client-id"
$env:DRMX_PLAYBACK_ACCESS_KEY = "drmx_secret_your-access-key"
$env:DRMX_CONTENT_ID = "your-published-content-id"
$env:DRMX_LOCAL_DEMO = "1"
dotnet runConnect your existing ASP.NET Core application#
Copy DrmXPlaybackEndpoint.cs into your server project. Register AddDrmXPlayback with server-only credentials and policy. Implement IDrmXContentEntitlement using your active purchase, subscription or course records. The check receives ClaimsPrincipal, Content ID, content type and CancellationToken; return false for missing, expired or revoked access.
Register normal authentication and authorization middleware, and call MapDrmXPlaybackSession().RequireAuthorization(). The endpoint derives the viewer from an authenticated NameIdentifier claim. It requires a same-origin Origin header, JSON and a matching authorized content type. Configure trusted reverse proxies so the application sees the public HTTPS scheme and host.
Load the qualified Shaka and Universal Player scripts from the sample page, then embed the Web Component with content-id and session-endpoint. Keep the player page and session endpoint on the same origin. The sample authorizes one configured VOD Content ID; extend the server mapping deliberately when adding Live DRM.
<drmx-universal-player content-id="your-published-content-id"
content-type="vod" session-endpoint="/api/drmx/playback-session">
</drmx-universal-player>Test the application#
Run dotnet run --project tests/DrmX.AspNet.Acceptance.csproj from the extracted repository root. The 17 HTTP checks cover authentication, origin, content/type binding, server-owned policy and identity, revocation and upstream failures. They simulate DRM-X responses. Then test actual protected playback, Stop, renewal and the browsers you support with your own published content.
Integration source downloads · Universal Player Web guide · License policies · DRM for education · Multi-DRM protection
DRM-X 6.0