git ssb

0+

dangerousbeans / etherstreams



Tree: 787b951e7dc923dce3d3c88e2d38cb36c75a765b

Files: 787b951e7dc923dce3d3c88e2d38cb36c75a765b / src / components / EthVideo.vue

2188 bytesRaw
1<template>
2 <div class='col-sm-12'>
3 <div class='embed-responsive'>
4 <div class='video'>
5 <MoonLoader ></MoonLoader>
6 </div>
7 </div>
8
9 </hr>
10
11
12 <span class="">
13 <h2>
14 ๐Ÿ’•
15 </h2>
16 </span>
17 </div>
18</template>
19
20<script>
21var WebTorrent = require('webtorrent')
22import MoonLoader from './Loader'
23
24export default {
25 name: "ethvideo",
26 props: ['magnet', 'video'],
27 components: { 'MoonLoader': MoonLoader },
28 data () {
29 return {
30 loading: true,
31 color: "black",
32 size: "20em"
33 }
34 },
35
36 mounted: function() {
37 // var torrentId = this.magnet
38 var client = new WebTorrent()
39
40 console.log("torrent id")
41
42 console.log(unescape(this.magnet))
43
44 // Hack on extra trackers incase there are none
45 var magnetURI = unescape(this.magnet + '&tr=wss://tracker.openwebtorrent.com&tr=wss://tracker.btorrent.xyz&tr=wss://tracker.fastcast.nz')
46
47
48 client.add(magnetURI, function (torrent) {
49 // Got torrent metadata
50 console.log('Client is downloading:', torrent.infoHash)
51
52 var content_file
53
54 if(torrent.files.length == 1)
55 {
56 content_file = torrent.files[0]
57 }
58 else {
59 torrent.files.forEach(function (file) {
60 console.log(file)
61 var name = file.name.toLowerCase()
62
63 // If this is renderable content
64 if(/\.(mp4|m4v|webm|ogg|mp3)$/i.test(name))
65 {
66 // make it the file to render unless there is a bigger file
67 if(content_file == null)
68 {
69 content_file = file
70 }
71 else if(file.length > content_file.length)
72 {
73 content_file = file
74 }
75 }
76 })
77 }
78
79 console.log(content_file)
80 if(content_file)
81 {
82 content_file.appendTo('.video')
83 }
84 else
85 {
86 alert("Unable to render any files from torrent")
87 }
88
89 })
90 }
91}
92
93
94</script>
95
96<style scoped>
97 .video
98 {
99 background: black;
100 min-height: 600px;
101 }
102
103 .v-spinner
104 {
105 position: absolute;
106 bottom: 50%;
107 left: 50%;
108 margin-left: -30px;
109 margin-bottom: -30px;
110 }
111</style>
112

Built with git-ssb-web