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

Audio Recorder added #480

Merged
Merged
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
14 changes: 14 additions & 0 deletions Audio_Recorder/encoders/Mp3Encoder.min.js

Large diffs are not rendered by default.

Binary file added Audio_Recorder/encoders/Mp3Encoder.min.js.mem
Binary file not shown.
1 change: 1 addition & 0 deletions Audio_Recorder/encoders/WavEncoder.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

157 changes: 157 additions & 0 deletions Audio_Recorder/html/complete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<html>
<head>
<title>Chrome Audio Capture Options</title>


</head>
<style>
.header {
display: flex;
align-items: center;
padding-bottom: 15px;
padding-left: 20px;
border-bottom: 2px solid darkred;
}

.header-title {
padding: 0 5px;
}

.progress {
margin: 50px 20px 10px 20px;
font-size: 16px;
display: flex;
}

.notes {
margin: 0 20px;
}

#progressContainer {
margin-left: 5px;
width: 500px;
height: 18px;
background-color: lavenderblush;
}

#encodeProgress {
height: 100%;
width: 0%;
background-color: darkred;
}

#saveCapture {
display: none;
}

.buttonContainer {
display: flex;
}

#status {
margin-top: 30px;
margin-left: 20px;
font-size: 14px;
}

.button {
padding: 10px;
border: 2px solid darkred;
font-size: 16px;
background-color: lavenderblush;
font-weight: bold;
margin: 10px 20px;
cursor: pointer;
border-radius: 5px;
}

.button:hover {
color: red;
background-color: darkred;
}

#review {
color: blue;
display: inline;
text-decoration: underline;
cursor: pointer;
}

</style>
<body>
<div class="header"><img src="./icon.png"/> <h1 class="header-title">Chrome Audio Capture</h1></div>
<div class="inner">
<div class="progress">
<label for="progrssContainer">Encoding Progress:</label>
<div id="progressContainer">
<div id="encodeProgress"></div>
</div>
</div>
<p id="status"></p>
</div>
<div class="buttonContainer">
<div class="button" id="saveCapture">Save Capture</div>
<div class="button" id="close">Close</div>
</div>
<div class="notes">Thank you for using the extension! Please go <div id="review">here</div> to leave a review!</div>
</body>
<script>
document.addEventListener('DOMContentLoaded', () => {
const encodeProgress = document.getElementById('encodeProgress');
const saveButton = document.getElementById('saveCapture');
const closeButton = document.getElementById('close');
const review = document.getElementById('review');
const status = document.getElementById('status');
let format;
let audioURL;
let encoding = false;
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if(request.type === "createTab") {
format = request.format;
let startID = request.startID;
status.innerHTML = "Please wait..."
closeButton.onclick = () => {
chrome.runtime.sendMessage({cancelEncodeID: startID});
chrome.tabs.getCurrent((tab) => {
chrome.tabs.remove(tab.id);
});
}

//if the encoding completed before the page has loaded
if(request.audioURL) {
encodeProgress.style.width = '100%';
status.innerHTML = "File is ready!"
generateSave(request.audioURL);
} else {
encoding = true;
}
}

//when encoding completes
if(request.type === "encodingComplete" && encoding) {
encoding = false;
status.innerHTML = "File is ready!";
encodeProgress.style.width = '100%';
generateSave(request.audioURL);
}
//updates encoding process bar upon messages
if(request.type === "encodingProgress" && encoding) {
encodeProgress.style.width = `${request.progress * 100}%`;
}
function generateSave(url) { //creates the save button
const currentDate = new Date(Date.now()).toDateString();
saveButton.onclick = () => {
chrome.downloads.download({url: url, filename: `${currentDate}.${format}`, saveAs: true});
};
saveButton.style.display = "inline-block";
}
});
review.onclick = () => {
chrome.tabs.create({url: "https://chrome.google.com/webstore/detail/chrome-audio-capture/kfokdmfpdnokpmpbjhjbcabgligoelgp/reviews"});
}


})

</script>
</html>
40 changes: 40 additions & 0 deletions Audio_Recorder/html/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<html>
<head>
<title>Chrome Audio Capture Options</title>
<link rel="stylesheet" href="error.css" type="text/css">
</head>
<style>
.header {
display: flex;
align-items: center;
padding-bottom: 15px;
border-bottom: 2px solid darkred;
}

h1 {
font-size: 36px;
}

img {
height: 64px;
margin: 0 20px 0 0;
}

h2 {
font-size: 26px;
}

.inner {
text-align: center;
}

</style>
<body>
<div class="header"><img src="./icon.png"/> <h1>Chrome Audio Capture</h1></div>
<div class="inner">
<h2>Sorry, capture on YouTube is disabled!</h2>
<p>Chrome Web Store does not allow extensions to capture audio from YouTube due to copyright reasons.</p>
<p>Sorry for the inconvenience, please use the extension on other websites.</p>
</div>
</body>
</html>
Loading
Loading