bigscreen-player
Advanced tools
Comparing version 3.11.0 to 3.12.0
{ | ||
"name": "bigscreen-player", | ||
"version": "3.11.0", | ||
"version": "3.12.0", | ||
"description": "Simplified media playback for bigscreen devices.", | ||
@@ -5,0 +5,0 @@ "main": "script/bigscreenplayer.js", |
@@ -347,20 +347,62 @@ require( | ||
it('should leave the manifest unchanged for absolute base urls', function () { | ||
var manifest = { | ||
Period: { | ||
BaseURL: 'http://cdn-a.com/dash/' | ||
} | ||
}; | ||
describe('should return a single base url object for absolute base urls', function () { | ||
var expectedManifest = { | ||
Period: { | ||
BaseURL: 'http://cdn-a.com/dash/' | ||
} | ||
Period: {}, | ||
BaseURL: { __text: 'https://cdn-a.com/dash/', 'dvb:priority': 0, serviceLocation: 'https://cdn-a.com/' }, | ||
BaseURL_asArray: [ | ||
{ __text: 'https://cdn-a.com/dash/', 'dvb:priority': 0, serviceLocation: 'https://cdn-a.com/' } | ||
] | ||
}; | ||
ManifestModifier.generateBaseUrls(manifest, sources); | ||
it('the url is on the manifest as a string', function () { | ||
var manifest = { | ||
Period: {}, | ||
BaseURL: 'https://cdn-a.com/dash/' | ||
}; | ||
expect(manifest).toEqual(expectedManifest); | ||
}); | ||
ManifestModifier.generateBaseUrls(manifest, sources); | ||
expect(manifest).toEqual(expectedManifest); | ||
}); | ||
it('the url is on the manifest as an object', function () { | ||
var manifest = { | ||
Period: {}, | ||
BaseURL: { | ||
__text: 'https://cdn-a.com/dash/' | ||
} | ||
}; | ||
ManifestModifier.generateBaseUrls(manifest, sources); | ||
expect(manifest).toEqual(expectedManifest); | ||
}); | ||
it('the url is on the manifest in the period as a string', function () { | ||
var manifest = { | ||
Period: { | ||
BaseURL: 'https://cdn-a.com/dash/' | ||
} | ||
}; | ||
ManifestModifier.generateBaseUrls(manifest, sources); | ||
expect(manifest).toEqual(expectedManifest); | ||
}); | ||
it('the url is on the manifest in the period as an object', function () { | ||
var manifest = { | ||
Period: { | ||
BaseURL: { | ||
__text: 'https://cdn-a.com/dash/' | ||
} | ||
} | ||
}; | ||
ManifestModifier.generateBaseUrls(manifest, sources); | ||
expect(manifest).toEqual(expectedManifest); | ||
}); | ||
}, | ||
it('should leave the manifest unchanged if there is no base url', function () { | ||
@@ -378,3 +420,3 @@ var manifest = { | ||
expect(manifest).toEqual(expectedManifest); | ||
}); | ||
})); | ||
}); | ||
@@ -381,0 +423,0 @@ }); |
@@ -41,3 +41,17 @@ define('bigscreenplayer/manifest/manifestmodifier', | ||
function extractBaseUrl (manifest) { | ||
return manifest.Period && manifest.Period.BaseURL || manifest.BaseURL && manifest.BaseURL.__text; | ||
if (manifest.Period && typeof manifest.Period.BaseURL === 'string') { | ||
return manifest.Period.BaseURL; | ||
} | ||
if (manifest.Period && manifest.Period.BaseURL && typeof manifest.Period.BaseURL.__text === 'string') { | ||
return manifest.Period.BaseURL.__text; | ||
} | ||
if (typeof manifest.BaseURL === 'string') { | ||
return manifest.BaseURL; | ||
} | ||
if (manifest.BaseURL && typeof manifest.BaseURL.__text === 'string') { | ||
return manifest.BaseURL.__text; | ||
} | ||
} | ||
@@ -47,13 +61,27 @@ | ||
var baseUrl = extractBaseUrl(manifest); | ||
if (!baseUrl || baseUrl.match(/^https?:\/\//)) return; | ||
var baseUrls = []; | ||
if (!baseUrl) return; | ||
var baseUrls = sources.map(function (source, priority) { | ||
var sourceUrl = new URL(baseUrl, source); | ||
function generateBaseUrl (source, priority, serviceLocation) { | ||
return { | ||
__text: sourceUrl.href, | ||
__text: source, | ||
'dvb:priority': priority, | ||
serviceLocation: source | ||
serviceLocation: serviceLocation | ||
}; | ||
}); | ||
} | ||
if (baseUrl.match(/^https?:\/\//)) { | ||
var newBaseUrl = generateBaseUrl(baseUrl, 0, sources[0]); | ||
baseUrls = [newBaseUrl]; | ||
if (manifest && (manifest.BaseURL || manifest.Period && manifest.Period.BaseURL)) { | ||
manifest.BaseURL = newBaseUrl; | ||
} | ||
} else { | ||
baseUrls = sources.map(function (source, priority) { | ||
var sourceUrl = new URL(baseUrl, source); | ||
return generateBaseUrl(sourceUrl.href, priority, source); | ||
}); | ||
} | ||
manifest.BaseURL_asArray = baseUrls; | ||
@@ -60,0 +88,0 @@ if (manifest && manifest.Period && manifest.Period.BaseURL) delete manifest.Period.BaseURL; |
@@ -65,3 +65,3 @@ define('bigscreenplayer/mediasources', | ||
function shouldFailover (failoverParams) { | ||
if (failoverParams.serviceLocation === getCurrentUrl()) { | ||
if (isFirstManifest(failoverParams.serviceLocation)) { | ||
return false; | ||
@@ -77,2 +77,9 @@ } | ||
// we don't want to failover on the first playback | ||
// the serviceLocation is set to our first cdn url | ||
// see manifest modifier - generateBaseUrls | ||
function isFirstManifest (serviceLocation) { | ||
return serviceLocation === getCurrentUrl(); | ||
} | ||
function isFailoverInfoValid (failoverParams) { | ||
@@ -79,0 +86,0 @@ var infoValid = typeof failoverParams === 'object' && |
define('bigscreenplayer/version', | ||
function () { | ||
return '3.11.0'; | ||
return '3.12.0'; | ||
} | ||
); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7849255
76062