Skip to content
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

Implement source-first ordering in "selectSource" as an optional over… #2847

Closed
wants to merge 7 commits into from

Conversation

imbcmdth
Copy link
Member

…ride to the currently implemented default "tech-first" ordering

Video.js currently uses a tech-first slection algorithm (ie. find the first source that can be decoded by the first tech. if none, try the next tech and repeat.) but the video element does something more like source-first. This commit implements the semantics of an optional source-first selection system in video.js

@pam
Copy link

pam commented Nov 23, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: 0b7ca4129f4f3953d9697e11cfaf11745051ed9d
Build details: https://travis-ci.org/pam/video.js/builds/92788871

(Please note that this is a fully automated comment.)

};

let foundSourceAndTech;
let flipFn = (fn) => (a, b) => fn(b, a);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just flip and finder?

@pam
Copy link

pam commented Nov 23, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 71bfad903a78fdec6f2b9e3c00fc3fb824122877
Build details: https://travis-ci.org/pam/video.js/builds/92790585

(Please note that this is a fully automated comment.)

@pam
Copy link

pam commented Nov 23, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 9a79e9eca6e279b92156639656b87ca42257fda6
Build details: https://travis-ci.org/pam/video.js/builds/92793794

(Please note that this is a fully automated comment.)

@pam
Copy link

pam commented Nov 23, 2015

Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED

Commit: 8aec518ef57c217aed7078a8ebca358970386822
Build details: https://travis-ci.org/pam/video.js/builds/92794152

(Please note that this is a fully automated comment.)

@pam
Copy link

pam commented Nov 23, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 423dd27f6cf95424f505211974c5ae870011543f
Build details: https://travis-ci.org/pam/video.js/builds/92797548

(Please note that this is a fully automated comment.)

// Extend TechFaker to create a tech that plays the only mime-type that TechFaker
// will not play
import Tech from '../../src/js/tech/tech.js';
import TechFaker from './tech/tech-faker.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we were ever explicit about this but I thought the style-consensus among the @videojs/core-committers was for imports to live at the top of the file only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are required to be at the top of the file. Only reason it hasn't complained is because we're putting babel into loose mode.

@dmlap
Copy link
Member

dmlap commented Nov 23, 2015

We probably should add some doc for the new option.

fixture.innerHTML += html;
var tag = document.getElementById('example_1');

var player = new Player(tag, { techOrder: ['techFaker', 'playsUnsupported'], sourceOrder: true });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost every other tests in that file is using var seems like a silly thing to change for one test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We kind of skimped on the migration of tests to full es6.
However, new code should definitely be with lets and what not.

@gkatsev
Copy link
Member

gkatsev commented Nov 23, 2015

Hm... I'm not sure we really have a place to document these options.

@gkatsev
Copy link
Member

gkatsev commented Nov 23, 2015

Probably best place to document the option, besides the function's jsdoc might be in another section on this page: https://github.com/videojs/docs/blob/master/docs/guides/options.html
Currently, the options there are only for options that are also video element attributes.

@imbcmdth
Copy link
Member Author

@gkatsev Hmm. I added documentation to the tech.md guide since it is there where we mention techOrder.

@gkatsev
Copy link
Member

gkatsev commented Nov 23, 2015

@rcrooks do we use the docs/ directory in this repo anymore?

@gkatsev
Copy link
Member

gkatsev commented Nov 23, 2015

Yeah, I guess that location is fine. Now we need to figure out whether it should be in this repo or in the docs repo. Also, the jsdoc for the function should be updated.


let foundSourceAndTech;
let flip = (fn) => (a, b) => fn(b, a);
let finder = (techArr, source) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to be fancy:

let finder = ([techName, tech], source) => {
  if (tech.canPlaySource(source)) {
    return {source: source, tech: techName};
  }
};

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be fancy.

@pam
Copy link

