-1

I have an audio file which it is in the .vox format and i want to convert that into the .mp3 format through java script i already got the code for the conversion but that code is in class file means that was in back end code,but i don't want that one through java script i want to convert the file.please help me.

  • You figure what your java code is doing, and you see if you can map that to javascript. But probably it is calling some **library** which wont work then. So you would look out for JS libraries that could do that for you. – GhostCat Nov 22 '16 at 12:57

3 Answers3

1

Naudio dll download (free) using NAudio using NAudio.Wave

        string convertedFileName = string.Format("{0}{1}", System.IO.Path.GetTempPath(), System.IO.Path.GetFileName(path).Replace(".vox", ".mp3"));

        using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
        {
            using (var reader = new RawSourceWaveStream(fileStream, Mp3WaveFormat.CreateALawFormat(8000, 1)))
            {
                using (WaveStream convertedStream = WaveFormatConversionStream.CreatePcmStream(reader))
                {
                    WaveFileWriter.CreateWaveFile(convertedFileName, convertedStream);
                }
            }
        }        

        return File(convertedFileName, System.Net.Mime.MediaTypeNames.Application.Octet, System.IO.Path.GetFileName(convertedFileName));
0

If you have your code already in Java Language and your classes defined, you could use http://jdk6.java.net/plugin2/liveconnect/ LiveConnect, as this post point out:

calling java methods in javascript code

as the post points out, this is an example:

Java code:

public class MethodInvocation extends Applet {
    public void noArgMethod() { ... }
    public void someMethod(String arg) { ... }
    public void someMethod(int arg) { ... }
    public int  methodReturningInt() { return 5; }
    public String methodReturningString() { return "Hello"; }
    public OtherClass methodReturningObject() { return new OtherClass(); }
}

public class OtherClass {
    public void anotherMethod();
}

Web page and JavaScript code:

<applet id="app"
    archive="examples.jar"
    code="MethodInvocation" ...>
</applet>
<script language="javascript">
 app.noArgMethod();
 app.someMethod("Hello");
 app.someMethod(5);
 var five = app.methodReturningInt();
 var hello = app.methodReturningString();
 app.methodReturningObject().anotherMethod();
</script>

Hope it helps :)

Community
  • 1
  • 1
0

Naudio dll download (free) using NAudio; using NAudio.Wave;

string convertedFileName = string.Format("{0}{1}", System.IO.Path.GetTempPath(), System.IO.Path.GetFileName(path).Replace(".vox", ".mp3"));

        using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
        {
            using (var reader = new RawSourceWaveStream(fileStream, Mp3WaveFormat.CreateALawFormat(8000, 1)))
            {
                using (WaveStream convertedStream = WaveFormatConversionStream.CreatePcmStream(reader))
                {
                    WaveFileWriter.CreateWaveFile(convertedFileName, convertedStream);
                }
            }
        }         

        return File(convertedFileName, System.Net.Mime.MediaTypeNames.Application.Octet, System.IO.Path.GetFileName(convertedFileName));