Coder Social home page Coder Social logo

Comments (3)

KodeKooker avatar KodeKooker commented on August 23, 2024 1

I also found this blocking issue while using the package on UWP platform, I'm waiting for an official fix on the nuget package.

from plugin.audiorecorder.

TristanMoreau avatar TristanMoreau commented on August 23, 2024

In the AudioRecorderService constructor, the Init() method is called to get the path of the file where the audio will be saved. Problem is this Init() partial method is async on the UWP part. When you use StartRecording(), since the Init() isn't awaited, it can cause crashes if the path is still null.

If you're willing to recompile the library, you can use this quick (and dirty) fix to make it work by using a loop checking the state of the path in StartRecording() :

public async Task<Task<string>> StartRecording ()
{
    //quickfix
    int retry = 0;
    while (filePath == null)
    {
          if (retry++ > 10)
               break;
          Task.Delay(100).Wait();
    }

    ResetAudioDetection();

    InitializeStream (PreferredSampleRate);

    await recorder.StartRecorder (audioStream, filePath);

    AudioStreamDetails = new AudioStreamDetails
    {
		ChannelCount = audioStream.ChannelCount,
		SampleRate = audioStream.SampleRate,
		BitsPerSample = audioStream.BitsPerSample
    };

    startTime = DateTime.Now;
    recordTask = new TaskCompletionSource<string> ();

    Debug.WriteLine ("AudioRecorderService.StartRecording() complete.  Audio is being recorded.");

    return recordTask.Task;
} 

You can of course adjust it to your needs as a temporary solution but, ideally, the Init() method should be awaited.

from plugin.audiorecorder.

NateRickard avatar NateRickard commented on August 23, 2024

Should be fixed in #15, though I'm unable to release a package at the moment as my Windows machine needs to be rebuilt. If you need this fix, just build the project and use the DLLs directly until I have time to revisit.

from plugin.audiorecorder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.