Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 42 additions & 16 deletions src/APIManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ module.exports = class APIManager {
'Enable or disable the tracking of analytic events. If disabled, all tracked events will be cleared.',
});

// Register a function to process tracked events
this.registerFunction({
name: 'trackEvents',
category: 'analytics',
fn: (cb) => {
// Subscribe to store's TRACKEVENT changes
this.instance.store.subscribe(
({trackedEvents}) => {
if (this.instance.store.state.trackedEvents.events.length) {
cb([...trackedEvents.events]);
// Flush the tracked events
this.instance.store.dispatch({type: 'FLUSH_TRACKED_EVENTS'});
}
},
['trackedEvents.events'],
);
},
description:
// eslint-disable-next-line max-len
'Invoke a callback function with an array of tracked events. This function is called whenever a new event is recorded.',
});
// Register open a widget
this.registerFunction({
name: 'openWidget',
Expand Down Expand Up @@ -94,27 +115,32 @@ module.exports = class APIManager {
},
description: 'Close the modal of a widget by specifying its constructor name.',
});
// Register a function to mute the video in the exposed API
this.registerFunction({
name: 'mute',
category: 'media',
fn: () => {
// Set the video to muted state
this.instance.video.isForceMuted = true; // Custom flag for muted status
this.instance.video.muted = true; // HTMLMediaElement property to mute audio
},
description:
// eslint-disable-next-line max-len
'Mute the video by setting the muted property to true. This function silences the audio of the current video instance.',
});

// Register a function to process tracked events
// Register a function to unmute the video in the exposed API
this.registerFunction({
name: 'trackEvents',
category: 'analytics',
fn: (cb) => {
// Subscribe to store's TRACKEVENT changes
this.instance.store.subscribe(
({trackedEvents}) => {
if (this.instance.store.state.trackedEvents.events.length) {
cb([...trackedEvents.events]);
// Flush the tracked events
this.instance.store.dispatch({type: 'FLUSH_TRACKED_EVENTS'});
}
},
['trackedEvents.events'],
);
name: 'unmute',
category: 'media',
fn: () => {
// Set the video to unmuted state
this.instance.video.isForceMuted = false; // Custom flag for muted status
this.instance.video.muted = false; // HTMLMediaElement property to unmute audio
},
description:
// eslint-disable-next-line max-len
'Invoke a callback function with an array of tracked events. This function is called whenever a new event is recorded.',
'Unmute the video by setting the muted property to false. This function restores the audio of the current video instance.',
});
}

Expand Down
28 changes: 0 additions & 28 deletions src/plugins/MediaManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,6 @@ module.exports = class MediaManager {
this.videoWidth = videoWidth;
this.videoHeight = videoHeight;
this.videoWithMicrophone = videoWithMicrophone;

// Register a function to mute the video in the exposed API
this.instance.apiManager.registerFunction({
name: 'mute',
category: 'media',
fn: () => {
// Set the video to muted state
this.instance.video.isMuted = true; // Custom flag for muted status
this.instance.video.muted = true; // HTMLMediaElement property to mute audio
},
description:
// eslint-disable-next-line max-len
'Mute the video by setting the muted property to true. This function silences the audio of the current video instance.',
});

// Register a function to unmute the video in the exposed API
this.instance.apiManager.registerFunction({
name: 'unmute',
category: 'media',
fn: () => {
// Set the video to unmuted state
this.instance.video.isMuted = false; // Custom flag for muted status
this.instance.video.muted = false; // HTMLMediaElement property to unmute audio
},
description:
// eslint-disable-next-line max-len
'Unmute the video by setting the muted property to false. This function restores the audio of the current video instance.',
});
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/MouseEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ module.exports = class MouseEvents {
onMousePressEvent(event) {
/**
* At launch the sound is muted until a click is performed on the <video>
* `this.instance.mediaManager.isMuted` is necessary to force the sound to be muted even if the user clicked on the video
* `this.instance.video.isForceMuted` is a flag set to true / false by apiManager
* if `this.instance.video.isForceMuted` is undefined then unmuted the video sound when user click onto video
*/
this.instance.video.muted = !this.instance.mediaManager.isMuted ? this.instance.video.muted : false;
// eslint-disable-next-line no-undefined
this.instance.video.muted = this.instance.video.isForceMuted === undefined ? false : this.instance.video.muted;
if (event.button !== 0) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/scss/base/_genymotion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@
max-height: 100%;
align-self: center;
height: 100%;
outline: none;
}
}
}
Expand Down