<!DOCTYPE html>
<html>
<head>
- <title>PeerTube</title>
-
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="robots" content="noindex">
+ <meta property="og:platform" content="PeerTube" />
- <link rel="icon" type="image/png" href="/client/assets/favicon.png" />
+ <script type="text/javascript">
+ // Thanks: https://mathiasbynens.be/notes/globalthis
+ (function() {
+ if (typeof globalThis === 'object') return;
+ Object.prototype.__defineGetter__('__magic__', function() {
+ return this;
+ });
+ __magic__.globalThis = __magic__
+ delete Object.prototype.__magic__;
+ }());
+ </script>
- <link rel="stylesheet" href="/client/assets/video-js/video-js.min.css">
- <link rel="stylesheet" href="/client/assets/video-js/videojs-dock.css">
- <script src="/client/assets/webtorrent/webtorrent.min.js"></script>
- <script src="/client/assets/video-js/video.min.js"></script>
- <script src="/client/assets/video-js/videojs-dock.min.js"></script>
+ <!-- /!\ The following comment is used by the server to prerender some tags /!\ -->
- <style>
- video {
- width: 99%;
- }
+ <!-- title tag -->
+ <!-- description tag -->
+ <!-- custom css tag -->
+ <!-- meta tags -->
+ <!-- server config -->
- /* fill the entire space */
- html, body {
- height: 100%;
- margin: 0;
- }
+ <!-- /!\ Do not remove it /!\ -->
- .video-js {
- width: 100%;
- height: 100%;
- }
+ <link rel="icon" type="image/png" href="/client/assets/images/favicon.png" />
+ </head>
- .vjs-poster {
- background-size: 100% auto;
- }
+ <body id="custom-css" class="standalone-video-embed">
- .vjs-peertube-link {
- color: white;
- text-decoration: none;
- font-size: 1.3em;
- line-height: 2.20;
- transition: all .4s;
- }
+ <div id="error-block">
+ <h1 id="error-title"></h1>
- .vjs-peertube-link:hover {
- text-shadow: 0 0 1em #fff;
- }
+ <div id="error-content"></div>
+ </div>
- </style>
- </head>
+ <div id="video-wrapper"></div>
- <body>
+ <div id="placeholder-preview"></div>
- <video id="video-container" class="video-js vjs-default-skin vjs-big-play-centered">
- </video>
+ <script type="text/javascript">
+ // Can be called in embed.ts
+ window.displayIncompatibleBrowser = function () {
+ const text = 'The player is not compatible with your web browser. Please try latest Firefox version.'
+ document.title = 'Sorry' + ' - ' + text
- <script>
- function loadVideoInfos (videoId, callback) {
- var xhttp = new XMLHttpRequest()
- xhttp.onreadystatechange = function () {
- if (this.readyState === 4 && this.status === 200) {
- var json = JSON.parse(this.responseText)
- return callback(json)
- }
- }
+ const errorBlock = document.getElementById('error-block')
+ errorBlock.style.display = 'flex'
- var url = window.location.origin + '/api/v1/videos/' + videoId
- xhttp.open('GET', url, true)
- xhttp.send()
- }
+ const errorTitle = document.getElementById('error-title')
+ errorTitle.innerHTML = 'Sorry'
- function loadVideoTorrent (magnetUri, player) {
- console.log('Loading video ' + videoId)
- var client = new window.WebTorrent()
+ const errorText = document.getElementById('error-content')
+ errorText.innerHTML = text
- console.log('Adding magnet ' + magnetUri)
- client.add(magnetUri, function (torrent) {
- var file = torrent.files[0]
+ const videoWrapper = document.getElementById('video-wrapper')
+ if (videoWrapper) videoWrapper.style.display = 'none'
- file.renderTo('video', function (err) {
- if (err) {
- console.error(err)
- return
- }
+ const placeholderPreview = document.getElementById('placeholder-preview')
+ if (placeholderPreview) placeholderPreview.style.display = 'none'
+ }
- // Hack to "simulate" src link in video.js >= 6
- // If no, we can't play the video after pausing it
- // https://github.com/videojs/video.js/blob/master/src/js/player.js#L1633
- player.src = function () { return true }
-
- player.play()
- })
- })
- }
-
- var urlParts = window.location.href.split('/')
- var videoId = urlParts[urlParts.length - 1]
-
- loadVideoInfos(videoId, function (videoInfos) {
- var magnetUri = videoInfos.magnetUri
- var videoContainer = document.getElementById('video-container')
- var previewUrl = window.location.protocol + '//' + videoInfos.podHost + videoInfos.previewPath
- videoContainer.poster = previewUrl
-
- videojs('video-container', { controls: true, autoplay: false }, function () {
- var player = this
-
- var Button = videojs.getComponent('Button')
- var peertubeLinkButton = videojs.extend(Button, {
- constructor: function () {
- Button.apply(this, arguments)
- },
-
- createEl: function () {
- var link = document.createElement('a')
- link.href = window.location.href.replace('embed', 'watch')
- link.innerHTML = 'PeerTube'
- link.title = 'Go to the video page'
- link.className = 'vjs-peertube-link'
- link.target = '_blank'
-
- return link
- },
-
- handleClick: function () {
- player.pause()
+ window.onerror = function (msg) {
+ if (typeof msg === 'string' && msg.toLowerCase().includes(' ice ')) {
+ console.warn(msg)
+ return
}
- })
- videojs.registerComponent('PeerTubeLinkButton', peertubeLinkButton)
-
- var controlBar = player.getChild('controlBar')
- var addedLink = controlBar.addChild('PeerTubeLinkButton', {})
- controlBar.el().insertBefore(addedLink.el(), controlBar.fullscreenToggle.el())
- player.dock({
- title: videoInfos.name
- })
+ window.displayIncompatibleBrowser()
+ }
- document.querySelector('.vjs-big-play-button').addEventListener('click', function () {
- loadVideoTorrent(magnetUri, player)
- }, false)
- })
- })
+ if (/MSIE|Trident/.test(window.navigator.userAgent) ) {
+ window.displayIncompatibleBrowser()
+ }
+ </script>
- </script>
</body>
-</html
+</html>