mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-18 23:34:08 +02:00
Re-add mp3 support in sound notifications
This commit is contained in:
parent
5c0aa1b3da
commit
01583e424f
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
namespace TweetDuck.Core.Notification{
|
namespace TweetDuck.Core.Notification{
|
||||||
static class SoundNotification{
|
static class SoundNotification{
|
||||||
public const string SupportedFormats = "*.wav;*.ogg;*.flac;*.opus;*.weba;*.webm"; // TODO add mp3 when supported
|
public const string SupportedFormats = "*.wav;*.ogg;*.mp3;*.flac;*.opus;*.weba;*.webm";
|
||||||
|
|
||||||
public static IResourceHandler CreateFileHandler(string path){
|
public static IResourceHandler CreateFileHandler(string path){
|
||||||
string mimeType;
|
string mimeType;
|
||||||
@ -18,36 +18,33 @@ public static IResourceHandler CreateFileHandler(string path){
|
|||||||
case ".webm": mimeType = "audio/webm"; break;
|
case ".webm": mimeType = "audio/webm"; break;
|
||||||
case ".wav": mimeType = "audio/wav"; break;
|
case ".wav": mimeType = "audio/wav"; break;
|
||||||
case ".ogg": mimeType = "audio/ogg"; break;
|
case ".ogg": mimeType = "audio/ogg"; break;
|
||||||
|
case ".mp3": mimeType = "audio/mp3"; break;
|
||||||
case ".flac": mimeType = "audio/flac"; break;
|
case ".flac": mimeType = "audio/flac"; break;
|
||||||
case ".opus": mimeType = "audio/ogg; codecs=opus"; break;
|
case ".opus": mimeType = "audio/ogg; codecs=opus"; break;
|
||||||
case ".mp3": TryShowError("MP3 sound notifications are temporarily unsupported, please convert the file to another format, such as .ogg, .wav, or .flac."); return null;
|
|
||||||
default: mimeType = null; break;
|
default: mimeType = null; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
return ResourceHandler.FromFilePath(path, mimeType);
|
return ResourceHandler.FromFilePath(path, mimeType);
|
||||||
}catch{
|
}catch{
|
||||||
TryShowError("Could not find custom notification sound file:\n"+path);
|
FormBrowser browser = FormManager.TryFind<FormBrowser>();
|
||||||
|
|
||||||
|
browser?.InvokeAsyncSafe(() => {
|
||||||
|
using(FormMessage form = new FormMessage("Sound Notification Error", "Could not find custom notification sound file:\n"+path, MessageBoxIcon.Error)){
|
||||||
|
form.AddButton(FormMessage.Ignore, ControlType.Cancel | ControlType.Focused);
|
||||||
|
|
||||||
|
Button btnViewOptions = form.AddButton("View Options");
|
||||||
|
btnViewOptions.Width += 16;
|
||||||
|
btnViewOptions.Location = new Point(btnViewOptions.Location.X-16, btnViewOptions.Location.Y);
|
||||||
|
|
||||||
|
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnViewOptions){
|
||||||
|
browser.OpenSettings(typeof(TabSettingsSounds));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void TryShowError(string message){
|
|
||||||
FormBrowser browser = FormManager.TryFind<FormBrowser>();
|
|
||||||
|
|
||||||
browser?.InvokeAsyncSafe(() => {
|
|
||||||
using(FormMessage form = new FormMessage("Sound Notification Error", message, MessageBoxIcon.Error)){
|
|
||||||
form.AddButton(FormMessage.Ignore, ControlType.Cancel | ControlType.Focused);
|
|
||||||
|
|
||||||
Button btnViewOptions = form.AddButton("View Options");
|
|
||||||
btnViewOptions.Width += 16;
|
|
||||||
btnViewOptions.Location = new Point(btnViewOptions.Location.X-16, btnViewOptions.Location.Y);
|
|
||||||
|
|
||||||
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnViewOptions){
|
|
||||||
browser.OpenSettings(typeof(TabSettingsSounds));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user