baraja-core/video-token

There is no license information available for the latest version (v1.0.1) of this package.

Parse video token from user string or URL.

v1.0.1 2021-12-22 10:31 UTC

This package is auto-updated.

Last update: 2024-03-30 00:32:53 UTC


README

Parse video token from user string or URL.

How to use

Detect token from URL:

$token = new \Baraja\VideoToken\VideoToken(
    'https://www.youtube.com/watch?v=_Gi_LQ0a8EA'
);

// or

$token = new \Baraja\VideoToken\VideoToken('_Gi_LQ0a8EA', 'youtube');

echo $token->getToken(); // _Gi_LQ0a8EA
echo $token->getProvider(); // youtube
echo $token->getThumbnailUrl(); // https://img.youtube.com/vi/_Gi_LQ0a8EA/maxresdefault.jpg
echo $token->getUrl(); // https://www.youtube.com/embed/_Gi_LQ0a8EA?rel=0

The input can be a URL from one of the supported video platforms, or a token and provider. The validity of the passed token will be automatically verified.

The operation of getting a preview image can be performance intensive, so always cache the result of the call.