@@ -15,12 +15,13 @@ import * as Dom from './utils/dom.js';
15
15
import * as Fn from './utils/fn.js' ;
16
16
import * as Guid from './utils/guid.js' ;
17
17
import * as browser from './utils/browser.js' ;
18
+ import { IE_VERSION } from './utils/browser.js' ;
18
19
import log , { createLogger } from './utils/log.js' ;
19
20
import toTitleCase , { titleCaseEquals } from './utils/to-title-case.js' ;
20
21
import { createTimeRange } from './utils/time-ranges.js' ;
21
22
import { bufferedPercent } from './utils/buffer.js' ;
22
23
import * as stylesheet from './utils/stylesheet.js' ;
23
- import FullscreenApi from './fullscreen-api.js' ;
24
+ import FullscreenApi , { prefixedAPI as prefixedFS } from './fullscreen-api.js' ;
24
25
import MediaError from './media-error.js' ;
25
26
import safeParseTuple from 'safe-json-parse/tuple' ;
26
27
import { assign } from './utils/obj' ;
@@ -33,7 +34,6 @@ import * as middleware from './tech/middleware.js';
33
34
import { ALL as TRACK_TYPES } from './tracks/track-types' ;
34
35
import filterSource from './utils/filter-source' ;
35
36
import { getMimetype , findMimetype } from './utils/mimetypes' ;
36
- import { IE_VERSION } from './utils/browser' ;
37
37
38
38
// The following imports are used only to ensure that the corresponding modules
39
39
// are always included in the video.js package. Importing the modules will
@@ -519,7 +519,15 @@ class Player extends Component {
519
519
this . reportUserActivity ( ) ;
520
520
521
521
this . one ( 'play' , this . listenForUserActivity_ ) ;
522
- this . on ( 'fullscreenchange' , this . handleFullscreenChange_ ) ;
522
+
523
+ if ( FullscreenApi . fullscreenchange ) {
524
+ this . on ( FullscreenApi . fullscreenchange , this . handleFullscreenChange_ ) ;
525
+
526
+ if ( IE_VERSION || browser . IS_FIREFOX && prefixedFS ) {
527
+ this . on ( document , FullscreenApi . fullscreenchange , this . handleFullscreenChange_ ) ;
528
+ }
529
+ }
530
+
523
531
this . on ( 'stageclick' , this . handleStageClick_ ) ;
524
532
525
533
this . breakpoints ( this . options_ . breakpoints ) ;
@@ -549,6 +557,11 @@ class Player extends Component {
549
557
// prevent dispose from being called twice
550
558
this . off ( 'dispose' ) ;
551
559
560
+ // make sure to remove fs handler on IE from the document
561
+ if ( IE_VERSION || browser . IS_FIREFOX && prefixedFS ) {
562
+ this . off ( document , FullscreenApi . fullscreenchange , this . handleFullscreenChange_ ) ;
563
+ }
564
+
552
565
if ( this . styleEl_ && this . styleEl_ . parentNode ) {
553
566
this . styleEl_ . parentNode . removeChild ( this . styleEl_ ) ;
554
567
this . styleEl_ = null ;
@@ -1908,29 +1921,60 @@ class Player extends Component {
1908
1921
event . preventDefault ( ) ;
1909
1922
}
1910
1923
1924
+ /**
1925
+ * native click events on the SWF aren't triggered on IE11, Win8.1RT
1926
+ * use stageclick events triggered from inside the SWF instead
1927
+ *
1928
+ * @private
1929
+ * @listens stageclick
1930
+ */
1931
+ handleStageClick_ ( ) {
1932
+ this . reportUserActivity ( ) ;
1933
+ }
1934
+
1911
1935
/**
1912
1936
* Fired when the player switches in or out of fullscreen mode
1913
1937
*
1914
1938
* @private
1915
1939
* @listens Player#fullscreenchange
1940
+ * @listens Player#webkitfullscreenchange
1941
+ * @listens Player#mozfullscreenchange
1942
+ * @listens Player#MSFullscreenChange
1943
+ * @fires Player#fullscreenchange
1916
1944
*/
1917
- handleFullscreenChange_ ( ) {
1945
+ handleFullscreenChange_ ( event = { } , retriggerEvent = true ) {
1918
1946
if ( this . isFullscreen ( ) ) {
1919
1947
this . addClass ( 'vjs-fullscreen' ) ;
1920
1948
} else {
1921
1949
this . removeClass ( 'vjs-fullscreen' ) ;
1922
1950
}
1951
+
1952
+ if ( prefixedFS && retriggerEvent ) {
1953
+ /**
1954
+ * @event Player#fullscreenchange
1955
+ * @type {EventTarget~Event }
1956
+ */
1957
+ this . trigger ( 'fullscreenchange' ) ;
1958
+ }
1923
1959
}
1924
1960
1925
1961
/**
1926
- * native click events on the SWF aren't triggered on IE11, Win8.1RT
1927
- * use stageclick events triggered from inside the SWF instead
1928
- *
1929
- * @private
1930
- * @listens stageclick
1962
+ * when the document fschange event triggers it calls this
1931
1963
*/
1932
- handleStageClick_ ( ) {
1933
- this . reportUserActivity ( ) ;
1964
+ documentFullscreenChange_ ( e ) {
1965
+ const fsApi = FullscreenApi ;
1966
+
1967
+ this . isFullscreen ( document [ fsApi . fullscreenElement ] ) ;
1968
+
1969
+ // If cancelling fullscreen, remove event listener.
1970
+ if ( this . isFullscreen ( ) === false ) {
1971
+ Events . off ( document , fsApi . fullscreenchange , Fn . bind ( this , this . documentFullscreenChange_ ) ) ;
1972
+ if ( prefixedFS ) {
1973
+ this . handleFullscreenChange_ ( { } , false ) ;
1974
+ } else {
1975
+ this . on ( FullscreenApi . fullscreenchange , this . handleFullscreenChange_ ) ;
1976
+ }
1977
+ }
1934
1978
}
1935
1979
1936
1980
/**
@@ -2568,24 +2612,16 @@ class Player extends Component {
2568
2612
// the browser supports going fullscreen at the element level so we can
2569
2613
// take the controls fullscreen as well as the video
2570
2614
2615
+ if ( ! prefixedFS ) {
2616
+ this . off ( FullscreenApi . fullscreenchange , this . handleFullscreenChange_ ) ;
2617
+ }
2618
+
2571
2619
// Trigger fullscreenchange event after change
2572
2620
// We have to specifically add this each time, and remove
2573
2621
// when canceling fullscreen. Otherwise if there's multiple
2574
2622
// players on a page, they would all be reacting to the same fullscreen
2575
2623
// events
2576
- Events . on ( document , fsApi . fullscreenchange , Fn . bind ( this , function documentFullscreenChange ( e ) {
2577
- this . isFullscreen ( document [ fsApi . fullscreenElement ] ) ;
2578
-
2579
- // If cancelling fullscreen, remove event listener.
2580
- if ( this . isFullscreen ( ) === false ) {
2581
- Events . off ( document , fsApi . fullscreenchange , documentFullscreenChange ) ;
2582
- }
2583
- /**
2584
- * @event Player#fullscreenchange
2585
- * @type {EventTarget~Event }
2586
- */
2587
- this . trigger ( 'fullscreenchange' ) ;
2588
- } ) ) ;
2624
+ Events . on ( document , fsApi . fullscreenchange , Fn . bind ( this , this . documentFullscreenChange_ ) ) ;
2589
2625
2590
2626
this . el_ [ fsApi . requestFullscreen ] ( ) ;
2591
2627
@@ -2617,6 +2653,8 @@ class Player extends Component {
2617
2653
2618
2654
// Check for browser element fullscreen support
2619
2655
if ( fsApi . requestFullscreen ) {
2656
+ // remove the document level handler if we're getting called directly.
2657
+ Events . off ( document , fsApi . fullscreenchange , Fn . bind ( this , this . documentFullscreenChange_ ) ) ;
2620
2658
document [ fsApi . exitFullscreen ] ( ) ;
2621
2659
} else if ( this . tech_ . supportsFullScreen ( ) ) {
2622
2660
this . techCall_ ( 'exitFullScreen' ) ;
0 commit comments