-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(FEC-7815): Support playManifest redirects for external streams #85
Changes from 2 commits
3e79b0c
c4b4b9d
65e6956
a177bb4
0282ff7
0c4f4ea
be3e78f
47b75b7
1e5e163
3eb1204
1e32fa0
51e3054
1a1cdfe
9121f62
484767d
7facc56
29f8db7
6794d7a
3fcdd5f
4d5cf0f
f45592f
cd9bd83
50f9cf8
0a8cf79
c7ea59e
0f82a4f
8556f06
878ad3c
49654b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// @flow | ||
import {Env} from 'playkit-js' | ||
|
||
/** | ||
* jsonp callback function, returns the direct manifest uri | ||
* @param {Object} data - the json object that returns from the server | ||
* @param {string} uri - original request uri | ||
* @returns {string} returns the direct uri | ||
*/ | ||
function getDirectManfiestUri(data: Object, uri: string): string { | ||
const getParsedUri = uri => { | ||
const parser = document.createElement('a'); | ||
parser.href = uri; | ||
return { | ||
'hostname': parser.hostname, | ||
'uri': uri | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing semicolon There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why to return an object if u use only the hostname field outside? |
||
}; | ||
|
||
const uriHost = getParsedUri(uri).hostname; | ||
const flavorUriHost = getParsedUri(data.flavors[0].url).hostname | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unsafe access to object |
||
if (data.flavors.length === 1 && uriHost !== flavorUriHost) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @odedhutzler please document this part inline - since this logic is not very clear at first There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. k |
||
return data.flavors[0].url; | ||
} else { | ||
return uri; | ||
} | ||
} | ||
|
||
/** | ||
* returns if we should use our jsonp http plugin | ||
* @param {Object} config - configuration relevant to jsonp | ||
* @returns {boolean} should or not use jsonp requests on manifests | ||
*/ | ||
function shouldUseJsonp(config: Object): boolean{ | ||
if ((config && config.useJsonp) || Env.browser.name.includes("IE") || Env.browser.name.includes("Edge")){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @odedhutzler we already know that Panasonic browser need it too - please add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we do better then browser sniffing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. beautify There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @OrenMe I can change it to more configured... like |
||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* add jsonp configuration to the general config | ||
* @param {Object} config - configuration relevant to jsonp | ||
* @returns {void} | ||
*/ | ||
function configureJsonp(config: Object): void{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. beautify |
||
config.playback = config.playback || {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should align this as general adapter config and not via direct and specific HLS or DASH settings. |
||
config.playback.options = config.playback.options || {}; | ||
config.playback.options.html5 = config.playback.options.html5 || {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @odedhutzler we have a function for that please use it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. k |
||
if (shouldUseJsonp(config.playback.options.html5.dash)){ | ||
config.playback.options.html5.dash = config.playback.options.html5.dash || {}; | ||
config.playback.options.html5.dash.useJsonp = true; | ||
config.playback.options.html5.dash.callback = getDirectManfiestUri; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too generic names for configurations (see my suggestion bellow). |
||
} | ||
if (shouldUseJsonp(config.playback.options.html5.hls)){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why separate config for hls and dash? {
playback: {
options: {
tryRedirectForExternalStreams: true,
redirectForExternalStreamsHandler: () => {....}
html5: {
}
}
}
} Not even sure it should be under options, need to discuss the placement of this anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i agree, though i must add the handler to the dash/hls config There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thought it gets the specific config, but you are right, i will change it. |
||
config.playback.options.html5.hls = config.playback.options.html5.hls || {}; | ||
config.playback.options.html5.hls.useJsonp = true; | ||
config.playback.options.html5.hls.callback = getDirectManfiestUri; | ||
} | ||
} | ||
|
||
export {configureJsonp} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import { | |
} from './common/utils/setup-helpers' | ||
import {evaluatePluginsConfig} from './common/plugins/plugins-config' | ||
import './assets/style.css' | ||
import {configureJsonp} from './common/utils/jsonp-helper' | ||
|
||
export default class KalturaPlayer { | ||
_player: Player; | ||
|
@@ -22,6 +23,7 @@ export default class KalturaPlayer { | |
constructor(options: KalturaPlayerOptionsObject) { | ||
this._player = loadPlayer(options.player); | ||
this._logger = getLogger('KalturaPlayer' + Utils.Generator.uniqueId(5)); | ||
configureJsonp(this._player._config); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move to default options There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
this._uiManager = new UIManager(this._player, options.ui); | ||
setUITouchConfig(options.ui.forceTouchUI, this._uiManager); | ||
this._provider = new Provider(options.provider, __VERSION__); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parser? looks like an element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's purpose is to parse the url