Skip to content

Commit

Permalink
3.0.6
Browse files Browse the repository at this point in the history
- fixes iPadOS detection and show mobile UI on iPadOS (like on iOS)
  • Loading branch information
radiantmediaplayer committed Apr 22, 2021
1 parent 90230fe commit 8b993d1
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 1,071 deletions.
13 changes: 6 additions & 7 deletions app/dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,23 @@
<body>
<div class="rmp-container" id="rmpPlayer">
<div class="rmp-content">
<video class="rmp-video"
src="https://www.rmp-streaming.com/media/big-buck-bunny-360p.mp4" playsinline muted
controls>
<video class="rmp-video" src="https://www.rmp-streaming.com/media/big-buck-bunny-360p.mp4"
playsinline muted controls>
</video>
</div>
</div>
<script type="module">
import { RmpVast } from '../js/src/index.js';
var id = 'rmpPlayer';
var container = document.getElementById(id);
var ADTAG2 = 'https://www.radiantmediaplayer.com/vast/tags/inline-linear.xml?VASTVERSIONS=[VASTVERSIONS]&MEDIAMIME=[MEDIAMIME]';
// var ADTAG = 'https://www.radiantmediaplayer.com/vast/tags/non-linear.xml';
// var ADTAG3 = 'https://www.radiantmediaplayer.com/vast/tags/ad-pod-all-wrappers.xml';
// var ADTAG2 = 'https://www.radiantmediaplayer.com/vast/tags/inline-linear.xml?VASTVERSIONS=[VASTVERSIONS]&MEDIAMIME=[MEDIAMIME]';
var ADTAG = 'https://www.radiantmediaplayer.com/vast/tags/inline-linear-1.xml';
// var ADTAG3 = 'https://www.radiantmediaplayer.com/vast/tags/ad-pod-all-wrappers.xml';
//var ADTAG2 = 'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator=';
var params = {
ajaxWithCredentials: false
};
window.rmpVast = new RmpVast(id, params, true);
window.rmpVast.loadAds(ADTAG2);
window.rmpVast.loadAds(ADTAG);
</script>
</body>
2 changes: 1 addition & 1 deletion css/rmp-vast.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/roboto/v20/KFOmCnqEu92Fr1Mu4mxP.ttf) format('truetype');
src: url(https://fonts.gstatic.com/s/roboto/v27/KFOmCnqEu92Fr1Mu4mxP.ttf) format('truetype');
}
.rmp-container {
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion css/rmp-vast.min.css

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

30 changes: 25 additions & 5 deletions js/src/fw/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ const _getUserAgent = function () {
};
const userAgent = _getUserAgent();

const _getPlatform = function () {
if (navigator && navigator.platform) {
return navigator.platform;
}
return null;
};
const platform = _getPlatform();

const _filterVersion = function (pattern) {
if (userAgent !== null) {
const versionArray = userAgent.match(pattern);
Expand All @@ -40,6 +48,14 @@ const _getDevicePixelRatio = function () {
};
ENV.devicePixelRatio = _getDevicePixelRatio();

const _maxTouchPoints = function () {
if (navigator && typeof navigator.maxTouchPoints === 'number') {
return navigator.maxTouchPoints;
}
return -1;
};
ENV.maxTouchPoints = _maxTouchPoints();

const IOS_PATTERN = /(ipad|iphone|ipod)/i;
const IOS_VERSION_PATTERN = /os\s+(\d+)_/i;
const _isIos = function () {
Expand All @@ -65,7 +81,7 @@ const _isMacOS = function () {
}
return [isMacOS, macOSXMinorVersion];
};
const isMacOS = _isMacOS();
let isMacOS = _isMacOS();

const SAFARI_PATTERN = /safari\/[.0-9]*/i;
const SAFARI_VERSION_PATTERN = /version\/(\d+)\./i;
Expand All @@ -81,13 +97,18 @@ const _isSafari = function () {
};
const isSafari = _isSafari();

const MAC_PLATFORM_PATTERN = /macintel/i;
const _isIpadOS = function () {
if (!isIos[0] && isSafari[0] && isSafari[1] > 12 && isMacOS[0] && isMacOS[1] > 14 && ENV.devicePixelRatio > 1) {
if (!isIos[0] && hasTouchEvents && MAC_PLATFORM_PATTERN.test(platform) && devicePixelRatio > 1 &&
ENV.maxTouchPoints > 1) {
return true;
}
return false;
};
ENV.isIpadOS = _isIpadOS();
if (ENV.isIpadOS) {
isMacOS = [false, -1];
}

const ANDROID_PATTERN = /android/i;
const ANDROID_VERSION_PATTERN = /android\s*(\d+)\./i;
Expand All @@ -99,7 +120,7 @@ const _isAndroid = function () {
if (ANDROID_PATTERN.test(userAgent)) {
support = [true, _filterVersion(ANDROID_VERSION_PATTERN)];
}
return support;
return support;
};

// from https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
Expand Down Expand Up @@ -131,10 +152,9 @@ const _hasNativeFullscreenSupport = function () {
return false;
};

ENV.isSafari = isSafari;
ENV.isIos = isIos;
ENV.isAndroid = _isAndroid();
ENV.isMacOS = _isMacOS();
ENV.isMacOSSafari = isMacOS[0] && isSafari[0];
ENV.isFirefox = _isFirefox();
ENV.isMobile = false;
if (ENV.isIos[0] || ENV.isAndroid[0] || ENV.isIpadOS) {
Expand Down
4 changes: 3 additions & 1 deletion js/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license Copyright (c) 2017-2020 Radiant Media Player | https://www.radiantmediaplayer.com
* rmp-vast 3.0.5
* rmp-vast 3.0.6
* GitHub: https://github.com/radiantmediaplayer/rmp-vast
* MIT License: https://github.com/radiantmediaplayer/rmp-vast/blob/master/LICENSE
*/
Expand Down Expand Up @@ -50,6 +50,8 @@ export class RmpVast {
}
if (this.debug) {
FW.log('creating new RmpVast instance');
FW.log('environment follows');
FW.log(null, ENV);
FW.logVideoEvents(this.contentPlayer, 'content');
}
// reset loadAds variables - this is reset at addestroyed
Expand Down
2 changes: 1 addition & 1 deletion js/src/utils/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ DEFAULT.instanceVariables = function () {
// on iOS and macOS Safari we use content player to play ads
// to avoid issues related to fullscreen management and autoplay
// as fullscreen on iOS is handled by the default OS player
if (ENV.isIos[0] || (ENV.isMacOS[0] && ENV.isSafari[0]) || ENV.isIpadOS) {
if (ENV.isIos[0] || ENV.isMacOSSafari || ENV.isIpadOS) {
this.useContentPlayerForAds = true;
if (this.debug) {
FW.log('vast player will be content player');
Expand Down
Loading

0 comments on commit 8b993d1

Please # to comment.