Secure video player for Laravel

Built your course site with Laravel? One request from a controller shows the XAPlayer secure player in Blade to users who bought the course.

Why XAPlayer for Laravel

  • One request, no SDK

    Laravel’s Http client gets a short-lived token; no extra package, no complex setup.

  • Key in .env

    The API key stays in .env and config/services.php and never reaches the browser.

  • Purchase check with Gate

    You control access with Gate and your own models; XAPlayer just plays the video securely.

  • User name on the video

    The Laravel user’s name and phone become the moving watermark.

Three steps to secure playback

  1. Put the API key and URL in .env.
  2. In the controller, after the purchase check, get a token from XAPlayer.
  3. Show the player URL in an iframe in Blade.

Tutorials and docs

A taste of the code

The full code, where it goes and how to test it are in the tutorial.

app/Http/Controllers/LessonController.php
$res = Http::withToken(config('services.xaplayer.key'))
    ->post(config('services.xaplayer.url') . '/embed-tokens', [
        'courseId' => $course->xaplayer_course_id,
        'viewer'   => ['id' => (string) $user->id, 'name' => $user->name],
    ]);

return view('watch', ['url' => $res->json('url')]);

Questions

No. Laravel’s Http client is enough.

Four hours by default, adjustable from one minute to 24 hours. A fresh token is fetched each time the page opens.

Yes. Send that video’s videoId instead of courseId.

Licenses are issued in the panel for now. On your own site you don’t need them: Laravel controls access.

Other platforms

Protect your course today

Signing up takes two minutes. 14 days free, with 10 licenses on us.

Start your 14-day free trial