InteractiveAdvertisingBureau / openvv

Other
81 stars 50 forks source link

Provide a way to use directly from JS #61

Open clemos opened 10 years ago

clemos commented 10 years ago

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.

alonashkenazi commented 10 years ago

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

clemos commented 10 years ago

Ok, how do you want to proceed ?

alonashkenazi commented 10 years ago

Sent you an email

clemos commented 10 years ago

Here are the features I'd like to see :

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.

Brayyy commented 8 years ago

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

goosemanjack commented 8 years ago

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.

EvgenySergeychik commented 7 years ago

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

clemos commented 7 years ago

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

EvgenySergeychik commented 7 years ago

@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?

jdreetz commented 7 years ago

@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

EvgenySergeychik commented 7 years ago

@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?

jdreetz commented 7 years ago

@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

EvgenySergeychik commented 7 years ago

@jdreetz Thank you.