This is a live streaming app example using our inLive JS SDK. It doesn't use any build tool to simplify and make it easier to understand.
← README.md
: That's this file, where we tell about what our website does and how we built it.
← index.html
: This is the main web page for the streamer site.
← live.html
: This is the main web page for the viewer site when streamers still go on live.
← style.css
: CSS files add styling. However, we also use Tailwind CSS on the page.
← script.mjs
: Interactivity of the buttons & APIs with Javascript function.
Open each file and check out the comments (in gray).
- Open studio.inlive.app on your browser and login with your Google or Github account.
- Go to the integration page.
- Create an application key. Make sure you copy the key after you create it because you won’t be able to see it again later.
Because this app is not using any build tool, it's not coming with any built-in HTTP server. To be able to access the web app locally, you will need to install an HTTP server. For example, here we're using http-server. Feel free to use another HTTP server that you prefer. To install http-server and run it you can follow these steps:
- Make sure you have NodeJS and NPM installed.
- Switch to this repo directory
- Install the http-server module globally by run
npm i -g http-server
in your terminal - Run the http-server by running `http-server``
- Then you should be able to access this web app using your browser at http://localhost:8080
From preparing API Key above step, find these lines in script.mjs
and input your API key.
const app = InliveApp.init({
apiKey:'<your-api-key-here>',
api:{
baseUrl:'https://dev-api.inlive.app' // change the default origin
}
})
- You need to create a new stream. Type your new stream name in the input field.
- Hit the
Create Stream
button. It triggerscreateStream
function which will send the input field value (number 1) to the create stream API and send a return stream id & slug that we will use for streaming. If you haven't type any name on the input field, it will randomize its own name. - Hit the
Start Stream
button. It triggersstartStream
function which initialprepareStream
,initStream
, andstartStreaming
function. Notes: It will take a while for streaming to start. It will show textStreaming started!
up the buttons if this step is completed. Notes: Using dynamic id on the API. - After step 3, it means you already go live!
- Hit the
Get Stream
button after textStreaming started!
appears. It triggersgetStream
function and return a link to view your own video live streaming (automaticly copied). - Paste the link on your browser to view (will be played by shaka player). Notes: For those who would like to use the manifest URL, it will show on the below text. You can test the manifest URL with any HLS or Dash compatible player.
- Hit
End Stream
button. It triggersendStream
function and an alert of a textStreaming ended!
will show if successfully ended.