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

feat: add flash engine #2

Merged
merged 12 commits into from
Aug 2, 2018
19 changes: 15 additions & 4 deletions src/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class Flash extends FakeEventTarget implements IEngine {

_srcToLoad: ?string;

_muted: boolean;

/**
* The Flash class logger.
* @type {any}
Expand Down Expand Up @@ -127,6 +129,9 @@ class Flash extends FakeEventTarget implements IEngine {
this._init(source, config);
}

hideTextTrack(): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is in the flow typings - didn't it alert you on missing interface?


}
_init(source: PKMediaSourceObject, config: Object): void {
this._eventManager = new EventManager();

Expand Down Expand Up @@ -414,9 +419,13 @@ class Flash extends FakeEventTarget implements IEngine {
* @returns {void}
*/
set volume(vol: number): void {
this._volume = vol;
if (this._api) {
this._api.volume(vol);
if (this._muted) {
this._volumeBeforeMute = vol;
} else {
this._volume = vol;
if (this._api) {
this._api.volume(vol);
}
}
}

Expand Down Expand Up @@ -515,9 +524,11 @@ class Flash extends FakeEventTarget implements IEngine {
*/
set muted(mute: boolean): void {
if (mute) {
this._volumeBeforeMute = this.volume;
this.volume = 0;
this._muted = true;
this._volumeBeforeMute = this.volume;
} else {
this._muted = false;
if (this._volumeBeforeMute) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could be 0 so check typeof this._volumeBeforeMute === 'number'

this.volume = this._volumeBeforeMute;
} else {
Expand Down