Added #1917 Better error message for sound import on unsupported sampling rate

This commit is contained in:
Jindra Petřík
2022-12-25 11:40:25 +01:00
parent 87f4baf554
commit 1bdc9d5218
9 changed files with 113 additions and 5 deletions

View File

@@ -171,6 +171,7 @@ import com.jpexs.decompiler.flash.tags.base.SoundTag;
import com.jpexs.decompiler.flash.tags.base.SymbolClassTypeTag;
import com.jpexs.decompiler.flash.tags.base.TextImportErrorHandler;
import com.jpexs.decompiler.flash.tags.base.TextTag;
import com.jpexs.decompiler.flash.tags.base.UnsupportedSamplingRateException;
import com.jpexs.decompiler.flash.tags.gfx.DefineExternalImage2;
import com.jpexs.decompiler.flash.tags.gfx.DefineSubImage;
import com.jpexs.decompiler.flash.tags.text.TextParseException;
@@ -4002,6 +4003,14 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
ds.getSwf().clearSoundCache();
} catch (IOException ex) {
//ignore
} catch (UnsupportedSamplingRateException ex) {
String samplingRateKhz = "" + (ex.getSoundRate() / 1000.0) + " kHz";
List<String> supportedRatesKhz = new ArrayList<>();
for (int rate:ex.getSupportedRates()) {
supportedRatesKhz.add("" + (rate / 1000.0) + " kHz");
}
ViewMessages.showMessageDialog(this, translate("error.sound.rate").replace("%saplingRate%", samplingRateKhz).replace("%supportedRates%", String.join(", ", supportedRatesKhz)), translate("error"), JOptionPane.ERROR_MESSAGE);
return;
}
if (!ok) {