Use optimal self-hosted video for user by width#15561
Use optimal self-hosted video for user by width#15561
Conversation
fa4b4f0 to
be2b4d6
Compare
be2b4d6 to
0e973f4
Compare
0e973f4 to
24275c2
Compare
|
Hello 👋! When you're ready to run Chromatic, please apply the You will need to reapply the label each time you want to run Chromatic. |
dac04f1 to
5fc414a
Compare
c8c8f1a to
9313fcc
Compare
9313fcc to
9331026
Compare
| "footballMatch": { | ||
| "$ref": "#/definitions/{id:string;homeTeam:{name:string;id:string;scorers:string[];codename:string;players:{name:string;id:string;position:string;lastName:string;substitute:boolean;timeOnPitch:string;shirtNumber:string;events:{eventTime:string;eventType:string;}[];}[];possession:number;shotsOn:number;shotsOff:number;corners:number;fouls:number;colours:string;crest:string;score?:number;};awayTeam:{name:string;id:string;scorers:string[];codename:string;players:{name:string;id:string;position:string;lastName:string;substitute:boolean;timeOnPitch:string;shirtNumber:string;events:{eventTime:string;eventType:string;}[];}[];possession:number;shotsOn:number;shotsOff:number;corners:number;fouls:number;colours:string;crest:string;score?:number;};status:string;comments?:string;}" | ||
| }, | ||
| "matchInfo": { |
There was a problem hiding this comment.
Please ignore these changes - these are temporary to allow CI to run. It is not intended that these will be a part of this PR when it gets merged.
There was a problem hiding this comment.
OK, these changes are a part of the changeset when running make gen-schemas. I've narrowed it down to the changes in the video.ts file, but I cannot explain why. Since these changes are harmless, I will continue.
davidfurey
left a comment
There was a problem hiding this comment.
Great to share this code between articles and fronts. Sorry, I haven't reviewed the whole thing but have made a couple of comments.
9331026 to
5621360
Compare
| return DEFAULT_ASPECT_RATIO; | ||
| } | ||
|
|
||
| return firstSource.width / firstSource.height; |
There was a problem hiding this comment.
Why have you opted to calculate the aspect ratio rather than taking it from the video asset?
There was a problem hiding this comment.
Good point. I'll convert the string into a number, so that the aspect ratio defined on the video source is the source of truth for the aspect ratio passed into the component.
There was a problem hiding this comment.
Brilliant, this should help with m3u8 as well which are only passed with the aspect ratio, not the dimensions
b2b3469 to
b735be8
Compare
| const videoAssets = | ||
| convertFEMediaAssetsToVideoAssets(selfHostedAssets); | ||
| const sources = extractValidSourcesFromAssets(videoAssets); | ||
|
|
||
| const aspectRatio = getAspectRatioFromSources(sources); |
There was a problem hiding this comment.
This is all much cleaner to read 👏
abeddow91
left a comment
There was a problem hiding this comment.
Fantastic, this looks great!
What does this change?
Selects the optimal video from the list of video sources. Selects the best set of dimensions for the users screen size.
Use the same logic when extracting sources from assets for both fronts and articles.
Why?
To serve smaller videos to users without any reduction in video quality.
Logic for extracting sources is likely to be the same for both fronts and articles. Combining the logic into one function ensures that changes to one will affect the other.