Video Intelligence (vi) - 图1

Video Intelligence (vi)

Video Intelligence component that built into Framework7 allows you to easily add video advertising to your Framework7 app, straight out-of-the-box.

vi’s interstitial ads can be placed into your app experience at your discretion, showing full screen video ads. Advertisers pay a premium for these ad slots, and they will be directly connected to your app; you’ll be able to monetise straight away.

Getting Started With vi

1. Sign up for Framework7 vi publisher account

First of all as a mobile publisher you need to create vi publisher account. To signup for Framework7 vi account go to vi.framework7.io and fill up the following form:

Video Intelligence (vi) - 图2

2. Setup your app at vi

After successful registration you will receive instructions with vi dashboard link and temporary password to the specified email.

When you log in to your vi dashboard you will see a list of your apps. If you don’t have apps create new one:

Video Intelligence (vi) - 图3

When you already have an app, you need to add placement for this app:

Video Intelligence (vi) - 图4

When you create place choose Placement Type: “Video Interstitial”

Video Intelligence (vi) - 图5

Ok, after we have placement created we need placement ID, choose just created placement:

Video Intelligence (vi) - 图6

Click “copy” near the placement id string to copy id to the clipboard

Video Intelligence (vi) - 图7

3. Configure vi in Framework7 app

After we set the things up at vi dashboard we will have:

  • App bundle id (e.g. io.framework7.testapp)
  • Placement id (e.g. pltd4o7ibb9rc653x14)

Now when we have our vi placement id we may set it up in Framework7 on the app initialization:

  1. var app = new Framework7({
  2. /*
  3. common app bundle id must match the one
  4. you have specified when created app in vi dashboard:
  5. */
  6. id: 'io.framework7.testapp',
  7. /* add vi placement id under the vi module parameters */
  8. vi: {
  9. placementId: 'pltd4o7ibb9rc653x14',
  10. },
  11. });

4. Show Ad

That is all, now we can use Framework7’s vi API to create and show ads. In simplest way just call the following method when you need to show an ad:

  1. app.vi.createAd();

vi App Methods

Let’s look at available vi app methods and properties:

app.vi.createAd(parameters)Create (and show) vi video ad.
  • parameters - object with vi ad parameters
  • Method returns vi ad instance
app.vi.loadSdk()Loads vi SDK. By default if vi is not disabled in app parameters then it will load it automatically
app.vi.sdkReadyBoolean property indicating whether the vi SDK is ready or not

vi Ad Parameters

Let’s look at list of all available parameters when we create vi ad:

ParameterTypeDefaultDescription
enabledbooleanfalseGlobal app parameter which enables vi API and vi SDK to load. If you pass any vi parameters under vi app parameters then it will enable vi api as well
appIdstringApp bundle id, if not specified then equal to id app parameter
placementIdstringpltd4o7ibb9rc653x14vi placemenet ID, you can use this one for testing, and switch to yours real one for production
placementTypestringinterstitialAd type. Can be interstitial (when ad runs as full screen video) or instream (when ad video )
autoplaybooleantrueEnables video ad autoplay
startMutedbooleanDefines whether the ad must start muted or not. By default is true when app is running as a web app (not Cordova) under mobile device (iOS or Android). It is required because on mobile device video autoplay usually requires additional user interaction
fallbackOverlaybooleantrueEnables overlay layer that will be visible when ad can not autoplay (in case video autoplay requires user interaction)
fallbackOverlayTextstringPlease watch this adFallback overlay text
appVerstringApp version, if not specified then equal to version app parameter
languagebooleannullApp language, if not specified then equal to language app parameter
widthnumberApp width in px. If not specified then equal to app container width
heightnumberApp height in px. If not specified then equal to app container height
showProgressbooleantrueEnable ad interface progress bar
showBrandingbooleantrueEnable ad interface vi branding logo
showMutebooleantrueEnable ad interface mute button
osstringOperating system, if not specified then will be equal to app.device.os
osVersionstringOperating system version, if not specified then will be equal to app.device.osVersion
orientationstringDevice orientation, if not specified then will be detected based on window.orientation
agenumberUser age (optional)
genderstringUser gender (optional)
advertiserIdstringUnique advertiser identifier (optional)
latitudeintegerDevice location latitude (optional)
longitudeintegerDevice location longitude (optional)
storeIdstringApp store id (optional)
ipstringDevice IP address (optional)
manufacturerstringDevice manufacturer (optional)
modelstringDevice model
connectionTypestringDevice connection type (optional)
connectionProviderstringDevice connection provider (optional)
onobject

