mirror of https://github.com/Chocobozzz/PeerTube
Prepare embed page
parent
81ca2cd3f4
commit
3bb2c7f99d
|
@ -119,7 +119,7 @@ module.exports = function (options) {
|
||||||
{
|
{
|
||||||
test: /\.html$/,
|
test: /\.html$/,
|
||||||
loader: 'raw-loader',
|
loader: 'raw-loader',
|
||||||
exclude: [ helpers.root('src/index.html') ]
|
exclude: [ helpers.root('src/index.html'), helpers.root('src/standalone/videos/embed.html') ]
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@ -187,6 +187,26 @@ module.exports = function (options) {
|
||||||
{
|
{
|
||||||
from: 'node_modules/webtorrent/webtorrent.min.js',
|
from: 'node_modules/webtorrent/webtorrent.min.js',
|
||||||
to: 'assets/webtorrent'
|
to: 'assets/webtorrent'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: 'node_modules/video.js/dist/video.min.js',
|
||||||
|
to: 'assets/video-js'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: 'node_modules/video.js/dist/video-js.min.css',
|
||||||
|
to: 'assets/video-js'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: 'node_modules/videojs-dock/dist/videojs-dock.min.js',
|
||||||
|
to: 'assets/video-js'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: 'node_modules/videojs-dock/dist/videojs-dock.css',
|
||||||
|
to: 'assets/video-js'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: 'src/standalone',
|
||||||
|
to: 'standalone'
|
||||||
}
|
}
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
@ -213,6 +233,7 @@ module.exports = function (options) {
|
||||||
* See: https://github.com/numical/script-ext-html-webpack-plugin
|
* See: https://github.com/numical/script-ext-html-webpack-plugin
|
||||||
*/
|
*/
|
||||||
new ScriptExtHtmlWebpackPlugin({
|
new ScriptExtHtmlWebpackPlugin({
|
||||||
|
sync: [ 'webtorrent.min.js' ],
|
||||||
defaultAttribute: 'defer'
|
defaultAttribute: 'defer'
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,9 @@
|
||||||
"tslint-loader": "^2.1.4",
|
"tslint-loader": "^2.1.4",
|
||||||
"typescript": "^2.0.0",
|
"typescript": "^2.0.0",
|
||||||
"url-loader": "^0.5.7",
|
"url-loader": "^0.5.7",
|
||||||
|
"video.js": "^5.11.9",
|
||||||
|
"videojs": "^1.0.0",
|
||||||
|
"videojs-dock": "^2.0.2",
|
||||||
"webpack": "2.1.0-beta.25",
|
"webpack": "2.1.0-beta.25",
|
||||||
"webpack-md5-hash": "0.0.5",
|
"webpack-md5-hash": "0.0.5",
|
||||||
"webpack-merge": "^0.15.0",
|
"webpack-merge": "^0.15.0",
|
||||||
|
|
|
@ -62,6 +62,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadVideo() {
|
loadVideo() {
|
||||||
|
|
||||||
|
console.log('<iframe width="560" height="315" src="' + window.location.origin + '/videos/embed/' + this.video.id + '" frameborder="0" allowfullscreen></iframe>');
|
||||||
|
|
||||||
// Reset the error
|
// Reset the error
|
||||||
this.error = false;
|
this.error = false;
|
||||||
// We are loading the video
|
// We are loading the video
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PeerTube</title>
|
||||||
|
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<link rel="icon" type="image/png" href="/client/assets/favicon.png" />
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
video {
|
||||||
|
width: 99%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fill the entire space */
|
||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-js {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vjs-poster {
|
||||||
|
background-size: 100% auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<video id="video-container" class="video-js vjs-default-skin vjs-big-play-centered">
|
||||||
|
</video>
|
||||||
|
|
||||||
|
|
||||||
|
<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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var url = window.location.origin + '/api/v1/videos/' + videoId
|
||||||
|
xhttp.open('GET', url, true)
|
||||||
|
xhttp.send()
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadVideoTorrent (magnetUri) {
|
||||||
|
console.log('Loading video ' + videoId)
|
||||||
|
var client = new window.WebTorrent()
|
||||||
|
|
||||||
|
console.log('Adding magnet ' + magnetUri)
|
||||||
|
client.add(magnetUri, function (torrent) {
|
||||||
|
var file = torrent.files[0]
|
||||||
|
|
||||||
|
file.renderTo('video', { autoplay: true })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var urlParts = window.location.href.split('/')
|
||||||
|
var videoId = urlParts[urlParts.length - 1]
|
||||||
|
var videoContainer = document.getElementById('video-container')
|
||||||
|
|
||||||
|
loadVideoInfos(videoId, function (videoInfos) {
|
||||||
|
var magnetUri = videoInfos.magnetUri
|
||||||
|
var thumbnailUrl = 'http://' + videoInfos.podUrl + videoInfos.thumbnailPath
|
||||||
|
videoContainer.poster = thumbnailUrl
|
||||||
|
|
||||||
|
videojs('video-container', { controls: true, autoplay: false }, function () {
|
||||||
|
var player = this
|
||||||
|
|
||||||
|
player.dock({
|
||||||
|
title: videoInfos.name
|
||||||
|
})
|
||||||
|
|
||||||
|
document.querySelector('.vjs-big-play-button').addEventListener('click', function () {
|
||||||
|
loadVideoTorrent(magnetUri)
|
||||||
|
|
||||||
|
player.play()
|
||||||
|
}, false)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -89,6 +89,9 @@ const thumbnailsPhysicalPath = constants.CONFIG.STORAGE.THUMBNAILS_DIR
|
||||||
app.use(constants.STATIC_PATHS.THUMBNAILS, express.static(thumbnailsPhysicalPath, { maxAge: constants.STATIC_MAX_AGE }))
|
app.use(constants.STATIC_PATHS.THUMBNAILS, express.static(thumbnailsPhysicalPath, { maxAge: constants.STATIC_MAX_AGE }))
|
||||||
|
|
||||||
// Client application
|
// Client application
|
||||||
|
app.use('/videos/embed', function (req, res, next) {
|
||||||
|
res.sendFile(path.join(__dirname, 'client/dist/standalone/videos/embed.html'))
|
||||||
|
})
|
||||||
app.use('/*', function (req, res, next) {
|
app.use('/*', function (req, res, next) {
|
||||||
res.sendFile(path.join(__dirname, 'client/dist/index.html'))
|
res.sendFile(path.join(__dirname, 'client/dist/index.html'))
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue