This is a brief overview of the methods and variables contained in the Javascript files used to run the extension.
- Webcam.js
- Yt_controls.js
- Popup.js
Contains functions to Setup the webcam as well as to handle the resulting MediaStream and MediaRecorder Object.
Injected into Youtube page upon clicking on extension icon.
Creates new html video element w/ custom styles applied.
Creates new video element w/ webcam as srcObject and appends it to youtube video container element.
The purpose of this script is to setup the webcam and handle the resulting MediaStream and MediaRecorder Object.
Handle Youtube video Play
- Grabs play/pause button from dom
- If title matches play condition sends(fires?) click event
Handle Youtube video Pause
- Grabs play/pause button from dom
- If title matches pause condition sends(fires?) click event
Handle Youtube video Restart
Responsible for handling control over extension and it currently controls:
- Setting up and Recording Webcam video
- Backend for popup.html
Add custom function as click event to an html element
let addCustomEventListener = (html_element, custom_event_func) => {
html_element.addEventListener("click", (e) => {
custom_event_func && custom_event_func(); // if no custom function is provided doesnt run it
});
};
Setup Popup Tab Functionality
function setupTabs() {
// Do Stuff ...
}
Setup Webcam Preview in popup window
Filters for supported mimtypes
Grabs current active tab from window
Handle clicking of start recording button
- Set MimeType Option
- Try to create new media recorder using media stream
- [debug] show result
- Update record button text
- Update other buttons/inputs
- Set on stop event
- When data is available start recording
if the data exist and it has a size > than 0 append it to the recoeded blobs array
Stops the MediaRecorder, then updates record, play and download buttons, updates codecPreferences
Toggle between running startRecording() and stopRecording() based off of recordButton text content (textContent)
MAYBE injects start up webcam function/script into youtube page
MAYBE runs a setup webcam function that allows for it to play in the popup Also sends a message or function to play/pause/restart the youtube video
Convert recorded Blobs array into a new Blob object and then add it as a src to recordedVideo and start playing.
Downloads recordedBlobs