Object with events handlers. For example:

  1. var viAd = app.vi.createAd({
  2. on: {
  3. stopped: function () {
  4. console.log(‘Ad video stopped’)
  5. }
  6. }
  7. })

All parameters can be used in global app parameters under vi property to set defaults for all vi ads. For example:

  1. var app = new Framework7({
  2. /*
  3. common app bundle id must match the one
  4. you have specified when created app in vi dashboard:
  5. */
  6. id: 'io.framework7.testapp',
  7. /* global vi parameters */
  8. vi: {
  9. placementId: 'pltd4o7ibb9rc653x14',
  10. }
  11. });

In this case when we create vi ad, we need to pass parameters that we want to override:

  1. var viAd = app.vi.createAd({
  2. // disable autoplay for this ad
  3. autoplay: false,
  4. })

vi Ad Methods & Properties

So to create vi ad we have to call:

  1. var viAd = app.vi.create({ /* parameters */ })

After that we have its initialized instance (like viAd variable in example above) with useful methods and properties:

Properties
viAd.appLink to global app instance
viAd.adOriginal vi ad instance
viAd.paramsvi ad parameters
Methods
viAd.start()Start ad video. Useful in case of disabled autoplay
viAd.pause()Pause ad video
viAd.resume()Resume ad video
viAd.stop()Stop ad video, in this case ad will be closed and destroyed. It will be impossible to proceed with this video ad
viAd.on(event, handler)Add event handler
viAd.once(event, handler)Add event handler that will be removed after it was fired
viAd.off(event, handler)Remove event handler
viAd.off(event)Remove all handlers for specified event
viAd.emit(event, …args)Fire event on instance

vi Ad Events

vi ad will fire the following events on vi ad instance:

EventTargetArgumentsDescription
readyviAdEvent will be triggered when ad created, requested and ready to be played. In case of disabled autplay, you to listen for this event and call viAd.start() when ad becomes ready
startedviAdEvent will be triggered when ad video started to play
clickviAdEvent will be triggered after click on ad video
clickviAdurlEvent will be triggered after click on ad video. As an argument it received click target URL. Use this url only in case if ad target url can not be opened by your device/app
impressionviAdEvent will be triggered on ad impression
stoppedviAdreasonEvent will be triggered when video ad stopped. As an argument it receives string reason, which can be, for example, userexit (when video was interrupted by user) or complete when ad video completed
completeviAdEvent will be triggered when video ad finished
userexitviAdEvent will be triggered when user closed the video ad
autoplayFailedviAdreasonEvent will be triggered in case of enabled autoplay and it failed to start an ad (for example when additional user interraction required)
errorviAderrorEvent will be triggered on ad error. As an argument it receives error message

App Events

vi component also fires events on app instance:

EventTargetArgumentsDescription
viSdkReadyappEvent will be triggered when vi SDK loaded and ready to be used

Examples

  1. var app = new Framework7({
  2. id: 'io.framework7.testapp',
  3. vi: {
  4. placementId: 'pltd4o7ibb9rc653x14',
  5. }
  6. });
  7. var $$ = Dom7;
  8. // Create prepaire ad
  9. var prepairedAd;
  10. if (!app.vi.sdkReady) {
  11. app.on('viSdkReady', function () {
  12. prepairedAd = app.vi.createAd({
  13. autoplay: false,
  14. });
  15. })
  16. } else {
  17. prepairedAd = app.vi.createAd({
  18. autoplay: false,
  19. });
  20. }
  21. // Show prepaired ad
  22. $$('.show-prepaired').on('click', function () {
  23. prepairedAd.start();
  24. });
  25. // Create and show ad
  26. $$('.create-and-show').on('click', function () {
  27. app.vi.createAd();
  28. });
  29. // With custom autplay fallback
  30. $$('.create-and-show-with-custom-callback').on('click', function () {
  31. app.vi.createAd({
  32. fallbackOverlay: false,
  33. on: {
  34. autoplayFailed: function() {
  35. const ad = this;
  36. app.dialog.alert('Check out this awesome ad', () => {
  37. ad.start();
  38. })
  39. }
  40. }
  41. });
  42. });
  43. // Create and show rewarded ad
  44. $$('.create-and-show-rewarded').on('click', function () {
  45. app.vi.createAd({
  46. autoplay: false,
  47. on: {
  48. ready: function() {
  49. const ad = this;
  50. app.dialog.alert('Check out this awesome ad to get the reward', () => {
  51. ad.start();
  52. })
  53. },
  54. complete: function() {
  55. app.dialog.alert('Congrats! You got the reward!')
  56. },
  57. userexit: function() {
  58. app.dialog.alert('Sorry, no reward for you!')
  59. },
  60. }
  61. });
  62. });

← Treeview

View / Router →