1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-04 10:34:51 +02:00
Commit Graph

71 Commits

Author SHA1 Message Date
Brandon Casey
e8e4fe2745 feat(autoplay): extend autoplay option for greater good (#5209)
This PR extends the `autoplay` to the player with a few options that should hopefully make working with browsers that disable unmuted autoplay by default easier.
The current boolean option will match current behavior and any unknown option will be treated as it does now. The new options are the string values `muted`, `play`, and `any`.

- `muted` will mute the element and call `play()` on `loadstart`,
- `play` will call `play()` on `loadstart()`, this is similar to the `autoplay` attribute
- `any` will call `play()` on `loadstart()` but if it fails it will try muting the video and calling `play()` again.
2018-06-21 14:32:07 -04:00
Oshin Karamian
083a86c363 feat: split overrideNative method into separate methods (#5107)
Split overrideNative method into one for Audio and Video. Fixes issues with differing track support in IE11.
2018-04-19 20:11:11 -04:00
Oshin Karamian
22bbbc948c feat: add tech method to allow override native audio and video (#5074) 2018-04-19 13:16:01 -04:00
Chuck Wilson
a2851fe4bd feat: Queue playback events when the playback rate is zero and we are seeking (#5024)
SourceHandlers that use MSE have a problem: if they push a segment into a SourceBuffer and then seek close to the end, playback will stall and/or there will be a massive downswitch in quality. The general approach to fixing this that was discussed on slack was by setting the playback rate of the player to zero, buffering all that was required, and then restoring the previous playback rate. In my implementation, I've done this in the source handler (see: videojs/videojs-contrib-hls#1374).

From the video.js perspective, it should ensure that the UI reflects the buffering status and that the player API behaves like you'd expect -- that is to say, that it will fire seeking immediately after a call to currentTime, and it will fire seeked, canplay, canplaythrough, and playing when everything is buffered.
2018-04-17 15:28:35 -04:00
Michael Vogel
8706941573 feat: Allow techs to change poster if player option techCanOverridePoster is set (#4921)
The option for the player techCanOverridePoster is introduced in this commit. It allows techs to update the post whenever they like. isPosterFromTech_ is introduced as a private player field in order to track when a poster was set by a tech. This allows us to clear the poster whenever the tech is disposed of by the player.

Additionally, attempting to set the same poster more than once will have no effect / no changes will be made, since the poster is the same. This was done in order to stop triggering multiple posterchange events when calling player.poster(aPoster) with techCanOverridePoster set to true.

When a tech is disposed and a poster was set by it, unset the poster.

Pass a `canOverridePoster` option to techs to know whether techCanOverridePoster was set.

Fixes #4910.
2018-03-07 14:31:50 -05:00
Brandon Casey
df96a74f6b feat: sourceset event (#4660)
Trigger a sourceset event whenever the source is set in the Html5 tech, including initial source. We override the video element's src and setAttribute methods so that we can trigger the sourceset event when people change the src with both the video element and our API methods.
The event object for sourceset will contain the src string that was provided at the time the sourceset was triggered. This is mostly important if a source is being set while a tech is changing.
A Tech has a featuresSourceset option that it can set to for sourceset handling. It can then call the helper triggerSourceset(src) to trigger the sourceset.
2018-03-07 14:28:37 -05:00
Gary Katsevman
29a8ee1d60
fix: cache middleware instances per player (#4939)
Middleware factories currently get run each time a source is set. Because middleware are assocated with a player, the factories should only run once per player.

This PR fixes it so that we associate a middleware instance with a middleware factory per player.
Each time a player is disposed, we will clear the cache of the middleware instances for that player.

Fixes #4677.
2018-02-12 17:30:27 -05:00
Gary Katsevman
7670db63cd
fix(middleware): do a null check in mediator methods (#4913) 2018-01-31 10:46:58 -05:00
ldayananda
bf3eb45a37 feat: add mediator middleware type for play() (#4868)
This will allow middleware to interact with calls to play() from the tech. This will require a method of indicating to middleware previously run that a middleware down the chain has terminated or stopped execution.

* Adds middleware mediator method that runs middleware from the player to the tech and a second time back up to the player. This category was created because play is both a setter(changes the playback state) and a getter(gets a native play promise if available). This also has the ability to tell whether a middleware has terminated before reaching the tech.
* Adds a middleware.TERMINATOR sentinel value that is available on the videojs object
* Adds play to the allowedMediators
* Adds paused to the allowedGetters
* Adds a sandbox example of a play mediator middleware
2018-01-30 11:30:42 -05:00
mister-ben
f03ac5e9b5 fix: do not patch canplaytype on android chrome (#4885)
Patching canPlayType on Android shouldn't be necessary on Android Chrome since it reports its ability to player HLS correctly.
2018-01-30 11:20:33 -05:00
Gary Katsevman
6fe7a9a3dd
fix: force autoplay in Chrome (#4804)
Chrome has started pausing autoplaying video elements when they are
moved in the DOM. Here we need to make sure that if the video started
autoplaying, after we move the element in the DOM we call play again.

Fixes #4720.
2017-12-14 11:24:48 -05:00
Brandon Casey
06641e8694 test: update tests to use qunit 2 assert format (#4753) 2017-11-16 18:12:09 -05:00
Gary Katsevman
82c8b80548 fix: auto-removal remote text tracks being removed when not supposed to (#4450)
We added a feature so that remote text tracks can auto-removed when a source changes. However, in 6.x we changed the source behavior to be asynchronous meaning that some text tracks were accidentally being removed when they weren't supposed to be.
For example:
```js
var player = videojs('my-player');
player.src({src: 'video.mp4', type: 'video/mp4'});
 // set second arg to false so that they get auto-removed on source change
player.addRemoteTextTrack({kind: 'captions', src: 'text.vtt', srclang: 'en'}, false);
```
Now when the player loads, this captions track is actually missing because it was removed.

Instead of adding auto-removal tracks immediately to the list, wait until we've selected a source before adding them in.


Fixes #4403 and #4315.
2017-06-28 16:38:29 +10:00
Alex Barstow
8d80a5846e feat: add 'playsinline' player option (#4348)
Video.js players can accept a number of standard <video> element options (autoplay, muted, loop, etc), but not currently playsinline, which is now part of the [HTML spec](https://html.spec.whatwg.org/multipage/embedded-content.html#attr-video-playsinline). We should add it to the list of <video> attributes that can be provided to the player as options.
2017-05-12 16:39:37 -04:00
Garrett
483e5a2ca5 feat: Add getVideoPlaybackQuality API (#4338)
Provides a tech getter for getVideoPlaybackQuality as specified by the W3C's Media Playback Quality API: https://wicg.github.io/media-playback-quality/.
2017-05-12 15:22:02 -04:00
mister-ben
da0f1ee681 feat: remove playbackRate blacklist for recent Android Chrome (#4321)
Android Chrome now supports playbackRate properly, so removes the blacklist added in #3246 for newer Chrome versions.
Adds `browser.CHROME_VERSION` as a necessary evil.
No longer blacklists for Chrome 58+ -- this could possibly be fixed since 52, but 58 is all I've been able to test on and most users should keep Chrome up to date.
2017-05-11 16:59:22 -04:00
Brandon Casey
a2b1a33606 fix: cues at startTime 0 do not fire (#4152)
Previously timeupdate would fire before the video was playing, and the tech was not ready. This caused issues when preload was set to auto, because cuechange would fire before the video was even started for cues with a startTime of 0.

Wait for tech to be ready before watching for timeupdate
update unit tests to use TechFaker
Add a unit test to verify that we wait for Tech to be ready.
2017-03-02 14:35:45 -05:00
mister-ben
405b29b8f1 fix: remove redundant Html5#play()
play() is defined twice in Html5. The promise handling in the earlier one was moved into Player#play().
2017-02-21 15:48:45 -05:00
Brandon Casey
a8f2e43274 feat: videojs.getTech works with TitleCase or camelCase names (#4010)
* Fixes #3986 
* update `techOptions` to look for `TitleCase`/`camelCase` user tech options
* remove deprecated usage of Tech as Component
* add a unit test to verify that registerTech works
* change defaultTech_ to defaultTechOrder_
2017-02-02 14:34:33 -05:00
Gary Katsevman
5bde16a1bc test(ie8): only run mute toggle tests in html5 env (#4003)
IE8 can't run the html5 tech and the mute toggle tests rely on a working
volume and mute functionality which tech faker does not have. Instead of
implementing it in tech faker, skip it on non-html5 environments.
2017-01-31 17:15:56 -05:00
Gary Katsevman
03529163b6 feat: Update MW to require a factory, add *-mw (#3969)
Middleware registration now only accept a factory method which takes a player reference and returns some object that represents the middleware with the various methods on it.
Also, add a use to register a middleware for all types.
2017-01-27 15:09:27 -05:00
Gary Katsevman
34aab3f357 feat: middleware (#3788)
Add middleware support. Middleware can function as go-between between the player and the tech. For example, it can modify the duration that the tech returns to the player. In addition, middleware allow for supporting custom video sources and types.

Currently, middleware can only intercept timeline methods like duration, currentTime, and setCurrentTime.

For example,
```js
videojs.use('video/foo', {
  setSource(src, next) {
    next(null, {
      src: 'http://example.com/video.mp4',
      type: 'video/mp4'
    });
  }
});
```
Will allow you to set a source with type `video/foo` which will play back `video.mp4`.

This makes setting the source asynchronous, which aligns it with the spec a bit more. Methods like play can still be called synchronously on the player after setting the source and the player will play once the source has loaded.

`sourceOrder` option was removed as well and it will now always use source ordering.

BREAKING CHANGE: setting the source is now asynchronous. `sourceOrder` option removed and made the default.
2017-01-19 17:29:09 -05:00
Brandon Casey
b387437aed feat: remove flash tech (#3956)
Remove Flash Tech from core. Use videojs-flash if flash is needed.
Also, update DOM method names.

BREAKING CHANGE: remove flash tech from core.
2017-01-19 16:01:56 -05:00
Brandon Casey
49bed07039 refactor: unify all Track and TrackList APIs (#3783)
Unify all track-related usage internally.

BREAKING CHANGE: some externally accessibly functions for tracks are now private.
2017-01-19 15:16:28 -05:00
Gary Katsevman
7bafcc2a55 test: fix tests (#3953)
* Switch to es3 preset for babel so that it runs last. Plugins run before presets and presets run in reverse order. Also, we ran into a weird bug in babel that causes `default` not to be quoted in some cases (https://github.com/babel/babel/issues/4799) which we've worked around here.
* Restore the es-shims for tests and the ie8 fallback script.
* Do a null-check around `Player.players`.
* use more round fractions (like 0.5 and 1) to avoid rounding issues.
2017-01-19 11:17:46 -05:00
Brandon Casey
2037e18235 feat(player): add played(), defaultMuted(), defaultPlaybackRate() (#3845)
Add `played()`, `defaultMuted()` and `defaultPlaybackRate()` methods to the player.

Fixes #523.
2017-01-18 14:59:15 -05:00
Brandon Casey
73b6316f3b refactor: remove special loadstart handling (#3906)
This is both a change as well as a bug fix. We tried to have better awareness of when the underlying video element changed underneath us so we can dispose of the source handler but that broke some use cases of MSE. Given that we weren't able to fix it in a reasonable non-breaking and non-invasive solution, we're taking it out.

BREAKING CHANGE: remove the double loadstart handlers that dispose the tech/source handlers if a secondary loadstart event is heard.
2017-01-18 00:38:31 -05:00
Gary Katsevman
a7ffa34b7b fix: remote text track deprecation warnings (#3864) 2016-12-15 15:48:19 -05:00
forbesjo
9b9f89e5b3 feat(tracks): Added option to disable native tracks (#3786)
This adds nativeAudioTracks and nativeVideoTracks tech options, this will disable hooking into the native track APIs. This would be useful when using videojs-contrib-hls on Edge.
2016-11-23 14:09:32 -05:00
Gary Katsevman
eb5e78bb88 revert: perf: Cache currentTime and buffered from Flash (#3705) (#3778)
This reverts commit 45ffa810fb.
2016-11-14 16:09:54 -05:00
Jon-Carlos Rivera
f05a9271b8 feat: option to have remoteTextTracks automatically 'garbage-collected' when sources change (#3736)
Tech#addRemoteTextTrack now accepts a second parameter - a boolean named manualCleanup which defaults to true preserving backwards compatibility. When that value is set to false the text track will be removed from the video element whenever a source change occurs.
2016-11-09 16:07:59 -05:00
David LaPalomento
45ffa810fb perf: Cache currentTime and buffered from Flash (#3705)
Calling into the SWF too often is expensive. Current time and buffered don't actually change that often but it's very common to call them a couple times in the handling of a single event. Cache their return values for 100ms so the performance penalty of going through ExternalInterface is limited.
2016-11-04 18:03:44 -04:00
Carey Hinoki
028559ccb0 feat: add ability to get current source object and all source objects (#2678)
Adds `currentSource` and `currentSources` methods to the player that return the current source object, containing `currentSrc()` and `currentType()`, and all source objects that were given to the player.

Fixes #2443
2016-11-03 15:50:55 -04:00
mister-ben
ed59531f78 fix: Suppress Infinity duration on Android Chrome before playback (#3476)
HTML5 tech will return NaN instead of Infinity if playback has not started. Fires a durationupdate event once the reported duration can be believed if the duration is still Infinity, so controls can update.

Fixes #3079.
2016-11-03 15:39:09 -04:00
Marco
dd2aff00a8 fix: disable HLS hack on Firefox for Android (#3586)
* Disable HLS hack on Firefox for Android

* Fix canPlayType patching tests

* Add test to ensure that canPlayType is not patched in Firefox for Android

* Fix assertion message in Firefox for Android test
2016-09-29 14:14:42 -04:00
Gary Katsevman
773b5ab1c1 Merge branch 'stable' 2016-08-15 18:20:47 -04:00
mister-ben
fa1c6430f4 @mister-ben silenced chrome's play() request was interrupted by pause() error. closes #3518 2016-08-15 17:49:52 -04:00
Pat O&#x27;Neill
72c44daaf3 @misteroneill updated tests to qunit 2.0. closes #3509 2016-08-12 13:51:31 -04:00
Brandon Casey
86068a5b45 @BrandonOCasey updates tests to pass linter 2016-08-05 11:37:12 -04:00
Vít Koumar
f36da276e3 @vit-koumar updated Flash tech to return Infinity from duration instead of -1. closes #3128 2016-07-18 14:10:57 -04:00
Gary Katsevman
b9e3e55384 Merge branch 'stable' 2016-05-27 18:28:40 -04:00
brandonocasey
fa8fc80b83 @BrandonOCasey fixed source handlers being disposed multiple times when a video is put into the video element directly. closes #3343 2016-05-27 18:12:47 -04:00
Gary Katsevman
b1e7bfd8f8 Merge branch 'stable' 2016-05-12 14:49:47 -04:00
Gary Katsevman
82d396a1fb @gkatsev nulled out currentSource_ in setSource. closes #3314 2016-05-12 14:43:10 -04:00
Nicky Gerritsen
68c4d248d9 @nickygerritsen Also pass tech options to canHandleSource. closes #3303 2016-05-11 09:08:17 +02:00
Greg Smith
249532ad45 @incompl clear currentSource_ after subsequent loadstarts. closes #3285 2016-05-02 18:54:34 -04:00
brandonocasey
2e2dbde4b4 @BrandonOCasey added audio and video track support. closes #3173 2016-04-22 14:31:12 -04:00
Nicky Gerritsen
f606f9df50 @nickygerritsen Pass tech options to source handlers. closes #3245 2016-04-13 20:28:09 +02:00
Gary Katsevman
e78e26b8a4 @gkatsev added a Player#reset method. Fixes #2852. closes #2880 2015-12-07 17:45:50 -05:00
Violeta Marculescu
c0d5f471bc @bcvio fixed returning current source rather than blob url. closes #2833 2015-11-23 12:04:31 -05:00