GithubHelp home page GithubHelp logo

ydhao / flashphoner_client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flashphoner/flashphoner_client

0.0 0.0 0.0 57.98 MB

Client for Flashphoner-server

Home Page: http://flashphoner.com

ActionScript 10.15% CSS 2.42% JavaScript 87.08% HTML 0.35%

flashphoner_client's Introduction

@flashphoner/websdk

Flashphoner WebCallServer JavaScript API (Web SDK)

Flashphoner WebCallServer JavaScript API (Web SDK) implementation.

Install

npm install @flashphoner/websdk

Using prebuild Javascript bundle in browser

two-way-streaming.html:

<!DOCTYPE html>
<html lang="en">
<head> 
    <script type="text/javascript" src="node_modules/@flashphoner/websdk/flashphoner.js"></script> 
    <script type="text/javascript" src="two-way-streaming.js"></script> 
</head>
<body onload="init_api()">
    <div id="publish" style="width:320px;height:240px;border: solid 1px"></div>
    <br/><button id="publishBtn">Publish</button><br/>
    <br/>
    <div id="play" style="width:320px;height:240px;border: solid 1px"></div>
    <br/><button id="playBtn">Play</button><br/>
    <br/>
    <br/><button id="stopBtn">Stop</button><br/>
</body>
</html>

two-way-streaming.js:

//Constants
var SESSION_STATUS = Flashphoner.constants.SESSION_STATUS;
var STREAM_STATUS = Flashphoner.constants.STREAM_STATUS;
var session;
var stream;
  
//Init Flashphoner API on page load
function init_api() {
    Flashphoner.init({});
    publishBtn.onclick = connect;
    playBtn.onclick = playStream;
    stopBtn.onclick = stopPublish;
}
  
//Connect to WCS server over websockets
function connect() {
    session = Flashphoner.createSession({
        urlServer: "wss://demo.flashphoner.com"
    }).on(SESSION_STATUS.ESTABLISHED, function(session) {
        publishStream(session);
    });
}
  
//Publish stream
function publishStream(session) {
    stream = session.createStream({
        name: "stream",
        display: document.getElementById("publish"),
    });
    stream.publish();
}
  
//Playing stream
function playStream() {
    session.createStream({
        name: "stream",
        display: document.getElementById("play"),
    }).play();
}
 
//Stopping stream
function stopPublish() {
    stream.stop();
}

More examples

Please look for more examples on GitHub and on this page

Documentation

Please read the details here and API docs here

Known issues

WebSDK is build with webrtc/adapter library version not lower than 7.2.6. In this regard, direct use of this library together with WebSDK should be avoided.

flashphoner_client's People

Contributors

camaross avatar flashphoner avatar

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.