Novage / p2p-media-loader

An open-source engine for P2P streaming of live and on demand video directly in a web browser HTML page
https://novage.com.ua/p2p-media-loader/demo.html
Apache License 2.0
1.4k stars 310 forks source link

Module "events" has been externalized for browser compatibility. Cannot access "events.EventEmitter" in client code #385

Closed nvtienlg closed 2 months ago

nvtienlg commented 2 months ago

Hello,

I created a vanilla js project using Vite, import this lib will result in mentioned error npm create vite@latest ... npm install p2p-media-loader-hlsjs hls.js

in main.js import Hls from 'hls.js'; import { HlsJsP2PEngine } from 'p2p-media-loader-hlsjs';

Screenshot 2024-07-01 at 12 24 02 Screenshot 2024-07-01 at 12 22 25

If i try using importmap method then everything is fine. But since importmap is not fully supported by all browsers, so i prefer to use npm method. Can you check this?

mrlika commented 2 months ago

Hi @nvtienlg, I think Node polyfills required by bittorrent-tracker package are missing. Check our Vite config for the reference: https://github.com/Novage/p2p-media-loader/blob/main/demo/vite.config.ts

nvtienlg commented 2 months ago

thank you very much @mrlika . it works