Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appending to existing tags INSIDE the Video tag for JPEG image ? #1525

Closed
C0nw0nk opened this issue Oct 9, 2018 · 3 comments
Closed

Appending to existing tags INSIDE the Video tag for JPEG image ? #1525

C0nw0nk opened this issue Oct 9, 2018 · 3 comments

Comments

@C0nw0nk
Copy link

@C0nw0nk C0nw0nk commented Oct 9, 2018

Setting the downloaded from torrent jpeg file into the tags poster and <img>

<video controls="controls" controlslist="nodownload" oncontextmenu="return false;" preload="none" poster="/">
<source src="/" type="video/mp4" /> <object width="800" height="450" type="application/x-shockwave-flash" data="/player.swf">
<param name="movie" value="/player.swf" />
<param name="flashvars" value="controls=true&amp;file=" />
<img src="/" width="800" height="450" alt="No suitable players" title="No video playback capabilities" /> </object>
</video>
<script type="text/javascript">
var client = new WebTorrent();
var torrentId = 'magnet:?xt=urn:btih:blah-bleep-bloop';

client.add(torrentId, function (torrent) {

torrent.addWebSeed('https://www.domain.com/jpeg.jpg')

console.log('Torrent Ready')
var file = torrent.files.find(function (file) {
	return file.name.endsWith('.jpg')
})

var append_to_tag = document.getElementsByTagName('video')[0].poster;
//file.appendTo(append_to_tag)
file.appendTo('video#img')
file.getBlobURL(function (err, url) {
if (err) throw console.log(err)
append_to_tag = url
console.log('Client is downloading:' + append_to_tag)
})

})
</script>

I have been trying with

file.appendTo('video#img')
file.appendTo('video#poster')

But I can't get it to display even though I can see in the console it has downloaded and is ready etc.

The Javascript methods I am used to are like this document.getElementsByTagName('video')[0].poster = "https://www.domain.com/jpeg.jpg";

Can anyone help me set the downloaded from torrent jpeg file into those tags ?

@Daniel-Abrecht

This comment has been minimized.

Copy link

@Daniel-Abrecht Daniel-Abrecht commented Oct 9, 2018

Here is a minimal example: https://jsfiddle.net/yj4kuszr/
I've also a library to hide all webtorrent specific things and allows magnet urls to be used like any other url: https://github.com/Daniel-Abrecht/magnet-protocolhandler

There may be other ways to do this, this is just how I usually do it.

@jimmywarting

This comment has been minimized.

Copy link
Contributor

@jimmywarting jimmywarting commented Oct 9, 2018

player.swf? remove that toxic thing!

@C0nw0nk

This comment has been minimized.

Copy link
Author

@C0nw0nk C0nw0nk commented Oct 10, 2018

player.swf? remove that toxic thing!

It is just in there as a fallback player for compatibility with older browsers / devices modern and uptodate devices use HTML5.

Here is a minimal example: https://jsfiddle.net/yj4kuszr/
I've also a library to hide all webtorrent specific things and allows magnet urls to be used like any other url: https://github.com/Daniel-Abrecht/magnet-protocolhandler

There may be other ways to do this, this is just how I usually do it.

Thank you! strange it works with the .poster missing but appended to the variable instead but oh well it works now :)

@C0nw0nk C0nw0nk closed this Oct 10, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.