Get the token of just created media

In many cases getting the video or audio token is closely connected to the creation of the media. For this we always recommended our verified event. You can however get it even sooner.

There are many events you can use, and in different ways. One of the first ones you can use is the uploading event. As soon as it fires you will know the token.

So why do we recommend verified event instead? The simple answer is that it means that your video has been verified as possible to process. That is to say, there are no obvious reasons why it would not process. As soon as this fires you can also close the page, or do anything else, it no longer matters. Our system has the video and will process it.

Setting it up

First, to make things simple, we will take it as if your header code looks something like this:

<link rel="stylesheet" href="https://assets.ziggeo.com/v2-stable/ziggeo.css" />
<script src="https://assets.ziggeo.com/v2-stable/ziggeo.js"></script>
<script>
	var ziggeo_app = new ZiggeoApi.V2.Application({
		token:"APPLICATION_TOKEN",
		webrtc_streaming_if_necessary: true,
		webrtc_on_mobile: true
	});
</script>
  • The only thing that should be different from above is "APPLICATION_TOKEN" should be your actual application token. Also you might use some specific revision (we always suggest stable or newer).
  • Note: If you are not sure what is our current stable revision and if you need to update, check this page.

Now, as we mentioned at the start, there are several ways you can listen to events.

Application wide event handling

Our system allows you to listen to events on a global level. That is not per entire page, rather per entire application initialized on that page. This is very useful if you have 2 or more recorders and you do not care which one was used. For example your goal is to get same type of video on either of the 4 recorders strategically placed around your page.

In such case global approach might be best since you have one code that handles them all.

Remember above that we created an application and referenced it into ziggeo_app variable? Well that is what we will use as so:

ziggeo_app.embed_events.on("verified", function (embedding) {
    alert("Video with token '" + embedding.get('video') + "' has been verified!");
});

Embedding specific event handling

So you might wonder why we need embedding specific handling when we get the embedding reference in the other events. Well that would actually be a good question. There is no real difference in which one you should use, just the preference. If you use the application wide, then you might need to add conditional checks (if blocks) to see if that embedding should be handled in certain way.

While it is OK to use for short snippets of changes. Now when there are a lot of things that should happen this no longer seems as best approach.

At that time you might want to separate your codes in a clean manner and avoid additional checks and just run the codes per recorder.

Luckily this is easy as well, however we will show more code to combine creation of recorder with the event. This is also how you would typically set it up:

<div id="embedding_placeholder"></div>
<script>
    ziggeo_app.on("ready", function() {
        var recorder = new ZiggeoApi.V2.Recorder({
            element: document.getElementById("embedding_placeholder"),
            attrs: {
                width: '100%',
                theme: "cube",
                themecolor: "red"
             }
         });

        recorder.on("verified", function () {
            alert("Video with token '" + embedding.get('video') + "' has been verified!");
        });

        recorder.activate();
     });
</script>

Support for audio and image media types

Our events such as uploading and verified will fire on all media types. As such this is recommended to use for every embedding type.

The code would be slightly different for creation of the audio recorder, however once created you would listen to the events in the exact same way.

PREV NEXT