From 465b65047534d5f85f92c8ab271058a163fd13a0 Mon Sep 17 00:00:00 2001 From: Nobuaki Tanaka Date: Sun, 8 Sep 2024 12:29:15 +0900 Subject: [PATCH] Update examples. --- Examples/FNA.NET/Game1.cs | 16 ++++++++----- Examples/MonoGame/Game1.cs | 16 ++++++++----- Examples/Silk.NET.OpenAL/AudioStream.cs | 2 +- Examples/build_all.bat | 32 ++++++++++++------------- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/Examples/FNA.NET/Game1.cs b/Examples/FNA.NET/Game1.cs index 18339ad..59e7b6a 100644 --- a/Examples/FNA.NET/Game1.cs +++ b/Examples/FNA.NET/Game1.cs @@ -7,8 +7,8 @@ public class Game1 : Game { private GraphicsDeviceManager graphics; - private MidiPlayer midiPlayer; - private MidiFile midiFile; + private MidiFile? midiFile; + private MidiPlayer? midiPlayer; public Game1() { @@ -17,20 +17,24 @@ public Game1() protected override void LoadContent() { - midiPlayer = new MidiPlayer("TimGM6mb.sf2"); midiFile = new MidiFile(@"C:\Windows\Media\flourish.mid"); + midiPlayer = new MidiPlayer("TimGM6mb.sf2"); } protected override void UnloadContent() { - midiPlayer.Dispose(); + if (midiPlayer != null) + { + midiPlayer.Dispose(); + midiPlayer = null; + } } protected override void Update(GameTime gameTime) { - if (midiPlayer.State == SoundState.Stopped) + if (midiPlayer!.State == SoundState.Stopped) { - midiPlayer.Play(midiFile, true); + midiPlayer.Play(midiFile!, true); } base.Update(gameTime); diff --git a/Examples/MonoGame/Game1.cs b/Examples/MonoGame/Game1.cs index 18339ad..59e7b6a 100644 --- a/Examples/MonoGame/Game1.cs +++ b/Examples/MonoGame/Game1.cs @@ -7,8 +7,8 @@ public class Game1 : Game { private GraphicsDeviceManager graphics; - private MidiPlayer midiPlayer; - private MidiFile midiFile; + private MidiFile? midiFile; + private MidiPlayer? midiPlayer; public Game1() { @@ -17,20 +17,24 @@ public Game1() protected override void LoadContent() { - midiPlayer = new MidiPlayer("TimGM6mb.sf2"); midiFile = new MidiFile(@"C:\Windows\Media\flourish.mid"); + midiPlayer = new MidiPlayer("TimGM6mb.sf2"); } protected override void UnloadContent() { - midiPlayer.Dispose(); + if (midiPlayer != null) + { + midiPlayer.Dispose(); + midiPlayer = null; + } } protected override void Update(GameTime gameTime) { - if (midiPlayer.State == SoundState.Stopped) + if (midiPlayer!.State == SoundState.Stopped) { - midiPlayer.Play(midiFile, true); + midiPlayer.Play(midiFile!, true); } base.Update(gameTime); diff --git a/Examples/Silk.NET.OpenAL/AudioStream.cs b/Examples/Silk.NET.OpenAL/AudioStream.cs index d298093..3c0411a 100644 --- a/Examples/Silk.NET.OpenAL/AudioStream.cs +++ b/Examples/Silk.NET.OpenAL/AudioStream.cs @@ -223,7 +223,7 @@ public void Stop() if (pollingTask != null) { - pollingCts.Cancel(); + pollingCts!.Cancel(); } } diff --git a/Examples/build_all.bat b/Examples/build_all.bat index 970eb34..f6af67f 100644 --- a/Examples/build_all.bat +++ b/Examples/build_all.bat @@ -1,77 +1,77 @@ cd CSCore dotnet build -c Release cd .. -copy TimGM6mb.sf2 CSCore\bin\Release\net6.0\TimGM6mb.sf2 +copy TimGM6mb.sf2 CSCore\bin\Release\net8.0\TimGM6mb.sf2 cd DotFeather dotnet build -c Release cd .. -copy TimGM6mb.sf2 DotFeather\bin\Release\net6.0\TimGM6mb.sf2 +copy TimGM6mb.sf2 DotFeather\bin\Release\net8.0\TimGM6mb.sf2 cd DrippyAL dotnet build -c Release cd .. -copy TimGM6mb.sf2 DrippyAL\bin\Release\net6.0\TimGM6mb.sf2 +copy TimGM6mb.sf2 DrippyAL\bin\Release\net8.0\TimGM6mb.sf2 cd FNA.NET dotnet build -c Release cd .. -copy TimGM6mb.sf2 FNA.NET\bin\Release\net6.0\TimGM6mb.sf2 +copy TimGM6mb.sf2 FNA.NET\bin\Release\net8.0\TimGM6mb.sf2 cd MonoGame dotnet build -c Release cd .. -copy TimGM6mb.sf2 MonoGame\bin\Release\net6.0\TimGM6mb.sf2 +copy TimGM6mb.sf2 MonoGame\bin\Release\net8.0\TimGM6mb.sf2 cd NAudio dotnet build -c Release cd .. -copy TimGM6mb.sf2 NAudio\bin\Release\net6.0-windows\TimGM6mb.sf2 +copy TimGM6mb.sf2 NAudio\bin\Release\net8.0-windows\TimGM6mb.sf2 cd OpenTK dotnet build -c Release cd .. -copy openal32.dll OpenTK\bin\Release\net6.0\openal32.dll -copy TimGM6mb.sf2 OpenTK\bin\Release\net6.0\TimGM6mb.sf2 +copy openal32.dll OpenTK\bin\Release\net8.0\openal32.dll +copy TimGM6mb.sf2 OpenTK\bin\Release\net8.0\TimGM6mb.sf2 cd Raylib_cs dotnet build -c Release cd .. -copy TimGM6mb.sf2 Raylib_cs\bin\Release\net6.0\TimGM6mb.sf2 +copy TimGM6mb.sf2 Raylib_cs\bin\Release\net8.0\TimGM6mb.sf2 cd Raylib_CsLo dotnet build -c Release cd .. -copy TimGM6mb.sf2 Raylib_CsLo\bin\Release\net6.0\TimGM6mb.sf2 +copy TimGM6mb.sf2 Raylib_CsLo\bin\Release\net8.0\TimGM6mb.sf2 cd SDL2 dotnet build -c Release cd .. -copy TimGM6mb.sf2 SDL2\bin\Release\net6.0\TimGM6mb.sf2 +copy TimGM6mb.sf2 SDL2\bin\Release\net8.0\TimGM6mb.sf2 cd SFML.Net dotnet build -c Release cd .. -copy TimGM6mb.sf2 SFML.Net\bin\Release\net6.0\TimGM6mb.sf2 +copy TimGM6mb.sf2 SFML.Net\bin\Release\net8.0\TimGM6mb.sf2 cd Silk.NET.OpenAL dotnet build -c Release cd .. -copy TimGM6mb.sf2 Silk.NET.OpenAL\bin\Release\net6.0\TimGM6mb.sf2 +copy TimGM6mb.sf2 Silk.NET.OpenAL\bin\Release\net8.0\TimGM6mb.sf2 cd Silk.NET.SDL dotnet build -c Release cd .. -copy TimGM6mb.sf2 Silk.NET.SDL\bin\Release\net6.0\TimGM6mb.sf2 +copy TimGM6mb.sf2 Silk.NET.SDL\bin\Release\net8.0\TimGM6mb.sf2 cd Sokol dotnet build -c Release cd .. -copy TimGM6mb.sf2 Sokol\bin\Release\net6.0\TimGM6mb.sf2 +copy TimGM6mb.sf2 Sokol\bin\Release\net8.0\TimGM6mb.sf2 cd TinyAudio dotnet build -c Release cd .. -copy TimGM6mb.sf2 TinyAudio\bin\Release\net6.0\TimGM6mb.sf2 +copy TimGM6mb.sf2 TinyAudio\bin\Release\net8.0\TimGM6mb.sf2 pause