Skip to content

Commit

Permalink
Changed element.remove, fixes #6
Browse files Browse the repository at this point in the history
Removed fauxVideoElement, appearantly fixing #7
  • Loading branch information
AleBles committed Sep 21, 2016
1 parent a62f362 commit 6498a7a
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 83 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = function (grunt) {
unused: true,
if_return: true,
join_vars: true,
drop_console: false
drop_console: true
},
mangle: true,
beautify: false
Expand Down
1 change: 0 additions & 1 deletion build/phaser-ads.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ declare module Fabrique {
private game;
private adRequested;
adManager: AdManager;
private fauxVideoElement;
private resizeListener;
constructor(game: Phaser.Game, adTagUrl: string);
setManager(manager: AdManager): void;
Expand Down
39 changes: 4 additions & 35 deletions build/phaser-ads.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/phaser-ads.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions build/phaser-ads.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "phaser-ads",
"author": "OrangeGames",
"version": "0.7.5",
"version": "0.8.0",
"description": "A Phaser plugin for providing nice ads integration in your phaser.io game",
"contributors": [
{
Expand All @@ -27,7 +27,7 @@
"grunt-contrib-uglify": "^0.11.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-typescript": "0.8.0",
"phaser": "2.5.0",
"phaser": "2.6.1",
"typescript": "1.8.x"
},
"engines": {
Expand Down
42 changes: 3 additions & 39 deletions ts/Providers/Ima3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ module Fabrique {

public adManager: AdManager = null;

private fauxVideoElement: HTMLMediaElement;

private resizeListener: ()=> void = null;

constructor(game: Phaser.Game, adTagUrl: string) {
Expand Down Expand Up @@ -57,19 +55,11 @@ module Fabrique {
this.adContent.style.height = '100%';
this.adContent.style.overflow = 'hidden';

//This is a work around for some ios failing issues
//iOS ima3 requires this information, but canvas doesn't provide it. so we create a a custom method
this.fauxVideoElement = this.gameContent.parentNode.appendChild(document.createElement('video'));
this.fauxVideoElement.id = 'phaser-ad-faux-video';
this.fauxVideoElement.style.position = 'absolute';
this.fauxVideoElement.style.zIndex = '999';
this.fauxVideoElement.style.display = 'none';

this.adTagUrl = adTagUrl;
this.game = game;

// Create the ad display container.
this.adDisplay = new google.ima.AdDisplayContainer(this.adContent, this.fauxVideoElement);
this.adDisplay = new google.ima.AdDisplayContainer(this.adContent);

//Set vpaid enabled, and update locale
(<any>google.ima.settings).setVpaidMode((<any>google.ima).ImaSdkSettings.VpaidMode.ENABLED);
Expand Down Expand Up @@ -128,22 +118,11 @@ module Fabrique {
adsRequest.nonLinearAdSlotWidth = width;
adsRequest.nonLinearAdSlotHeight = height;

if (this.game.device.iOS) {
this.fauxVideoElement.style.width = width + 'px';
this.fauxVideoElement.style.height = height + 'px';
}


//Required for games, see:
//http://googleadsdeveloper.blogspot.nl/2015/10/important-changes-for-gaming-publishers.html
adsRequest.forceNonLinearFullSlot = true;

try {
if (this.game.device.iOS) {
//We need to play the video element on click, otherwise iOS won't work :(
this.fauxVideoElement.play();
}

this.adRequested = true;
this.adLoader.requestAds(adsRequest);
} catch (e) {
Expand Down Expand Up @@ -212,9 +191,6 @@ module Fabrique {

try {
//Show the ad elements, we only need to show the faux videoelement on iOS, because the ad is displayed in there.
if (this.game.device.iOS) {
this.fauxVideoElement.style.display = 'block';
}
this.adContent.style.display = 'block';

// Initialize the ads manager. Ad rules playlist will start at this time.
Expand Down Expand Up @@ -258,15 +234,6 @@ module Fabrique {
{
this.onContentResumeRequested();
}
//Work around for skip/end not registering @ ios
if (this.game.device.iOS) {
let intervalId = setInterval(() => {
if (this.fauxVideoElement.src.length > 0) {
this.onContentResumeRequested();
clearInterval(intervalId);
}
}, 200);
}
break;
case google.ima.AdEvent.Type.STARTED:
this.adManager.onAdProgression.dispatch(Plugins.AdEvent.start);
Expand Down Expand Up @@ -329,9 +296,6 @@ module Fabrique {
}

this.adContent.style.display = 'none';
if (this.game.device.iOS) {
this.fauxVideoElement.style.display = 'none';
}
this.adManager.onContentResumed.dispatch();
}

Expand Down Expand Up @@ -368,10 +332,10 @@ module Fabrique {
if (test.offsetHeight === 0) {
enabled = false;
}
test.remove();
test.parentNode.removeChild(test);

return enabled;
}
};

window.setTimeout(adsEnabled = isEnabled(), 100);

Expand Down
2 changes: 1 addition & 1 deletion vendor/google-ima3-sdk.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ declare module GoogleAds.ima {
}

class AdDisplayContainer {
constructor(content: HTMLElement, ad: HTMLElement, customClickTrack?: HTMLElement);
constructor(content: HTMLElement, ad?: HTMLElement, customClickTrack?: HTMLElement);
initialize(): void;
}
}
Expand Down

0 comments on commit 6498a7a

Please sign in to comment.