Created
May 23, 2018 06:45
-
-
Save picasso250/749df8ce2514a3ef3a9b9978645f6a7e to your computer and use it in GitHub Desktop.
player for youtube-dl (with sub titles) https://rg3.github.io/youtube-dl/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$name = isset($_GET['name'])?trim($_GET['name']):''; | |
if ($name === '') { | |
$list = glob("*.mp4"); | |
} | |
function get_sub_title($name) { | |
$file = "$name.en.vtt"; | |
if (is_file($file)) return $file; else return false; | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>video player</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" type="text/css" media="screen" href="main.css" /> | |
<script src="main.js"></script> | |
</head> | |
<body> | |
<?php if ($name === ''): ?> | |
<ul> | |
<?php foreach ($list as $name): ?> | |
<li><a href="?name=<?= htmlentities($name) ?>"><?= htmlentities($name) ?></a></li> | |
<?php endforeach ?> | |
</ul> | |
<?php else: ?> | |
<!-- Simple video example --> | |
<!-- 'Big Buck Bunny' licensed under CC 3.0 by the Blender foundation. Hosted by archive.org --> | |
<!-- Poster from peach.blender.org --> | |
<video controls | |
src="/<?= htmlentities($name) ?>" | |
width="1280"> | |
<?php if ($subtitle=get_sub_title(substr($name,0,strlen($name)-4))): ?> | |
<track label="English" kind="subtitles" srclang="en" src="/<?= htmlentities($subtitle) ?>" default> | |
<?php endif ?> | |
Sorry, your browser doesn't support embedded videos, | |
but don't worry, you can <a href="https://archive.org/details/BigBuckBunny_124">download it</a> | |
and watch it with your favorite video player! | |
</video> | |
<?php endif ?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment