PageRenderTime 41ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/src/main/scala/dk/mehmedbasic/audiobook/execution/ConversionCommandFactory.scala

https://bitbucket.org/mehmedbasic/scalaudiobookconverter
Scala | 37 lines | 23 code | 8 blank | 6 comment | 0 complexity | d9569912494afa27b3b78be77060637e MD5 | raw file
  1. package dk.mehmedbasic.audiobook.execution
  2. import dk.mehmedbasic.audiobook.conversion.AudioConfig
  3. import java.io.File
  4. /**
  5. * Command factory creates commands based on OS.
  6. *
  7. * @author Jesenko Mehmedbasic
  8. * created 20-01-13, 00:16
  9. */
  10. class ConversionCommandFactory(
  11. system: OperatingSystem,
  12. inputFile: File,
  13. outputConfig: AudioConfig) extends CommandFactory(system) {
  14. val outputFile = File.createTempFile(System.nanoTime() + "", ".mp4")
  15. def getOutput = outputFile
  16. protected override def addParametersToCommand(command: Command) {
  17. command.addParameter("P", null)
  18. command.addParameter("C", outputConfig.channels)
  19. command.addParameter("R", outputConfig.sampleFrequency)
  20. command.addParameter("o", "\"" + outputFile.getAbsolutePath + "\"")
  21. command.addParameter("", null)
  22. }
  23. protected override def createWindowsCommand(): Command = {
  24. new Command("\"" + new File(".").getAbsolutePath + "\\external\\faac.exe\"")
  25. }
  26. protected override def createUnixCommand(): Command = {
  27. new Command("faac")
  28. }
  29. }