Quick hack using ffmpeg to fix linux builds

This commit is contained in:
CreepyCrafter24 2020-03-30 16:05:25 +02:00
parent 0932b0d0d0
commit dc5a17bc56
2 changed files with 12 additions and 5 deletions

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using Bassoon;
@ -29,12 +30,17 @@ namespace testexetrisathlon.SoundManagement
foreach ((string name, string key) in manifestResources)
{
string file = Path.GetTempFileName();
File.Move(file, Path.ChangeExtension(file, "wav"));
File.Move(file, Path.ChangeExtension(file, "mp3"));
file = Path.ChangeExtension(file, "mp3");
using (Stream resource = Assembly.GetManifestResourceStream(key))
{
using FileStream fileStream = File.Create(file);
resource.Seek(0, SeekOrigin.Begin);
resource.CopyTo(fileStream);
}
Process.Start(new ProcessStartInfo{FileName = "ffmpeg", Arguments = $"-i {file} {Path.ChangeExtension(file, "wav")}", WorkingDirectory = Path.GetTempPath()}).WaitForExit();
File.Delete(file);
file = Path.ChangeExtension(file, "wav");
using Stream resource = Assembly.GetManifestResourceStream(key);
using FileStream fileStream = File.Create(file);
resource.Seek(0, SeekOrigin.Begin);
resource.CopyTo(fileStream);
_files.Add(name, file);
_loadedSounds.Add(name, new Sound(file));
}

View File

@ -26,6 +26,7 @@
<Content Include="tetris_yUxH6t_256px.ico" />
<Compile Remove="SoundManagement/LinuxSoundManager.cs" Condition="'$(OS)' == 'Windows_NT'" />
<Compile Remove="SoundManagement/WindowsSoundManager.cs" Condition="'$(OS)' != 'Windows_NT'" />
<Compile Remove="SoundManagement/LoopStream.cs" Condition="'$(OS)' != 'Windows_NT'" />
<Compile Remove="SoundManagement/LinuxBeeper.cs" Condition="'$(OS)' == 'Windows_NT'" />
<Compile Remove="SoundManagement/WindowsBeeper.cs" Condition="'$(OS)' != 'Windows_NT'" />
<Compile Remove="LinuxSizeSetter.cs" Condition="'$(OS)' == 'Windows_NT'" />