myetv-player 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -1
- package/css/myetv-player.css +7 -2
- package/css/myetv-player.min.css +1 -1
- package/dist/myetv-player.js +669 -79
- package/dist/myetv-player.min.js +579 -42
- package/package.json +4 -2
- package/plugins/google-adsense-ads/README.md +230 -0
- package/plugins/google-adsense-ads/g-adsense-ads-plugin.js +75 -8
- package/plugins/google-ima-ads/README.md +258 -0
- package/plugins/google-ima-ads/g-ima-ads-plugin.js +2 -2
- package/plugins/soundcloud/myetv-player-soundcloud-plugin.js +927 -0
- package/plugins/soundcloud/readme.md +89 -0
- package/plugins/youtube/myetv-player-youtube-plugin.js +155 -164
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "myetv-player",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "MYETV Video Player - Modular HTML5 video player with plugin support for YouTube, Vimeo, Twitch, Facebook, and streaming protocols (HLS/DASH)",
|
|
3
|
+
"version": "1.6.0",
|
|
4
|
+
"description": "MYETV Video Player - Modular HTML5 video player with plugin support for YouTube, Vimeo, Twitch, Facebook, Cloudflare Stream and streaming protocols (HLS/DASH)",
|
|
5
5
|
"main": "dist/myetv-player.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist/",
|
|
@@ -59,3 +59,5 @@
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
|
|
62
|
+
|
|
63
|
+
|
|
@@ -1 +1,231 @@
|
|
|
1
|
+
# Google AdSense Plugin for MYETV Video Player
|
|
1
2
|
|
|
3
|
+
A plugin that integrates Google AdSense display ads into the MYETV Video Player. This plugin shows responsive AdSense banners as overlay ads when the video is paused.
|
|
4
|
+
|
|
5
|
+
## Important Notes
|
|
6
|
+
|
|
7
|
+
- This plugin uses **AdSense Display Ads** (not AdSense for Video)
|
|
8
|
+
- Ads appear as **overlay banners** on top of the video player
|
|
9
|
+
- **NOT recommended for use inside iframes** - may violate AdSense policies
|
|
10
|
+
- For true video ads (pre-roll, mid-roll), use the Google IMA Plugin instead
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- ✅ Responsive AdSense display ads
|
|
15
|
+
- ✅ Automatic ad display on video pause
|
|
16
|
+
- ✅ Auto-hide when video resumes
|
|
17
|
+
- ✅ Customizable ad formats
|
|
18
|
+
- ✅ Close button for user control
|
|
19
|
+
- ✅ Full-width responsive support
|
|
20
|
+
- ✅ Debug mode for troubleshooting
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
### 1. Include AdSense Script
|
|
25
|
+
|
|
26
|
+
Add the Google AdSense script to your HTML page:
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXXXXXXXX"
|
|
30
|
+
crossorigin="anonymous"></script>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Replace `ca-pub-XXXXXXXXXX` with your AdSense Publisher ID.
|
|
34
|
+
|
|
35
|
+
### 2. Include the Plugin
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<script src="path/to/g-adsense-ads-plugin.js"></script>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. Initialize the Plugin
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
const player = new VideoPlayer('#video', {
|
|
45
|
+
// ... other player options
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Initialize AdSense plugin
|
|
49
|
+
const adsensePlugin = new AdSenseVideoPlugin(player, {
|
|
50
|
+
publisherId: 'ca-pub-XXXXXXXXXX',
|
|
51
|
+
adSlot: '1234567890', // Optional
|
|
52
|
+
adFormat: 'auto', // Optional
|
|
53
|
+
fullWidth: true, // Optional
|
|
54
|
+
debug: false // Optional
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Setup the plugin
|
|
58
|
+
adsensePlugin.setup();
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Configuration Options
|
|
62
|
+
|
|
63
|
+
| Option | Type | Default | Description |
|
|
64
|
+
|--------|------|---------|-------------|
|
|
65
|
+
| `publisherId` | String | `''` | **Required**. Your AdSense Publisher ID (e.g., `ca-pub-XXXXXXXXXX`) |
|
|
66
|
+
| `adSlot` | String | `''` | Optional. Specific ad slot ID from AdSense |
|
|
67
|
+
| `adFormat` | String | `'auto'` | Ad format: `'auto'`, `'rectangle'`, `'horizontal'`, `'vertical'` |
|
|
68
|
+
| `fullWidth` | Boolean | `true` | Enable full-width responsive ads |
|
|
69
|
+
| `debug` | Boolean | `false` | Enable debug logging to console |
|
|
70
|
+
|
|
71
|
+
## How to Get Your Publisher ID
|
|
72
|
+
|
|
73
|
+
1. Sign in to your [Google AdSense account](https://www.google.com/adsense)
|
|
74
|
+
2. Go to **Ads** → **Overview**
|
|
75
|
+
3. Click **By ad unit** -> **Display ads**
|
|
76
|
+
4. Create a new ad unit or use an existing one
|
|
77
|
+
5. Your Publisher ID is in the format: `ca-pub-XXXXXXXXXX`
|
|
78
|
+
6. Optional: Copy the Ad Slot ID (the number after `data-ad-slot`)
|
|
79
|
+
|
|
80
|
+
## Usage Examples
|
|
81
|
+
|
|
82
|
+
### Basic Usage (Auto Format)
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
const adsensePlugin = new AdSenseVideoPlugin(player, {
|
|
86
|
+
publisherId: 'ca-pub-1234567890'
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
adsensePlugin.setup();
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### With Specific Ad Slot
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
const adsensePlugin = new AdSenseVideoPlugin(player, {
|
|
96
|
+
publisherId: 'ca-pub-1234567890',
|
|
97
|
+
adSlot: '9876543210',
|
|
98
|
+
debug: true
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
adsensePlugin.setup();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Custom Ad Format
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
const adsensePlugin = new AdSenseVideoPlugin(player, {
|
|
108
|
+
publisherId: 'ca-pub-1234567890',
|
|
109
|
+
adFormat: 'rectangle', // Force rectangle format
|
|
110
|
+
fullWidth: false
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
adsensePlugin.setup();
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Public Methods
|
|
117
|
+
|
|
118
|
+
### `setup()`
|
|
119
|
+
Initializes the plugin and creates the ad container.
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
adsensePlugin.setup();
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### `showAd()`
|
|
126
|
+
Manually show the ad overlay.
|
|
127
|
+
|
|
128
|
+
```javascript
|
|
129
|
+
adsensePlugin.showAd();
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### `hideAd()`
|
|
133
|
+
Manually hide the ad overlay and resume video playback.
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
adsensePlugin.hideAd();
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### `dispose()`
|
|
140
|
+
Clean up and remove the plugin.
|
|
141
|
+
|
|
142
|
+
```javascript
|
|
143
|
+
adsensePlugin.dispose();
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Automatic Behavior
|
|
147
|
+
|
|
148
|
+
The plugin automatically:
|
|
149
|
+
- Shows ads when video is **paused**
|
|
150
|
+
- Hides ads when video **resumes playing**
|
|
151
|
+
- Shows ads when video **ends**
|
|
152
|
+
- Provides a **Close Ad** button for users
|
|
153
|
+
|
|
154
|
+
## Events
|
|
155
|
+
|
|
156
|
+
The plugin triggers custom events on the player:
|
|
157
|
+
|
|
158
|
+
| Event | Description |
|
|
159
|
+
|-------|-------------|
|
|
160
|
+
| `adstarted` | Fired when ad is displayed |
|
|
161
|
+
| `adcomplete` | Fired when ad is hidden |
|
|
162
|
+
|
|
163
|
+
Listen to events:
|
|
164
|
+
|
|
165
|
+
```javascript
|
|
166
|
+
player.on('adstarted', () => {
|
|
167
|
+
console.log('Ad is now showing');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
player.on('adcomplete', () => {
|
|
171
|
+
console.log('Ad was closed');
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## AdSense Policy Compliance
|
|
176
|
+
|
|
177
|
+
**Important**: This plugin is designed for use on **main pages only**, not inside iframes. Using AdSense ads inside iframes may violate Google's policies unless you have explicit permission.
|
|
178
|
+
|
|
179
|
+
### Allowed Usage:
|
|
180
|
+
- ✅ Player on main page (same domain)
|
|
181
|
+
- ✅ Player embedded directly in page content
|
|
182
|
+
- ✅ Single player per page recommended
|
|
183
|
+
|
|
184
|
+
### Not Allowed:
|
|
185
|
+
- ❌ Player inside cross-domain iframe
|
|
186
|
+
- ❌ Multiple instances trying to bypass 3-ad limit
|
|
187
|
+
- ❌ Ads loaded via iframe on different domain
|
|
188
|
+
|
|
189
|
+
For iframe-based implementations or true video advertising, consider using **Google IMA SDK** with **AdSense for Video** (requires 2M+ monthly impressions) or **Google Ad Manager**.
|
|
190
|
+
|
|
191
|
+
## Troubleshooting
|
|
192
|
+
|
|
193
|
+
### Ads not showing?
|
|
194
|
+
|
|
195
|
+
1. **Check Publisher ID**: Ensure your `publisherId` is correct and starts with `ca-pub-`
|
|
196
|
+
2. **AdSense Script**: Verify the AdSense script is loaded in your HTML
|
|
197
|
+
3. **Enable Debug**: Set `debug: true` to see console logs
|
|
198
|
+
4. **Ad Blockers**: Disable ad blockers for testing
|
|
199
|
+
5. **Policy Compliance**: Ensure your site complies with AdSense policies
|
|
200
|
+
|
|
201
|
+
### Console Errors?
|
|
202
|
+
|
|
203
|
+
Enable debug mode:
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
const adsensePlugin = new AdSenseVideoPlugin(player, {
|
|
207
|
+
publisherId: 'ca-pub-XXXXXXXXXX',
|
|
208
|
+
debug: true // Enable debug logging
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Browser Support
|
|
213
|
+
|
|
214
|
+
- Chrome/Edge (latest)
|
|
215
|
+
- Firefox (latest)
|
|
216
|
+
- Safari (latest)
|
|
217
|
+
- Mobile browsers (iOS Safari, Chrome Mobile)
|
|
218
|
+
|
|
219
|
+
## License
|
|
220
|
+
|
|
221
|
+
Created by [MYETV.tv](https://www.myetv.tv) & [Oskar Cosimo](https://oskarcosimo.com)
|
|
222
|
+
|
|
223
|
+
## Related Plugins
|
|
224
|
+
|
|
225
|
+
- **Google IMA Plugin** - For true video ads (pre-roll, mid-roll, post-roll)
|
|
226
|
+
- See `g-ima-ads-plugin.js` for video advertising with VAST/VPAID support
|
|
227
|
+
|
|
228
|
+
## Support
|
|
229
|
+
|
|
230
|
+
For issues or questions:
|
|
231
|
+
- GitHub Issues: https://github.com/OskarCosimo/myetv-video-player-opensource/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/* Google AdSense Plugin for MYETV Video Player
|
|
2
2
|
* Integrates Google AdSense for Video
|
|
3
3
|
* Created by https://www.myetv.tv https://oskarcosimo.com
|
|
4
4
|
*/
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
this.createAdContainer();
|
|
39
39
|
this.loadAdSenseScript();
|
|
40
|
+
this.attachVideoEvents();
|
|
40
41
|
|
|
41
42
|
if (this.options.debug) {
|
|
42
43
|
console.log('🎬 AdSense Video Plugin initialized');
|
|
@@ -70,12 +71,38 @@
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
ins.setAttribute('data-ad-format', this.options.adFormat);
|
|
73
|
-
|
|
74
74
|
if (this.options.fullWidth) {
|
|
75
75
|
ins.setAttribute('data-full-width-responsive', 'true');
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
// Create Close button
|
|
79
|
+
const closeBtn = document.createElement('button');
|
|
80
|
+
closeBtn.textContent = '✕ Close Ad';
|
|
81
|
+
closeBtn.style.cssText = `
|
|
82
|
+
position: absolute;
|
|
83
|
+
top: 10px;
|
|
84
|
+
right: 10px;
|
|
85
|
+
padding: 8px 16px;
|
|
86
|
+
background: rgba(0, 0, 0, 0.7);
|
|
87
|
+
color: white;
|
|
88
|
+
border: none;
|
|
89
|
+
border-radius: 4px;
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
z-index: 1000;
|
|
92
|
+
font-size: 14px;
|
|
93
|
+
font-family: Arial, sans-serif;
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
closeBtn.addEventListener('click', () => {
|
|
97
|
+
this.hideAd();
|
|
98
|
+
// Resume video only if not ended
|
|
99
|
+
if (!this.player.video.ended) {
|
|
100
|
+
this.player.video.play();
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
78
104
|
this.adContainer.appendChild(ins);
|
|
105
|
+
this.adContainer.appendChild(closeBtn);
|
|
79
106
|
this.player.container.appendChild(this.adContainer);
|
|
80
107
|
}
|
|
81
108
|
|
|
@@ -110,19 +137,54 @@
|
|
|
110
137
|
if (this.options.debug) {
|
|
111
138
|
console.log('🎬 AdSense ad initialized');
|
|
112
139
|
}
|
|
140
|
+
|
|
141
|
+
// Show ad immediately if video is paused or not started
|
|
142
|
+
if (this.player.video.paused) {
|
|
143
|
+
this.showAd();
|
|
144
|
+
}
|
|
113
145
|
} catch (error) {
|
|
114
146
|
console.error('🎬 AdSense initialization error:', error);
|
|
115
147
|
}
|
|
116
148
|
}
|
|
117
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Attach video events
|
|
152
|
+
*/
|
|
153
|
+
attachVideoEvents() {
|
|
154
|
+
// Show ad when video is paused
|
|
155
|
+
this.player.video.addEventListener('pause', () => {
|
|
156
|
+
this.showAd();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Show ad when video ends
|
|
160
|
+
this.player.video.addEventListener('ended', () => {
|
|
161
|
+
this.showAd();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Hide ad when video starts playing
|
|
165
|
+
this.player.video.addEventListener('play', () => {
|
|
166
|
+
this.hideAd();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Show ad on load if no autoplay
|
|
170
|
+
this.player.video.addEventListener('loadedmetadata', () => {
|
|
171
|
+
if (this.player.video.paused && this.isAdLoaded) {
|
|
172
|
+
this.showAd();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
118
177
|
/**
|
|
119
178
|
* Show ad
|
|
120
179
|
*/
|
|
121
180
|
showAd() {
|
|
122
|
-
if (this.isAdLoaded) {
|
|
181
|
+
if (this.isAdLoaded && this.adContainer) {
|
|
123
182
|
this.adContainer.style.display = 'block';
|
|
124
|
-
this.player.video.pause();
|
|
125
183
|
this.player.triggerEvent('adstarted');
|
|
184
|
+
|
|
185
|
+
if (this.options.debug) {
|
|
186
|
+
console.log('🎬 Ad shown');
|
|
187
|
+
}
|
|
126
188
|
}
|
|
127
189
|
}
|
|
128
190
|
|
|
@@ -130,9 +192,14 @@
|
|
|
130
192
|
* Hide ad
|
|
131
193
|
*/
|
|
132
194
|
hideAd() {
|
|
133
|
-
this.adContainer
|
|
134
|
-
|
|
135
|
-
|
|
195
|
+
if (this.adContainer) {
|
|
196
|
+
this.adContainer.style.display = 'none';
|
|
197
|
+
this.player.triggerEvent('adcomplete');
|
|
198
|
+
|
|
199
|
+
if (this.options.debug) {
|
|
200
|
+
console.log('🎬 Ad hidden');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
136
203
|
}
|
|
137
204
|
|
|
138
205
|
/**
|
|
@@ -155,4 +222,4 @@
|
|
|
155
222
|
}
|
|
156
223
|
|
|
157
224
|
})();
|
|
158
|
-
/* GLOBAL_END */
|
|
225
|
+
/* GLOBAL_END */
|
|
@@ -1 +1,259 @@
|
|
|
1
|
+
# Google IMA Plugin for MYETV Video Player
|
|
1
2
|
|
|
3
|
+
A plugin that integrates the **Google Interactive Media Ads (IMA) SDK** with the MYETV Video Player.
|
|
4
|
+
It enables true video advertising (pre-roll, mid-roll, post-roll, VMAP, VAST, VPAID) using a standard HTML5 player.
|
|
5
|
+
|
|
6
|
+
## Important Notes
|
|
7
|
+
|
|
8
|
+
- This plugin uses **Google IMA SDK**, not standard AdSense display units.
|
|
9
|
+
- You must provide a valid **VAST/VMAP ad tag URL** or an `adsResponse`.
|
|
10
|
+
- For AdSense for Video, Google Ad Manager, or other ad networks, you still need a compatible ad tag.
|
|
11
|
+
- The plugin overlays ads on top of the video element using an IMA-managed ad container.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- ✅ Full integration with **Google IMA HTML5 SDK**
|
|
16
|
+
- ✅ Supports **VAST**, **VMAP**, and **VPAID**
|
|
17
|
+
- ✅ Uses `AdDisplayContainer`, `AdsLoader`, and `AdsManager`
|
|
18
|
+
- ✅ Automatic ad request on first play
|
|
19
|
+
- ✅ Handles ad lifecycle events (start, complete, error, skipped, etc.)
|
|
20
|
+
- ✅ Responsive ad resizing on window resize
|
|
21
|
+
- ✅ Customizable locale, labels, and rendering settings
|
|
22
|
+
- ✅ Debug logging
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
### 1. Include the IMA SDK
|
|
27
|
+
|
|
28
|
+
Add the Google IMA SDK script to your HTML page:
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<script src="https://imasdk.googleapis.com/js/sdkloader/ima3.js"></script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 2. Include the Plugin
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<script src="path/to/g-ima-ads-plugin.js"></script>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 3. Initialize the MYETV Video Player
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<video id="my-video" controls>
|
|
44
|
+
<source src="video.mp4" type="video/mp4">
|
|
45
|
+
</video>
|
|
46
|
+
|
|
47
|
+
<script>
|
|
48
|
+
const player = new VideoPlayer('#my-video', {
|
|
49
|
+
// ... other player options
|
|
50
|
+
});
|
|
51
|
+
</script>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 4. Initialize the Google IMA Plugin
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
const imaPlugin = new GoogleIMAPlugin(player, {
|
|
58
|
+
adTagUrl: 'https://your-ad-server.example.com/vast-tag',
|
|
59
|
+
locale: 'en',
|
|
60
|
+
showCountdown: true,
|
|
61
|
+
showControls: true,
|
|
62
|
+
autoPlayAdBreaks: true,
|
|
63
|
+
vpaidMode: 'ENABLED',
|
|
64
|
+
vastLoadTimeout: 5000,
|
|
65
|
+
numRedirects: 4,
|
|
66
|
+
debug: false
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Setup the plugin
|
|
70
|
+
imaPlugin.setup();
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Configuration Options
|
|
74
|
+
|
|
75
|
+
All options are passed as the second argument to `new GoogleIMAPlugin(player, options)`.
|
|
76
|
+
|
|
77
|
+
| Option | Type | Default | Description |
|
|
78
|
+
|--------|------|---------|-------------|
|
|
79
|
+
| `adTagUrl` | String | `''` | VAST / VMAP ad tag URL (required unless `adsResponse` is provided) |
|
|
80
|
+
| `adsResponse` | String / Object | `null` | Pre-fetched VAST XML / JSON response instead of `adTagUrl` |
|
|
81
|
+
| `locale` | String | `'it'` | IMA UI locale (e.g. `en`, `it`, `fr`) |
|
|
82
|
+
| `showCountdown` | Boolean | `true` | Whether to show IMA countdown / UI elements |
|
|
83
|
+
| `showControls` | Boolean | `true` | Whether to allow ad controls (play/pause, etc.) |
|
|
84
|
+
| `autoPlayAdBreaks` | Boolean | `true` | Automatically play ad breaks when they are ready |
|
|
85
|
+
| `disableCustomPlaybackForIOS10Plus` | Boolean | `false` | IMA custom playback compatibility flag for iOS 10+ |
|
|
86
|
+
| `vastLoadTimeout` | Number | `5000` | VAST load timeout in milliseconds |
|
|
87
|
+
| `debug` | Boolean | `false` | Enable console debug logging |
|
|
88
|
+
| `vpaidMode` | String | `'ENABLED'` | `'ENABLED'`, `'INSECURE'`, or `'DISABLED'` for VPAID support |
|
|
89
|
+
| `adLabel` | String | `'ADS'` | Ad label text (e.g. "Ad", "Advertisement") |
|
|
90
|
+
| `adLabelNofN` | String | `'di'` | Separator for "Ad X of Y" text (e.g. "of") |
|
|
91
|
+
| `nonLinearWidth` | Number / `null` | `null` | Custom non-linear ad width (fallback: video width) |
|
|
92
|
+
| `nonLinearHeight` | Number / `null` | `null` | Custom non-linear ad height (fallback: video height / 3) |
|
|
93
|
+
| `numRedirects` | Number | `4` | Maximum number of allowed VAST redirects |
|
|
94
|
+
| `adsRenderingSettings` | Object | `{}` | Custom `AdsRenderingSettings` options merged into defaults |
|
|
95
|
+
|
|
96
|
+
## How It Works
|
|
97
|
+
|
|
98
|
+
Internally, the plugin:
|
|
99
|
+
|
|
100
|
+
1. Creates an **ad container** overlay (`div`) on top of the player container.
|
|
101
|
+
2. Creates an `AdDisplayContainer` with the video element and the ad container.
|
|
102
|
+
3. Creates an `AdsLoader` and listens for:
|
|
103
|
+
- `ADS_MANAGER_LOADED`
|
|
104
|
+
- `AD_ERROR`
|
|
105
|
+
4. On `ADS_MANAGER_LOADED`, it creates an `AdsManager` with `AdsRenderingSettings`.
|
|
106
|
+
5. Starts the ads by calling:
|
|
107
|
+
- `adsManager.init(width, height, ViewMode.NORMAL)`
|
|
108
|
+
- `adsManager.start()`
|
|
109
|
+
6. Listens to ad events (STARTED, COMPLETE, ALL_ADS_COMPLETED, SKIPPED, PAUSED, RESUMED, etc.) and forwards custom events to the player.
|
|
110
|
+
|
|
111
|
+
## Automatic Behavior
|
|
112
|
+
|
|
113
|
+
By default, the plugin:
|
|
114
|
+
|
|
115
|
+
- Requests ads on **first video play** if `adTagUrl` or `adsResponse` is provided.
|
|
116
|
+
- Shows the ad container when ads start.
|
|
117
|
+
- Hides the ad container when all ads complete or on ad error.
|
|
118
|
+
- Resumes content playback on ad error.
|
|
119
|
+
- Resizes ads on **window resize** to match the video size.
|
|
120
|
+
|
|
121
|
+
## Public Methods
|
|
122
|
+
|
|
123
|
+
### `setup()`
|
|
124
|
+
|
|
125
|
+
Initializes the plugin, creates the ad container, and prepares IMA.
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
imaPlugin.setup();
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### `requestAds()`
|
|
132
|
+
|
|
133
|
+
Explicitly request ads (already called automatically on first play, if configured).
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
imaPlugin.requestAds();
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### `dispose()`
|
|
140
|
+
|
|
141
|
+
Destroy ads manager, ads loader, and remove the ad container.
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
imaPlugin.dispose();
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Events
|
|
148
|
+
|
|
149
|
+
The plugin fires custom events on the MYETV player to help you react to ad lifecycle:
|
|
150
|
+
|
|
151
|
+
| Event | Description |
|
|
152
|
+
|-------|-------------|
|
|
153
|
+
| `adstarted` | Fired when an ad starts playing |
|
|
154
|
+
| `adcomplete` | Fired when a single ad completes |
|
|
155
|
+
| `allAdscomplete` | Fired when all ads in the pod / VMAP are finished |
|
|
156
|
+
| `adpaused` | Fired when an ad is paused |
|
|
157
|
+
| `adresumed` | Fired when an ad resumes |
|
|
158
|
+
| `adskipped` | Fired when an ad is skipped |
|
|
159
|
+
| `aderror` | Fired when an ad error occurs (also resumes content) |
|
|
160
|
+
|
|
161
|
+
Example:
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
player.on('adstarted', () => {
|
|
165
|
+
console.log('IMA ad started');
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
player.on('allAdscomplete', () => {
|
|
169
|
+
console.log('All IMA ads completed');
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
player.on('aderror', (e) => {
|
|
173
|
+
console.error('Ad error:', e);
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Ad Tag Requirements
|
|
178
|
+
|
|
179
|
+
You can use:
|
|
180
|
+
|
|
181
|
+
- **Google Ad Manager** VAST / VMAP tags
|
|
182
|
+
- **AdSense for Video** tags (if your account is approved)
|
|
183
|
+
- Third-party ad networks that provide **VAST/VMAP** URLs compatible with IMA
|
|
184
|
+
|
|
185
|
+
Example VAST tag URL (Google Ad Manager style):
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/123456789/video_ad_unit&env=vp&gdfp_req=1&output=vast&unviewed_position_start=1
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Set it in the plugin:
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
const imaPlugin = new GoogleIMAPlugin(player, {
|
|
195
|
+
adTagUrl: 'https://pubads.g.doubleclick.net/gampad/ads?...',
|
|
196
|
+
locale: 'en'
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
imaPlugin.setup();
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Iframe & Policy Considerations
|
|
203
|
+
|
|
204
|
+
- Google IMA is **designed** to work with iframes and manages its own internal ad iframes.
|
|
205
|
+
- However, general Google ads policy still applies:
|
|
206
|
+
- Use **friendly iframes** (same domain) whenever possible.
|
|
207
|
+
- Avoid using external iframes to circumvent ad limits or policies.
|
|
208
|
+
- For strict policy details, always refer to the latest Google IMA and AdSense/Ad Manager documentation.
|
|
209
|
+
|
|
210
|
+
## Troubleshooting
|
|
211
|
+
|
|
212
|
+
### No ads are playing
|
|
213
|
+
|
|
214
|
+
Check:
|
|
215
|
+
|
|
216
|
+
1. `adTagUrl` is a valid VAST/VMAP URL and returns a proper response.
|
|
217
|
+
2. IMA SDK script is loaded:
|
|
218
|
+
```html
|
|
219
|
+
<script src="https://imasdk.googleapis.com/js/sdkloader/ima3.js"></script>
|
|
220
|
+
```
|
|
221
|
+
3. Autoplay policies: some browsers block autoplay without user interaction.
|
|
222
|
+
4. If `debug: true` is enabled, watch the browser console for:
|
|
223
|
+
- Initialization logs
|
|
224
|
+
- Ad errors / warnings
|
|
225
|
+
|
|
226
|
+
### AdError events
|
|
227
|
+
|
|
228
|
+
Listen for `aderror`:
|
|
229
|
+
|
|
230
|
+
```javascript
|
|
231
|
+
player.on('aderror', (event) => {
|
|
232
|
+
console.error('IMA ad error:', event.error);
|
|
233
|
+
});
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
The plugin will automatically destroy the `AdsManager` and resume content playback on error.
|
|
237
|
+
|
|
238
|
+
## Browser Support
|
|
239
|
+
|
|
240
|
+
- Chrome / Edge (latest)
|
|
241
|
+
- Firefox (latest)
|
|
242
|
+
- Safari (desktop & iOS)
|
|
243
|
+
- Android Chrome
|
|
244
|
+
- Other modern browsers supporting HTML5 video and JavaScript
|
|
245
|
+
|
|
246
|
+
## License
|
|
247
|
+
|
|
248
|
+
Created by [MYETV.tv](https://www.myetv.tv) & [Oskar Cosimo](https://oskarcosimo.com)
|
|
249
|
+
|
|
250
|
+
## Related Plugins
|
|
251
|
+
|
|
252
|
+
- **Google AdSense Plugin** - Overlay display ads using standard AdSense units.
|
|
253
|
+
- See `g-adsense-ads-plugin.js` for banner-style overlays.
|
|
254
|
+
|
|
255
|
+
## Support
|
|
256
|
+
|
|
257
|
+
For issues or questions:
|
|
258
|
+
|
|
259
|
+
- GitHub Issues: https://github.com/OskarCosimo/myetv-video-player-opensource
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/* Google IMA Plugin for MYETV Video Player
|
|
2
2
|
* Integrates Google Interactive Media Ads SDK
|
|
3
3
|
* Supports VAST, VMAP, VPAID
|
|
4
4
|
* Created by https://www.myetv.tv https://oskarcosimo.com
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
vastLoadTimeout: options.vastLoadTimeout || 5000,
|
|
31
31
|
debug: options.debug || false,
|
|
32
32
|
vpaidMode: options.vpaidMode || 'ENABLED', // ENABLED, INSECURE, DISABLED
|
|
33
|
-
adLabel: options.adLabel || '
|
|
33
|
+
adLabel: options.adLabel || 'ADS',
|
|
34
34
|
adLabelNofN: options.adLabelNofN || 'di',
|
|
35
35
|
nonLinearWidth: options.nonLinearWidth || null,
|
|
36
36
|
nonLinearHeight: options.nonLinearHeight || null,
|