How to switch from v1 to v2 and why you should?
At this time most of our customers are using v2 directly however in our documentation there were (and still are) some codes that you can see reference the v1 for some reason.
In some cases we added info about v2, in others changed it to v2, however somewhere that was not really possible such as forum questions for example. So this document is aimed at explaining how you can tell if you are using v1 or v2 and also how to switch.
How to find out if you have v1 or v2 embedding code?
The easiest way to tell is if your code is using embedding that looks like so:
<ziggeo ziggeo-video="_my_cool_video"></ziggeo>
This is a v1 embedding. Unless you are familiar with the codes, you can not tell if this is player, recorder or both.
This means that all code is working on same embedding and creating the scenario based on assumptions of what the parameters are set for.
This meant that if you make a mistake in your parameter the code might not understand that you are trying to have the player shown and show recorder.
Sure this only happens during the initial phases as you get to know our system, still we like to make things easy and simple.
Now V2 on the other hand is more specialized. What this means is that we have a player and we also have a recorder, and so on. So your embedding now would look like so:
<ziggeoplayer ziggeo-video="_my_cool_video"></ziggeoplayer>
or
<ziggeorecorder></ziggeorecorder>
Well now you can immediately tell that the first is the player and the second is recorder.
Now imagine if you did not know any code. Still if you saw the "player" or "recorder" in the tag name, it would give you enough of info to know what code to copy paste just to try it out.
Not only are you able know right away what it is for, so does our code. This means that we can bring up only the code that matters and when it matters. This in turn makes the system faster, stronger and most importantly - provides better experience.
How to see if you are using v1 or v2 application setup?
V1 application setup is quite specific. You would have the code such as the following:
ZiggeoApi.token = "YOUR_APP_TOKEN";
Also any of the config entries such as:
<script>ZiggeoApi.Config.cdn = true;</script>
<script>ZiggeoApi.Config.webrtc = true;</script>
<script>ZiggeoApi.Config.resumable = true;</script>
<script>ZiggeoApi.Config.cookies = true;</script>
All of these are v1 and should be changed to v2.
So how would the same look for v2?
<script>
var ziggeoApp = new ZiggeoApi.V2.Application({
token:"APPLICATION_TOKEN",
webrtc_streaming_if_necessary: true,
webrtc_on_mobile: true
});
</script>
That is it. The CDN is turned on by default just like WebRTC and resumable uploads are.
The only thing that is important in v2 is the auth system. Since v2 is designed to be more resource friendly, the auth system is set to false by default. So if you are using our auth system, all you would do is turn it on by adding auth: true and you are done.
How to see if you are using v1 or v2 events?
V1 events are global. They would fire for all embeddings and you would need to add logic to know where the event was triggered. Once you did you could do what you had to with provided data.
The events looked something like this:
ZiggeoApi.Events.on("submitted", function() {
alert("submitted");
});
Now you can tell immediately that they are all starting from ZiggeoApi.Events.on(). So if you see this in your code, you should switch to our v2 instead.
Now the v2 has few flavors of events actually:
- The embedding specific events
* These are events that are set per each embedding so you can design your code to just react on specific events and do specific actions based on what embedding it is directly - The application wide embedding events
* These are behaving just like the v1 events are however they are based on the application. This allows you to know globally when something happens. For example if you only want to know that playback started regardles of the embedding, this would make it possible. - The application events
* While just 2 at this time, they allow you to get additional info that is based on your entire application. For example if you forgot to put the application token.
Embedding specific events
These would look like so:
embedding.on("verified", function () {
//Your code goes here
});
Application wide embedding events
These would look like so:
ziggeoApp.embed_events.on("verified", function (embedding) {
//Your code goes here
});
The application in this case is ziggeoApp. Benefit is that if you have 2 applications, it would allow you to see globally what happens yet still be able to separate actions from different applications.
This is actually how we sometimes go to your website and test things without using your application ;)
Application wide events
Let us also take a look at the events that fire for the application itself:
ziggeoApp.on("ready", function () {
//Your code goes here
});
Why should you switch to v2?
V1 won awards and featured great code. It still works right in most cases, however as the browsers and web itself changes we needed something that is more modular. We also listened to what our customers like yourself were saying and wanted to make it even easier.
We also wanted something that was designed for responsiveness, easily fits everywhere yet is super easy to add new features to it. From this desire v2 was born.
As you could see above v2 already offers some things however there is another reason why you want to switch from v1.
As the v1 could not really be upgraded to use new features, we worked on v2. At one point we have removed the v1 core code and made it run v2 player or recorder internally.
So currently the v1 is the proxy for the v2.
There are few pages that can help you with the switch:
The Header (application setup)
Parameters to spice up your embeddings
Application wide Embedding Events
There is one more and quite important point to leave you with at this time. That is that our support team is here and happy to help, so for any questions just reach out and let us know :) We are happy to help.
Please sign in to leave a comment.
Comments
0 comments