forked from nader-jw/html5player
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.coffee
More file actions
69 lines (59 loc) · 2.29 KB
/
app.coffee
File metadata and controls
69 lines (59 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
inject = require 'honk-di'
Player = require './player'
ProofOfPlay = require './proof_of_play'
VariedAdStream = require './varied_ad_stream'
{Ajax, XMLHttpAjax} = require 'ajax'
defaultConfig = {}
defaultConfig['vistar.api_key'] = '58b68728-11d4-41ed-964a-95dca7b59abd'
defaultConfig['vistar.network_id'] = 'Ex-f6cCtRcydns8mcQqFWQ'
defaultConfig['vistar.device_id'] = 'test-device-id'
defaultConfig['vistar.debug'] = false
defaultConfig['vistar.url'] =
'http://dev.api.vistarmedia.com/api/v1/get_ad/json'
config = window.Cortex?.getConfig() or defaultConfig
window?.Vistar = ->
# an example app
class Binder extends inject.Binder
configure: ->
@bind(Ajax).to(XMLHttpAjax)
@bindConstant('navigator').to window.navigator
@bindConstant('video').to document.querySelector('.player video')
@bindConstant('image').to document.querySelector('.player img')
@bindConstant('config').to
url: config['vistar.url']
apiKey: config['vistar.api_key']
networkId: config['vistar.network_id']
deviceId: window.Cortex?.player?.id() or config['vistar.device_id']
venueId: config['vistar.venue_id']
width: 1280
height: 720
cacheAssets: true
allowAudio: true
directConnection: false
latitude: 39.9859241
longitude: -75.1299363
queueSize: 10
debug: !!defaultConfig['vistar.debug']
mimeTypes: ['image/gif', 'image/jpeg', 'image/png', 'video/webm']
displayArea: [
{
id: 'display-0'
width: 1280
height: 720
allow_audio: false
cpm_floor_cents: Number(config['vistar.cpm_floor_cents'] or 0)
}
]
injector = new inject.Injector(new Binder)
ads = injector.getInstance VariedAdStream
player = injector.getInstance Player
pop = injector.getInstance ProofOfPlay
# this exists only so one can inspect the different components while it's
# running
window.__vistarplayer =
ads: ads
player: player
pop: pop
ads
.pipe(player)
.pipe(pop)