Skip to content

Commit

Permalink
feat: connect the fullscreen to the player (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Ziv committed Oct 31, 2017
1 parent 2b8e74d commit 5860548
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/components/fullscreen/fullscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {connect} from 'preact-redux';
import {bindActions} from '../../utils/bind-actions';
import {actions} from '../../reducers/fullscreen';
import BaseComponent from '../base';
import { default as Icon, IconType } from '../icon';
import {default as Icon, IconType} from '../icon';

/**
* mapping state to props
Expand All @@ -19,13 +19,13 @@ const mapStateToProps = state => ({
});

@connect(mapStateToProps, bindActions(actions))
/**
* FullscreenControl component
*
* @class FullscreenControl
* @example <FullscreenControl player={this.player} />
* @extends {BaseComponent}
*/
/**
* FullscreenControl component
*
* @class FullscreenControl
* @example <FullscreenControl player={this.player} />
* @extends {BaseComponent}
*/
class FullscreenControl extends BaseComponent {

/**
Expand All @@ -48,7 +48,8 @@ class FullscreenControl extends BaseComponent {
document.addEventListener('mozfullscreenchange', () => this.fullscreenChangeHandler());
document.addEventListener('fullscreenchange', () => this.fullscreenChangeHandler());
document.addEventListener('MSFullscreenChange', () => this.fullscreenChangeHandler());

this.player.addEventListener(this.player.Event.REQUESTED_ENTER_FULLSCREEN, () => this.enterFullscreen());
this.player.addEventListener(this.player.Event.REQUESTED_EXIT_FULLSCREEN, () => this.exitFullscreen());
}

/**
Expand Down Expand Up @@ -101,14 +102,14 @@ class FullscreenControl extends BaseComponent {
enterFullscreen(): void {
if (this.props.isMobile && this.player.env.os.name === 'iOS') {
this.player.getView().getElementsByTagName('video')[0].webkitEnterFullscreen();
}
else {
} else {
let elementToFullscreen = document.getElementById(this.config.targetId);

if (elementToFullscreen) {
this.requestFullscreen(elementToFullscreen);
}
}
this.player.notifyEnterFullscreen();
}

/**
Expand All @@ -127,6 +128,7 @@ class FullscreenControl extends BaseComponent {
} else if (typeof document.msExitFullscreen === 'function') {
document.msExitFullscreen();
}
this.player.notifyExitFullscreen();
}

/**
Expand All @@ -153,8 +155,8 @@ class FullscreenControl extends BaseComponent {
<button aria-label={<Text id='controls.fullscreen'/>}
className={this.props.fullscreen ? [style.controlButton, style.isFullscreen].join(' ') : style.controlButton}
onClick={() => this.toggleFullscreen()}>
<Icon type={IconType.Maximize} />
<Icon type={IconType.Minimize} />
<Icon type={IconType.Maximize}/>
<Icon type={IconType.Minimize}/>
</button>
</Localizer>
</div>
Expand Down

0 comments on commit 5860548

Please sign in to comment.