Skip to main content

ZiggeoApi.Events seems to be obsolete.

Comments

3 comments

  • Bane

    Hi Gavin,

    Thank you for submitting this. Yes, you are right that not all of the things are exactly the same, and thank you for posting about it.

    I do hope that someone having the same thoughts as you did find your post so that they can see the answer.

    Since we still support v1 and of course we support v2 and next to that we also support our older revisions, it is possible that sometimes the docs are not as easy to navigate (if so we are always open for feedback and suggestions :) ).

    In general as a rule of thumb, it is best to check the dropdown at the top to say v2 or v1 as per your own requirement.

    For example, the v1 events look like so:

    ZiggeoApi.Events.on("submitted", function ( data ) {
    //Your code goes here
    });

    This is all great if you are using v1 codes and v1-stable/ziggeo.js file.

    If you are using v1 embedding codes, however you try to use v2-stable/ziggeo.js file it will not know about the reference (and you would see the errors in the console).

    Our header page can help with the exact file you want.

    * at the top you have an option to switch to v1 if needed.

    Now, the v2 uses events a bit differently. It has:

    1. Private (embedding specific) events
    2. Application events
    3. Global embedding events

    Private events basically mean that the event is per embedding, so if the event fires, you know exactly which embedding the event happened on.

    The code for it would look like so:

    embedding.on("verified", function () {
    //Your code goes here
    });

    You will notice that it is no longer using the ZiggeoAPI to create an event, rather the embedding itself. Now the reference to the embedding is different depending on the way you have created it (JS or HTML), and this is mentioned at the top of this page.

    * make sure to have dropdowns set with V2 and stable (cookies try their best to remember which version you made the last switch)

    Now the application you mentioned as system events is good to be used. It allows us 2 things from above. The application events, like ready and global embedding events if we want to have our usecase the same as v1 did (v1 events were global by nature, so you had to find our which element fired).

    var application = new ZiggeoApi.V2.Application({
    token: APP_TOKEN
    });

    In this case we are creating the application.

    Now if you are using /v2-stable/ziggeo.js as I mentioned above, you would not be able to access ZiggeoApi.Events, while you will be able to use application.on().

    In general application.on('read', ... is the same as ZiggeoApi.Events.on("system_ready", ... just easier to write and makes more sense.

    While switching to v1-stable would allow you to use .Events.on() approach they would not work for v2, so I do suggest switching to v2 approach instead completely.

    If you need any assistance with the codes themselves, do let us know :)

    For reference for anyone else that might be reading this and not sure where these events are mentioned, they are all under our docs pages.

    Specifically under Browser Interaction section:

    1. Embedding specific / private events
    2. Embedding events captured on application wide level
    3. Application specific events

    Now just before answering I do believe that I understand the reference you made, and that you are actually referring to our code embedding demos, which are showing v1 approach, which would work with v1-stable/ziggeo.js, however not with v2-stable/ziggeo.js file.

    If so, this is the link: https://ziggeo.com/docs/sdks/javascript/browser-integration/embed-methods

    At the time the docs were made, everyone was still utilizing our v1-stable/ziggeo.js file. At this time I do believe that it would be better to change those to v2 specific codes, so thank you for raising this.

    In the spirit of the same, I will leave the above as I think that it will help, and here is the actual code that you would use on your v2-stable pages

    <div id="replace_me-v2_player"></div>
    <script>     application.on("ready"function() {         var player = new ZiggeoApi.V2.Player({             elementdocument.getElementById("replace_me-v2_player"),             attrs: {                 width320,                 height180,                 theme"modern",                 themecolor"red",                 video"_sample_video"             }         });         player.activate();     }); </script>

    Where this would be in your header:

    <link rel="stylesheet" href="https://assets-cdn.ziggeo.com/v2-stable/ziggeo.css" />
    <script src="https://assets-cdn.ziggeo.com/v2-stable/ziggeo.js"></script>
    <script>var app = new ZiggeoApi.V2.Application({
    token:"APPLICATION_TOKEN"
    });
    </script>

    Hope this helps :)

    0
  • Gavin King (plumpNation)

    Yes, it helps :)

    But just to clarify, 

    ZiggeoApi.Events.on("system_ready"function() {
            var player = new ZiggeoApi.V2.Player({

    from this page (https://ziggeo.com/docs/sdks/javascript/browser-integration/embed-methods#javascript-version=v2) is incorrect?

    0
  • Bane

    Glad to hear that Gavin.

    In simple terms it is "old", but not obsolete. :) So for all new (v2) setups, you can not use it.

    For everyone that is still using older version and is switching to new one (v1 to v2) for them the same will work just fine.

    The short reason why that is so is because our v1 includes v2 codes as well, while v2 is pure v2, so anything that it (v2 system) is not using, will not be there :)

    0

Please sign in to leave a comment.