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
[Feature proposition] Allow to render a torrent into an existing element #425
Conversation
Any comment on this feature? |
I like it. I've wanted this myself. |
I'm work under #531 render-to method does not include yet to main branch :( Do you have the patch as standalone javascript file to include as the second after: |
@feross I rebased the PR, ready to merge in master! I'd like a review and approval of other WebTorrent contributors before merging, do you know who to ping? Thanks. :) |
} | ||
|
||
function fatalError (err) { | ||
err.message = 'Error appending file "' + file.name + '" to DOM: ' + err.message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't be accurate anymore, because "appending"
It looks pretty good to me, but if you don't mind a little unsolicited feedback, I'd call |
@devtristan Thanks for your comments, I fixed the error message and renamed |
* Update 'handle' (previously 'append-to') to take a 'getElem' function instead of directly a root element, allowing to custimize the element injection method, and without directly manipulating the DOM. * Reimplement 'append-to' using abstract 'handle' method. * Implement a 'render-to' method to render a torrent inside an existing element.
if (err) return fatalError(err) | ||
elem.src = url | ||
elem.alt = file.name | ||
cb(null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be cb(null, elem)
@valeriangalliat Thanks for the good PR! It has a few issues (mentioned as inline comments), but I can fix those up after merge. You rock! |
[Feature proposition] Allow to render a torrent into an existing element
Released as 0.65.0. |
Awesome, thanks for fixing the issues! |
No problem. Thanks for taking the initiative to fix the issue :) I really appreciate that. |
Thanks a lot! Any plans to add "renderTo" method to "https://cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js" ? |
@RomanEmelyanov The new code should be available at that url. You might need to clear your cache to see it. |
What I'm do wrong?
|
SOLVED: I'm forget to add "controls" and "autoplay" for |
So if I put controls and autoplay on a element and you Also what does it do when the torrent file is not a video and I set it to render to a video tag? |
The default is
It will try to put the file data into the video tag which will just make the video tag fire an |
@feross Thanks. But I need to disable autoplay and I was thinking it would be convenient to use Between the lines you answered my question with "No". So the |
You can disable autoplay by passing an |
I know and I do this now.
|
This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue. |
Like
file.appendTo
, but taking an existing element as parameter, for example:See the
Implement 'render-to' method
commit to have a proper diff, becauseappend-to.js
was renamed torender.js
and it's messing the full PR diff.Related: #531.