Code Monkey home page Code Monkey logo

kaltura-teleprompter-nodejs's Introduction

Kaltura Teleprompter

A proof of concept that overlays a teleprompter on top of the Kaltura Express Recorder. The Kaltura Editor is then implemented to allow recordings to be trimmed.

Demo App:

https://kaltura-teleprompter.herokuapp.com/

Video Walkthrough of code:

http://www.kaltura.com/tiny/qag4h

Requirements:

  1. Nodejs
  2. Kaltura VPaaS account

Getting Started:

  1. Copy env.template to .env and fill in your information
  2. Run: npm install
  3. For developement run: npm run dev
  4. Or, for production run: npm start

Underneath the hood

High Level Application Architecture

Kaltura Teleprompter is built on Node.js and development began by forking the Kaltura Node.js Template

Essentially, the teleprompter recording UI is a mashup of two projects, the javascript based Kaltura Express Recorder API and https://github.com/manifestinteractive/teleprompter. Event listeners from the Express Recorder are used to synchronize the start time of the teleprompter and the recorder.

The second part of the application is an implementation of the javascript Kaltura Editor API, and its event listeners are used to provide reliable download links and a confusion-free user experience.

Brief API Walkthrough of video from creation to sharing

Recording and uploading

When you first record a video with the javascript Express Recorder, it is saved to the Kaltura Cloud as a MediaEntry which you can access as a developer from the KMC once recording is finished. Each MediaEntry has an entryId which is a unique identifier for that video. The entryId is returned to the Express Recorder javascript object, and the browser is simply redirected to the editor routes/edit.js with the entryID in the url. There is also an option to download the video at this point, which is a built-in feature of the Express Recorder

Recording and Syncing with Teleprompter

When first loading the teleprompter, execution begins in routes/index.js and a Kaltura session is created via

var adminks = await KalturaClientFactory.getKS('', { type: kaltura.enums.SessionType.ADMIN });

The session string is then passed to the UI

 res.render('index', { 
      title: 'Kaltura Teleprompter',
      ks:adminks
 });

And execution proceeds to views/index.ejs

The teleprompter UI

The teleprompter has no knowledge of the recorder and it exists as an <iframe> positioned above the the Express Recorder's UI on the page. The source code for the teleprompter lives in /public/teleprompter-master

When starting and stopping the recorder its event listeners are triggered and then make javascript calls into the iframe. For example, in views/index.ejs start_teleprompter() is called when the recordingStarted of Express Recorder is triggered and stop_teleprompter() is called on recordingEnded

           expRec.instance.addEventListener("recordingStarted", function () {
                console.log("STARTED");
                setTimeout(function () {
                    if (!cancelled) {
                        //call into the iframe of the teleprompter and start it
                        //when the Express Recorder has started
                        document.getElementById("teleframe").contentWindow.start_teleprompter();
                    } else {
                        cancelled = false;
                    }
                }, 3000);
            });
            expRec.instance.addEventListener("recordingEnded", function () {
                console.log("ENDED");
                //call into the iframe of the teleprompter and stop it
                //when the Express Recorder has started
                document.getElementById("teleframe").contentWindow.stop_teleprompter();
            });

As you can see from this example, by taking advantage of Kaltura Express Recorder's event API you can create powerful, seamless integrations with the recorder as this project demonstrates.

When the user is satisfied with their recording, they press the "Upload" button on the UI which will upload their video to the Kaltura Cloud as a MediaEntry. Finally, the upload event is triggered in the UI:

            //when upload of video is complete, redirect user to share
            expRec.instance.addEventListener("mediaUploadEnded", function(event) {
                window.onbeforeunload = null;
                window.location = "/share?entryId="+event.detail.entryId;
            });

And it is the mediaUploadEnded listener that actually triggers the browser to redirect to the share page. Remember, you can access the uploaded MediaEntry from the KMC once it is uploaded.

Sharing The Video

The sharing page is based off https://developer.kaltura.com/player. But before the player is shown, the video must be ready for sharing.

In views/share.ejs

        function poll() {
            $.getJSON("/status?entryId=<%=entryId%>", function (data) {
                if (data['ready']) {
                    //show player
                } else {
                    setTimeout(poll, 3000);
                }
            }
        }
        poll();

the /status method in routes/index.js is polled recursively every 3 seconds until the video is ready.

And when the video is ready, it is displayed:

                if (data['ready']) {
                    $("#spinner").hide();
                    try {
                        var player = KalturaPlayer.setup({
                            targetId: "kaltura-player",
                            provider: {
                                partnerId: <%= process.env.KALTURA_PARTNER_ID %>,
                                uiConfId: <%= process.env.KALTURA_RECPLAYER_ID %>
                            }
                        });
                        //load first entry in player
                        player.loadMedia({ entryId: '<%= entryId%>' });

How you can help (guidelines for contributors)

Thank you for helping Kaltura grow! If you'd like to contribute please follow these steps:

Where to get help

Get in touch

You can learn more about Kaltura and start a free trial at: http://corp.kaltura.com
Contact us via Twitter @Kaltura or email: [email protected]
We'd love to hear from you!

License and Copyright Information

All code in this project is released under the AGPLv3 license unless a different license for a particular library is specified in the applicable library path.

Copyright © Kaltura Inc. All rights reserved.
Authors and contributors: See GitHub contributors list.

Open Source Libraries Used

https://github.com/manifestinteractive/teleprompter MIT License

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.