pam commented Nov 23, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: a1de5ca4d779ddfc7b0a27cda1052d555e2a1153
Build details: https://travis-ci.org/pam/video.js/builds/92813318

(Please note that this is a fully automated comment.)

@pam
Copy link

pam commented Nov 23, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: c37f28b06029e8dcc42421e45ab4552dbab4f4ab
Build details: https://travis-ci.org/pam/video.js/builds/92814381

(Please note that this is a fully automated comment.)

let techs =
this.options_.techOrder
.map(toTitleCase)
.map((techName) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// `Component.getComponent(...)` is for support of old behavior of techs
// being registered as components.
// Remove once that deprecated behavior is removed.
.map((techName) => [techName, Tech.getTech(techName) || Component.getCompnent(techName)])

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like putting that much distance between chained property accesses. The reason the comment is inside the function in the first place is that it doesn't "break the chain" and indentation makes things even more clear.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok either way. If we update getTech to automatically try calling getComponent, then, we could probably just remove the comment altogether and have the nice oneliner here.

@pam
Copy link

pam commented Nov 23, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: aed2ad0174b0b9158ddfacb5182777836af1c9ae
Build details: https://travis-ci.org/pam/video.js/builds/92815408

(Please note that this is a fully automated comment.)


With a player setup as follows:

<video data-setup='{"techOrder": ["html5", "flash"]}, "sourceOrder": true'>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourceOrder should be moved to the data-setup json.

@gkatsev
Copy link
Member

gkatsev commented Nov 24, 2015

Small comment on the docs.
LGTM.

@gkatsev gkatsev added the minor This PR can be added to a minor release. It should not be added to a patch release. label Nov 24, 2015
@pam
Copy link

pam commented Nov 24, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 82df17e41cea6d94b160c0ff6624dd9a5d712b9a
Build details: https://travis-ci.org/pam/video.js/builds/92977110

(Please note that this is a fully automated comment.)

jrivera added 7 commits November 25, 2015 16:56
…ride to the currently implemented default "tech-first" ordering

Video.js currently uses a tech-first slection algorithm (ie. find the first source that can be decoded by the first tech. if none, try the next tech and repeat.) but the video element does something more like source-first. This commit implements the semantics of an optional source-first selection system in video.js
@pam
Copy link

pam commented Nov 25, 2015

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 4aef350
Build details: https://travis-ci.org/pam/video.js/builds/93253360

(Please note that this is a fully automated comment.)

@gkatsev gkatsev closed this in 69b89e5 Nov 25, 2015
@gkatsev gkatsev mentioned this pull request Nov 25, 2015
jgubman added a commit to jgubman/video.js that referenced this pull request Jan 27, 2016
* upstream/stable: (479 commits)
  v5.4.4
  @gkatsev switched to use custom vtt.js from npm. closes videojs#2905
  v5.4.3
  @gkatsev updated options customizer and github-release options. closes videojs#2903
  v5.4.2
  @gkatsev updated grunt-release config. closes videojs#2900
  v5.4.1
  @gkatsev added chg- and github- release for next releases. closes videojs#2899
  v5.4.0
  @gkatsev added ability to release next tag from master. closes videojs#2894
  @gkatsev added nullcheck for cues in updateForTrack. Fixes videojs#2870. closes videojs#2896
  @chemoish emulated HTMLTrackElement to enable track load events. closes videojs#2804
  @gkatsev added a Player#reset method. Fixes videojs#2852. closes videojs#2880
  @nick11703 changed multiline comments in sass with single-line comments. closes videojs#2827
  @gkatsev added Player#tech. Fixes videojs#2617. closes videojs#2883
  @misteroneill updated videojs-ie8 to 1.1.1. closes videojs#2869
  v5.3.0
  @imbcmdth added sourceOrder option for source-first ordering in selectSource. closes videojs#2847
  @forbesjo updated formatTime to not go negative. closes videojs#2821
  v5.2.4
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor This PR can be added to a minor release. It should not be added to a patch release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants