/// <summary> /// Compares timestamps on .wav files and .mp3 files to see if we need to update any .mp3 files. /// Be aware that if you are staging audio files in preparation for publishing, the bookFolderPath /// should be the original book folder files, not the staged files. Otherwise you may get unexpected /// results. (See BL-5437) /// </summary> public static bool IsAnyCompressedAudioMissing(string bookFolderPath, XmlDocument dom) { if (!LameEncoder.IsAvailable()) { return(true); } return(!GetTrueForAllAudioSpans(bookFolderPath, dom, (wavpath, mp3path) => !Mp3IsNeeded(wavpath, mp3path))); }
/// <summary> /// Make a compressed audio file for the specified .wav file. /// </summary> public static string MakeCompressedAudio(string wavPath) { // We have a recording, but not compressed. Possibly the LAME package was installed after // the recordings were made. Compress it now. if (s_mp3Encoder == null) { s_mp3Encoder = new LameEncoder(); } return(s_mp3Encoder.Encode(wavPath)); }
/// <summary> /// Make a compressed audio file for the specified .wav file. /// (Or return null if it can't be done because we don't have a LAME package installed.) /// </summary> /// <param name="id"></param> /// <returns></returns> // internal and virtual for testing. private static string MakeCompressedAudio(string wavPath) { // We have a recording, but not compressed. Possibly the LAME package was installed after // the recordings were made. Compress it now. if (_mp3Encoder == null) { if (!LameEncoder.IsAvailable()) { return(null); } _mp3Encoder = new LameEncoder(); } _mp3Encoder.Encode(wavPath, wavPath.Substring(0, wavPath.Length - 4), new NullProgress()); return(Path.ChangeExtension(wavPath, "mp3")); }