Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

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

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

Already on GitHub? # to your account

Embedding the service worker in other apps for streaming big media files #534

Closed
lhns opened this issue Dec 21, 2024 · 4 comments
Closed
Labels
need/author-input Needs input from the original author need/triage Needs initial labeling and prioritization

Comments

@lhns
Copy link

lhns commented Dec 21, 2024

I find this project very fascinating because it really opens up IPFS for real-world use.
I've played around with helia-verified-fetch and it works pretty well but it cannot be used with stuff like media elements containing big media files which have to be streamed.
A service worker like this one would make it possible.
If it was easy to integrate the ServiceWorker into other projects which might not be hosted on IPFS it could be used to load media files like images, audio or videos from IPFS in a streaming fashion.

@lidel
Copy link
Member

lidel commented Jan 13, 2025

This project is using https://www.npmjs.com/package/@helia/verified-fetch under the hood.

@lhns if you had issues with streaming big files, that is a bug. Mind providing a steps to reproduce?

@lidel lidel added need/author-input Needs input from the original author need/triage Needs initial labeling and prioritization labels Jan 13, 2025
@lidel lidel changed the title Library to integrate the ServiceWorker into other projects Issue with streaming big media files Jan 13, 2025
@lidel lidel added the bug Something isn't working label Jan 13, 2025
@SgtPooki
Copy link
Member

@lhns it sounds like streaming isn't necessarily broken for you, but the way verified-fetch has to be used doesn't work for streaming because you can't pass the response to <video> elements. Is that correct?

How would you be using the service worker in your application? We have discussed creating a workbox plugin that would make it easier for devs to add the service-worker-gateway to their applications, would that work for you?

@lhns
Copy link
Author

lhns commented Jan 13, 2025

@lhns it sounds like streaming isn't necessarily broken for you, but the way verified-fetch has to be used doesn't work for streaming because you can't pass the response to <video> elements. Is that correct?

How would you be using the service worker in your application? We have discussed creating a workbox plugin that would make it easier for devs to add the service-worker-gateway to their applications, would that work for you?

Yes this is correct! I think a workbox plugin would be a nice approach. My use case is pretty much as you described it. I want to use ipfs urls as the source of media elements like video and audio but by using this approch it could be applied to any asset of a web application using the standard fetch api.

@2color 2color removed the bug Something isn't working label Jan 14, 2025
@2color
Copy link
Member

2color commented Jan 14, 2025

@lhns You can try out loading Big Buck Bunny with the Service Worker Gateway:
https://bafybeidsp6fva53dexzjycntiucts57ftecajcn5omzfgjx57pqfy3kwbq.ipfs.inbrowser.link/

You could potentially embed this as an iframe, but it's not ideal having a new origin with its own service worker for each CID you load.

A Workbox plugin is something we want to explore (but have no timeline currently), as it gives you full control over the SW lifecycle and doesn't require a new origin for each CID.

@2color 2color changed the title Issue with streaming big media files Embedding the service worker in other apps for streaming big media files Jan 14, 2025
@ipfs ipfs locked and limited conversation to collaborators Jan 14, 2025
@2color 2color converted this issue into discussion #543 Jan 14, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
need/author-input Needs input from the original author need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

4 participants