Skip to content

Instantly share code, notes, and snippets.

@NandoKstroNet
Last active January 3, 2022 11:37
Show Gist options
  • Save NandoKstroNet/6ca5906ba03b324f1a69157076d5bc1a to your computer and use it in GitHub Desktop.
Save NandoKstroNet/6ca5906ba03b324f1a69157076d5bc1a to your computer and use it in GitHub Desktop.
Componente Player projeto VideoFlix, curso Laravel Mastery em https://laravelmastery.com.br
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">
<!-- Styles -->
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
@livewireStyles
@stack('head')
</head>
<body class="font-sans antialiased">
<div class="bg-gray-100">
<main>
{{ $slot }}
</main>
</div>
@livewireScripts
@stack('scripts')
</body>
</html>
<div>
<div id="player"></div>
@push('head')
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@clappr/player@latest/dist/clappr.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/clappr.level-selector/latest/level-selector.min.js"></script>
<style>
/* https://github.com/clappr/clappr/issues/402#issuecomment-561549413 */
/* Fix the player container to take up 100% width and to calculate its height based on its children. */
[data-player] {
position: relative;
width: 100vw;
height: 100vh;
margin: 0;
}
/* Fix the video container to take up 100% width and to calculate its height based on its children. */
[data-player] .container[data-container] {
width: 100vw;
height: 100vh;
position: relative;
}
/* Fix the media-control element to take up the entire size of the player. */
[data-player] .media-control[data-media-control] {
top: 0;
right: 0;
bottom: 0;
left: 0;
}
/* Fix the video element to take up 100% width and to calculate its height based on its natural aspect ratio. */
[data-player] video {
position: relative;
display: block;
width: 100vw;
height: 100vh;
}
</style>
@endpush
@push('scripts')
<script>
var player = new Clappr.Player({
source: "{{url('resources/' . $video->code . '/' . $video->processed_video)}}",
width: "100%",
height: "auto",
parentId: "#player",
mimeType: "application/x-mpegURL",
plugins: {"core": [LevelSelector]}
});
</script>
@endpush
</div>
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\Video;
class Player extends Component
{
public $video;
public function mount(Video $video)
{
$this->video = $video;
}
public function render()
{
return view('livewire.player')->layout('layouts.player');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment