© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•7mo ago•
7 replies
ـّّّ Jordan't ـّّّ

new to NAudio. having issues

if i run this function, skip to the next song and then run it again the song wont play unless the last one was paused or stopped.
i have absolutely no idea why this is happening but i believe i've narrowed it down to some issue with NAudio, specifically this section of my code:
            if (audioFile == null || audioFile.FileName != currentPath)
            {
                outputDevice?.Stop(); // Clean up any existing resources

                audioFile = new AudioFileReader(currentPath);
                audioFile.CurrentTime = playbackTime;

                outputDevice = new WaveOutEvent();
                outputDevice.Init(audioFile);
                outputDevice.PlaybackStopped += OnPlaybackStopped;
            }
            if (audioFile == null || audioFile.FileName != currentPath)
            {
                outputDevice?.Stop(); // Clean up any existing resources

                audioFile = new AudioFileReader(currentPath);
                audioFile.CurrentTime = playbackTime;

                outputDevice = new WaveOutEvent();
                outputDevice.Init(audioFile);
                outputDevice.PlaybackStopped += OnPlaybackStopped;
            }
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Error with Naudio
C#CC# / help
3y ago
having issues carrying variables to methods
C#CC# / help
4y ago
Having issues setting up Avalonia
C#CC# / help
16mo ago
Help: Using an Event handler. (NAudio)
C#CC# / help
3y ago