openvv icon indicating copy to clipboard operation
openvv copied to clipboard

Provide a way to use directly from JS

Open clemos opened this issue 10 years ago • 13 comments

I guess the title says it all :) We have a JS video player, and would like to implement openVV on it. Reviewing the code, it seems definitely possible to provide an additionnal "backend" that would wrap the JS code from https://github.com/openvv/openvv/blob/master/src/org/openvv/js/OVVAsset.js into a useable js lib. Further structuring the js sources would also allow more events to be implemented (onViewable/notViewable, onFocus/onUnfocus), which would be very valuable.

clemos avatar Oct 01 '14 10:10 clemos

Add support for JS players (HTML5) is on the roadmap. We can have a chat on the specifications

alonashkenazi avatar Oct 01 '14 16:10 alonashkenazi

Ok, how do you want to proceed ?

clemos avatar Oct 08 '14 08:10 clemos

Sent you an email

alonashkenazi avatar Oct 08 '14 14:10 alonashkenazi

Here are the features I'd like to see :

  • expose that same API as OVVAsset in JS by
    • porting needed parts of OVVAsset.as to JS
    • including OVVAsset.js directly
    • using both measuring techniques (ie feature detect Flash to use beacons technique)
  • both versions of OVVAsset should expose events on viewability change
    • the common JS part should listen to DOM scroll, window focus/blur, fullscreen and viewability events
    • when beacon method is used, the throttle event is used as well, and relayed to JS
    • eventually, allow the JS version to work across (cross-domain) iframes, as a lot of JS players are bound to iframes

I guess the current OVVAsset.js could include both the code injected by the SWF as well as the native JS API. I'm not familiar with the whole codebase, but I believe that ideally, we should think about it the other way around: the "main" part should be as much as possible in JS, the only AS3 parts should be the beacon, and an AS3 wrapper to the injected JS API. Please notice that I never used the VPAID features.

clemos avatar Oct 09 '14 14:10 clemos

Agreed, a JavaScript VPAID (non Flash) wrapper would be helpful.

Brayyy avatar Dec 11 '15 01:12 Brayyy

Instead of using the flash beacon for a pure JS implementation you should consider a postMessage implementation that consists of a host-side geometry component and a cross domain communication pipe.

goosemanjack avatar Dec 31 '15 18:12 goosemanjack

@clemos Did you get the standalone OVVAsset.js with the requirements you listed or the current version should have it? Thanks

EvgenySergeychik avatar Mar 09 '17 02:03 EvgenySergeychik

@EvgenySergeychik nope, I haven't been working on OVV for a while now, and unfortunately never made this standalone JS version :|

clemos avatar Mar 09 '17 09:03 clemos

@clemos Thanks for quick reply. So i need to use OVVAsset.js as a wrapper to interop with openvv.swc which has to be imported to project?

EvgenySergeychik avatar Mar 09 '17 17:03 EvgenySergeychik

@EvgenySergeychik If you want to use OVVAsset.js on it's own you need a Javascript class that performs the same functions as OVVAsset.as - https://github.com/InteractiveAdvertisingBureau/openvv/blob/master/src/org/openvv/OVVAsset.as

Your OVVAsset.as replacement will have to create an instance of OVVAsset in JS. You'll need to modify OVVAsset.js in a few ways. One will be to modify what it uses as the player element. You'll have to change that to a specific DOM element you want to measure. The current version of OVV looks for a specific Flash embed on the page to find it - https://github.com/InteractiveAdvertisingBureau/openvv/blob/master/src/org/openvv/js/OVVAsset.js#L1638

Also, you'll need to update the beaconsStarted method that the Flash beacons call to, to tell the player they've started - https://github.com/InteractiveAdvertisingBureau/openvv/blob/master/src/org/openvv/js/OVVAsset.js#L1055

You'll have to proxy the 'player' with something that can accept the 'onJsReady' calls, that calls back to OVVAsset.as - https://github.com/InteractiveAdvertisingBureau/openvv/blob/master/src/org/openvv/OVVAsset.as#L266

Not sure how urgent your need is, but it might be worth waiting for the HTML5 version of OpenVV to be released. We're still in the architecture phase, but I think the expectation is that it will be released sometime this year. It will make use of IntersectionObserver primarily for measurement. You can see how this works in the current OpenVV here -

https://github.com/InteractiveAdvertisingBureau/openvv/blob/master/src/org/openvv/js/OVVAsset.js#L1316

jdreetz avatar Mar 09 '17 20:03 jdreetz

@jdreetz Thanks a lot for explanation and guidance. I will think about it and talk to our team about the strategy, but it is great to know that HTML5 version should be released this year. One more question: I could implement my own viewability measurement by implementing VPaid wrapper?

EvgenySergeychik avatar Mar 10 '17 01:03 EvgenySergeychik

@EvgenySergeychik - yes, you could probably do that, but the Javascript side doesn't have any VPAID specific listeners. That's all handled on the Flash side - https://github.com/InteractiveAdvertisingBureau/openvv/blob/master/src/org/openvv/OVVAsset.as#L604

jdreetz avatar Mar 12 '17 18:03 jdreetz

@jdreetz Thank you.

EvgenySergeychik avatar Mar 13 '17 14:03 EvgenySergeychik