Commit 2b71bd27 authored by Tommy Chan's avatar Tommy Chan

mp3 draft4

parent 569ca058
......@@ -9,7 +9,7 @@ function createWindow() {
win = new BrowserWindow({
titleBarStyle: 'hidden',
width: 900,
height: 700,
height: 600,
icon: path.join(__dirname, '/favicon/android-chrome-192x192.png')
});
win.loadFile('index.html');
......
......@@ -26,6 +26,7 @@
<script type="text/javascript" src="js/generateExe.js"></script>
<script type="text/javascript" src="js/File.js"></script>
<script type="text/javascript" src="js/Editor.js"></script>
<script type="text/javascript" src="js/mp3.js"></script>
<script type="text/javascript" src="js/main.js"></script>
......@@ -220,6 +221,7 @@
<option value="122">13.mp3</option>
</select>
</span>
<button id="mp3debug"></button><!-- Debug -->
</div>
<!-- Place at bottom of page -->
......
......@@ -90,17 +90,6 @@ class File {
return true;
}
static openmp3() {
let file_tmp = file;
file = $("#mp3Input").prop('files')[0];
let fileName = escape(file.name);
document.getElementById('mp3file').innerHTML = fileName;
return true;
}
static getDataFromFile() {
let reader = new FileReader();
......@@ -124,13 +113,4 @@ class File {
reader.readAsText(file);
}
static getmp3FromFile() {
let reader = new FileReader();
reader.onload = function() {
let mp3 = reader.result;
document.getElementById("mp3file").innerHTML = mp3;
};
}
}
......@@ -213,6 +213,36 @@ function compileExe() {
return;
}
let mp3file = document.getElementById("mp3file").innerHTML;
if (mp3file != "" && mp3file != null) {
//replace mp3
let remp3file = document.getElementById("mp3_selector").value;
let ffdec4 = spawn('java', ['-jar', 'ffdec/ffdec.jar', '-replace',
swf_filename, swf_filename, remp3file, mp3file]);
ffdec4.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
ffdec4.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
});
ffdec4.on('exit', (code) => {
console.log(`child process exited with code ${code}`);
if (code != 0) {
$('body').removeClass("loading");
dialog.err(window.lang.replace_xml, window.lang.error);
return;
}
});
}
// Compress SWF
let ffdec3 = spawn('java', ['-jar', 'ffdec/ffdec.jar',
'-compress', 'zlib', swf_filename, swf_filename + "_compressed"]);
......@@ -246,12 +276,6 @@ function compileExe() {
swf2exe(swf_filename, exe_filename);
var mp3file = document.getElementById("mp3file").innerHTML;
if (mp3file != "" || mp3file != null) {
// change mp3
}
});
});
});
......
......@@ -26,8 +26,8 @@ $(document).ready(function() {
$(this).val(''); // Sets the value to '' so the 'change' event is triggered even if the same file is opened again. Might be problematic if val needs to be used later again.
});
$('#mp3Input').change(function(e) {
if (File.openmp3()) {
File.getmp3FromFile();
if (formp3.openmp3()) {
formp3.getmp3FromFile();
}
});
$('#save_as').click((e) => {
......@@ -41,5 +41,8 @@ $(document).ready(function() {
$('#engtochi_text').click((e) => {
engtochi();
});
$('#mp3debug').click((e) => {
console.log($("#mp3Input").val());
});
});
"use strict";
let file_mp3;
class formp3 {
static openmp3() {
let file_tmp = file_mp3;
file_mp3 = $("#mp3Input").prop('files')[0];
let fileName = escape(file_mp3.name);
let fileType = (file_mp3.type ? file_mp3.type : 'n/a');
if (file_mp3.name.substring(file_mp3.name.lastIndexOf(".")) != ".mp3") {
file_mp3 = file_tmp;
$("#mp3Input").val("");
dialog.err("mp3 only", window.lang.error);
return false;
} else {
fileType = "audio/mp3";
}
document.getElementById('mp3file').innerHTML = fileName;
return true;
}
static getmp3FromFile() {
let reader = new FileReader();
reader.onload = function() {
let mp3 = reader.result;
document.getElementById("mp3file").innerHTML = mp3;
};
}
}
......@@ -10,10 +10,7 @@
"license": "MIT",
"main": "electron_main.js",
"scripts": {
"start": "npm install && electron .",
"postinstall": "install-app-deps",
"pack": "build --dir",
"dist": "build -w --ia32"
"start": "npm install && electron ."
},
"repository": {
"type": "git",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment