MvvmCross + Shiny Plugin (Voice Recognition)

Hi,

I'm am interesting about the Shiny Plugin from Allan Ritchie.
=> https://github.com/shinyorg

I'm looking for the Voice Recognition.
https://www.nuget.org/packages/Shiny.SpeechRecognition/1.0.0.357-beta

Actually I'm working on a Xamarin.Forms project that use the MvvmCross Framework.
I was wondering if someone here has to work with this two element together.

Recently I saw this => "Integrations with 3rd Party MVVM Frameworks like Prism, ReactiveUI, & MvvmCross" on https://allancritchie.net/posts/introducingshiny

To be simple, I have a Portable Project that initialize MvvmCross ( + ViewModel, etc...)
A Forms, Forms.Android and Forms.iOS project.

public partial class App : MvxApplication
{
    public override void Initialize()
            {
                RegisterAppStart<VoiceRecognitionViewModel>();
            }
}

I don't understand how I can initialize the ISpeechRecognizer in the ViewModel in Portable project.
The IoC container doesn't recognize it, and MvvmCross navigation doesn't recognize the constructor and I can't navigate on it.

public VoiceRecognitionViewModel(IMvxNavigationService navigationService, ISpeechRecognizer speechRecognizer, IUserDialogs userDialogs)
        {
            // Do stuff
        }

What I want to know is, how can I initialize from the beginning the Shiny plugin (ShinyStartup) ?
The Shiny sample work with the Prism MvvmCross => https://github.com/shinyorg/shinysamples

Thank for the help.
Zebiphire

Posts

  • Zebiphire67Zebiphire67 Member ✭✭

    Hello,

    We can see the integration is "in progress".
    => https://github.com/shinyorg/shiny/tree/master/src/Shiny.Integrations.MvvmCross

    Someone in the forum hase already made working Shiny.SpeedRecognition on a MvvmCross Project ?

    The Sample is using Prism Framework.
    => https://github.com/shinyorg/shinysamples

    I try to understand how it can work with MvvmCross.
    Thank.

  • Zebiphire67Zebiphire67 Member ✭✭

    Ok, I figure out how initialize the Plugin at the start of the application.
    We need to follow the directives => https://allancritchie.net/posts/introducingshiny

    Initialize a Shiny Startup.

    public class InitializeShiny : ShinyStartup
        {
            public override void ConfigureServices(IServiceCollection services)
            {
                services.UseSpeechRecognition();
            }
        }
    

    Then in your MvxFormsAppCompatActivity (android example) initialize in the OnCreate():

     AndroidShinyHost.Init(Application, new InitializeShiny(), services =>
                {
                    services.UseSpeechRecognition();
                });
    

    Now I'm trying to use the service in the ViewModel constructor (ISpeechRecognizer speechRecognizer).

    Like:

    public VoiceRecognitionViewModel(IMvxNavigationService navigationService, ISpeechRecognizer speechRecognizer)
            {
                // Todo
            }
    

    Can we use something like:

    Mvx.IoCProvider.LazyConstructAndRegisterSingleton<ISpeechRecognizer, SpeechRecognizerImpl>();

    ISpeechRecognizer and SpeechRecognizerImpl come from the Shiny Plugin.

    I got this error from:

    ISpeechRecognizer _speechRecognizer = Mvx.IoCProvider.Resolve();

    MvvmCross.Exceptions.MvxIoCResolveException: 'Failed to resolve parameter for parameter context of type AndroidContext when creating Shiny.SpeechRecognition.SpeechRecognizerImpl. You may pass it as an argument'

    Do you know how can I have access to ISpeechRecognizer ?

    Thank.

Sign In or Register to comment.