Giter Site home page Giter Site logo

augok / p2p-hls Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 3.0 321 KB

A JavaScript library based on hls.js to implement video traffic delivery over P2P streaming in web browsers HTML page.

Home Page: https://webp2p.augok.com/

License: Apache License 2.0

CSS 11.71% HTML 88.29%
dplayer hls hlsjs p2p p2p-network video webrtc web webp2p

p2p-hls's Introduction

P2P-hls

P2P hls is a JavaScript library based on hls.js to implement video traffic delivery over P2P in web browsers.

It allows creating Peer-to-Peer network (also called P2P CDN or P2PTV) for traffic sharing between users (peers) that are watching the same video stream live or VOD over HLS.

Powered by hls.js, it can play HLS on any platform with many popular HTML5 players.

It significantly reduces traditional CDN traffic and cost while delivering video streams to more users.

Save Your Bandwidth using WebRTC.

Useful Demo

Homepage

https://webp2p.augok.com

Free!! Use directly!

Problems caused by CDN have been fixed!!!

https://webp2p.augok.com/player/?url=

Example

https://webp2p.augok.com/p2pdemo/?url=https://m3u8.link.address/video.m3u8

Quick Start

Load the latest CDN hosted version of JavaScript library.

Add these tags to your document's <head>:

<script src="https://unpkg.com/webp2p-hls@latest/p2pl.js"></script>
<script src="https://unpkg.com/webp2p-hls@latest/p2ph.js"></script>
<script src="https://unpkg.com/webp2p-hls@latest/p2phls.js"></script>

Then there's a free, CDN hosted version of hls.js that anyone can use. Add these tags to your document's <head>:

<script src="https://unpkg.com/[email protected]/index.js"></script>

Example by DPlayer

<script src="https://unpkg.com/webp2p-hls@latest/p2pl.js"></script>
<script src="https://unpkg.com/webp2p-hls@latest/p2ph.js"></script>
<script src="https://unpkg.com/webp2p-hls@latest/p2phls.js"></script>
<script src="https://unpkg.com/[email protected]/index.js"></script>
<!-- unpkg : use the latest version of DPlayer.js -->
<script src="https://unpkg.com/dplayer/dist/DPlayer.min.js"></script>
// url is link address.
var p2phls = new P2Phls(url);

var player = new DPlayer({
    container: document.getElementById('video'),
    autoplay: true,
    preload: 'auto',
    video: {
        url: url,
        type: 'customHls',
        customType: {
            'customHls': function(video, player) {
                var hls = new Hls({
                    liveSyncDurationCount: 7,
                    loader: p2phls.getLoader()
                });
                p2phls.initHlsPlayer(hls);

                hls.loadSource(video.src);
                hls.attachMedia(video);
            }
        }
    }
});

API

isP2P()

Determine whether to support P2P.

// p2phls is new P2Phls(url) object
p2phls.isP2P()
// return true or false

isHls()

Determine whether to support Hls.

// p2phls is new P2Phls(url) object
p2phls.isHls()
// return true or false

Event

bytechange

Monitor traffic download btye.

// p2phls is new P2Phls(url) object
p2phls.on('bytechange', function(data){
    var httpMb = data.http; // http traffic download btyes
    var p2pMb = data.p2p; // p2p traffic download btyes
});

peers

Monitor P2P peers connections.

// p2phls is new P2Phls(url) object
p2phls.on('peers', function(num,peer){
    num; //peers num
    peer; // peer detail object
});

See p2pdemo for more...

Contact Us

Telegram: @augok009

p2p-hls's People

Contributors

augok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

p2p-hls's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.