Skip to content

Commit

Permalink
Update documentation (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaDemchenko authored Jul 19, 2024
1 parent 363038f commit 8101d30
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
[![npm version](https://img.shields.io/npm/v/p2p-media-loader-core?logo=npm&logoColor=white)](https://npmjs.com/package/p2p-media-loader-core)
[![jsDelivr hits (npm)](https://data.jsdelivr.com/v1/package/npm/p2p-media-loader-core/badge?style=rounded)](https://www.jsdelivr.com/package/npm/p2p-media-loader-core)



**P2P Media Loader** is an open-source JavaScript library that leverages modern web browser features, such as HTML5 video and WebRTC, to enable media delivery over peer-to-peer (P2P) connections. It integrates smoothly with many popular HTML5 video players and works entirely without browser plugins or add-ons. Experience it in action with the [demo](http://novage.com.ua/p2p-media-loader/demo.html).

By leveraging P2P technology, it greatly reduces reliance on traditional content delivery network (CDN) resources, lowers costs, and enhances the ability to deliver media streams to a larger audience.
Expand Down Expand Up @@ -41,7 +39,7 @@ This library enables the creation of a huge P2P mesh networks, also known as pee
- Supports live and VOD streams over HLS or MPEG-DASH protocols
- Supports multiple HTML5 video players and engines:
- Engines: Hls.js, Shaka Player
- Video players: [Vidstack](https://www.vidstack.io/), [Clappr](http://clappr.io/), [MediaElement](https://www.mediaelementjs.com/), [Plyr](https://plyr.io/), [DPlayer](https://dplayer.diygod.dev/), [OpenPlayerJS](https://www.openplayerjs.com/), and others that support Hls.js or Shaka video engines. These players can be integrated via custom integration with the library API.
- Video players: [Vidstack](https://www.vidstack.io/), [Clappr](http://clappr.io/), [MediaElement](https://www.mediaelementjs.com/), [Plyr](https://plyr.io/), [DPlayer](https://dplayer.diygod.dev/), [OpenPlayerJS](https://www.openplayerjs.com/), [PlayerJS](https://playerjs.com/) , and others that support Hls.js or Shaka video engines. These players can be integrated via custom integration with the library API.
- Supports adaptive bitrate streaming of HLS and MPEG-DASH protocols
- There is no need for server-side software for simple use cases. By default **P2P Media Loader** uses publicly available servers:
- WebTorrent trackers - [https://tracker.novage.com.ua/](https://tracker.novage.com.ua/), [https://tracker.webtorrent.dev/](https://tracker.webtorrent.dev/), [https://openwebtorrent.com/](https://openwebtorrent.com/)
Expand Down
28 changes: 28 additions & 0 deletions api_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,34 @@ For more examples with npm packages, you may check our [React demo](https://gith
</script>
```
### **Integrating P2P with PlayerJS and Hls.js**
```html
<script type="module">
import { HlsJsP2PEngine } from "p2p-media-loader-hlsjs";
window.Hls = HlsJsP2PEngine.injectMixin(window.Hls);
const player = new Playerjs({
id: "player",
hlsconfig: {
p2p: {
core: {
swarmId: "Optional custom swarm ID for stream",
// Other P2P engine config parameters go here
},
onHlsJsCreated: (hls) => {
// Subscribe to P2P engine and Hls.js events here
hls.p2pEngine.addEventListener("onPeerConnect", (details) => {
console.log(`Connected to peer ${details.peerId})`);
});
},
},
},
});
</script>
```
### **Integrating P2P with DPlayer and Hls.js**
```html
Expand Down
9 changes: 6 additions & 3 deletions packages/p2p-media-loader-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export type StreamConfig = {
*
* @default
* ```typescript
* simultaneousHttpDownloads: 3
* simultaneousHttpDownloads: 2
* ```
*/
simultaneousHttpDownloads: number;
Expand Down Expand Up @@ -264,7 +264,7 @@ export type StreamConfig = {
*
* @default
* ```typescript
* p2pNotReceivingBytesTimeoutMs: 1000
* p2pNotReceivingBytesTimeoutMs: 2000
* ```
*/
p2pNotReceivingBytesTimeoutMs: number;
Expand All @@ -284,7 +284,7 @@ export type StreamConfig = {
*
* @default
* ```typescript
* httpNotReceivingBytesTimeoutMs: 1000
* httpNotReceivingBytesTimeoutMs: 3000
* ```
*/
httpNotReceivingBytesTimeoutMs: number;
Expand Down Expand Up @@ -312,6 +312,9 @@ export type StreamConfig = {
/**
* List of URLs to the WebTorrent trackers used for announcing and discovering peers (i.e. WebRTC signaling).
*
* WARNING: In the Safari browser, only the first tracker will be used. Safari has issues with multiple trackers,
* leading to problems with sending SDP messages for WebRTC signaling.
*
* @default
* The default trackers used are:
* ```typescript
Expand Down

0 comments on commit 8101d30

Please sign in to comment.