Player is loading...

This is an example of using Ace Stream Javascript API to embed player on the page.

First, add javascript library on the page (inside the <head> tag):


                    <script src="//static.acestream.net/jsapi/acestream.min.js"></script>
                

Then you can create the player with this code:


                    var player = null;
                    AceStream.createPlayer("#player", {
                        onLoad: function (playerObj) {
                            player = playerObj;
                            // Sintel
                            player.loadContentId("94c2fd8fb9bc8f2fc71a2cbe9d4b866f227a0209");
                        },
                        onError: function(err) {
                            console.log("init: error: " + err);
                        }
                    });
                

The code creates player in the HTML-container with id "player".

Upon successful player creation onLoad callback is called and player object is passed as parameter.

You should save player object to some variable to be able to call player methods later, for example, to switch to another content.

Currently such method are available:

Buttons on the top of the pages show how to use different content loading methods.

Additional features

If the user has a browser extension Ace Script with the activated userscript Ace Cast, the following additional features will be available:

In order to inform the user about these features, the corresponding information block is shown after clicking on "menu" or "play" button.

Attention! The need to use a browser extension and a userscript to make additional features available is temporary, until we implement a solution that allows direct and secure communication between javascript code and the Ace Stream application.

Roadmap

New JS API consists of reusable javascript modules which are bundled with browserify. Currently only the bundled version is distributed, but we plan to prepare documentation for these modules and publish it along with the source code on github.

Modules will implement such functionality like:

Legacy JS API

The old version of JS API is still available. You can find test page and links here.

Multiple players on the same page

Here is an example of creating multiple players on the same page.

To create second player you just need to provide a container for it:


                <div id="second-player"></div>
            
and then load player into this container:

                var secondPlayer = null;
                AceStream.createPlayer("#second-player", {
                    onLoad: function (playerObj) {
                        secondPlayer = playerObj;
                        // Brodilo TV
                        secondPlayer.loadTransportFileUrl("http://acestream.org/downloads/tmp/test.acelive");
                    },
                    onError: function(err) {
                        console.log("Failed to init second player: " + err);
                    }
                });
            

Player is loading...