コード例 #1
0
        public override int PluginMain()
        {
            ConsoleHelper.CreateConsole();

            while (true)
            {
                Console.WriteLine(" == Recognizing == ");
                Task <SpeechRecognitionResult> recognizer = RecognizeSpeech();
                SpeechRecognitionResult        result     = recognizer.Result;
                if (result == null)
                {
                    Console.WriteLine("Couldn't recognize, try again");
                    continue;
                }

                if (result.Text == "exit")
                {
                    break;
                }

                UiBuiltins.Notification(
                    header: "Text spoken",
                    message: result.Text
                    );
            }
            return(0);
        }
コード例 #2
0
        public int MainHandler(NameValueCollection parameters)
        {
            List <ListItem> items = new List <ListItem> {
                new ListItem(
                    label: "AudioPlayer",
                    url: BuildNavUrl("/audio"),
                    isFolder: true,
                    art: new Dictionary <Art, string> {
                    { Art.Poster, "https://upload.wikimedia.org/wikipedia/commons/2/25/Kodi-logo-Thumbnail-light-transparent.png" },
                    { Art.Fanart, "https://images.pexels.com/photos/167092/pexels-photo-167092.jpeg?dl&fit=crop&crop=entropy&w=6000&h=4000" }
                }
                    ),
                new ListItem(
                    label: "Events",
                    url: BuildNavUrl("/events"),
                    isFolder: true
                    ),
                new ListItem(
                    label: "Nav",
                    url: BuildNavUrl("/nav"),
                    isFolder: true
                    ),
                new ListItem(
                    label: "Playlist",
                    url: BuildNavUrl("/playlist"),
                    isFolder: true
                    ),
                new ListItem(
                    label: "Video",
                    url: BuildNavUrl("/video"),
                    art: new Dictionary <Art, string>()
                {
                    { Art.Fanart, "https://mango.blender.org/wp-content/gallery/4k-renders/26_thom_robot.jpg" },
                    { Art.Poster, "https://mango.blender.org/wp-content/themes/tearsofsteel/images/logo.png" },
                }
                    ),
                new ListItem(
                    label: "Video2",
                    url: BuildNavUrl("/video2"),
                    art: new Dictionary <Art, string>()
                {
                    { Art.Poster, "https://peach.blender.org/wp-content/uploads/poster_bunny_small.jpg?x81236" },
                    { Art.Fanart, "https://peach.blender.org/wp-content/uploads/bbb-splash.png?x81236" }
                }
                    )
            };

            List.Add(items);
            List.Show();

            UiBuiltins.Notification(
                header: "My Notification",
                message: "Hello World from C#",
                duration: TimeSpan.FromSeconds(1)
                );

            return(0);
        }
コード例 #3
0
        public int PluginMain(NameValueCollection parameters)
        {
            ConsoleHelper.CreateConsole();

            Console.WriteLine(" == Recognizing == ");
            Console.WriteLine($"Say \"{ExitKeyword}\" to exit");
            UiBuiltins.Notification("Info", $"Say \"{ExitKeyword}\" to exit");
            RecognizeSpeech();

            exitEvent.WaitOne();
            return(0);
        }
コード例 #4
0
        public async void RecognizeSpeech()
        {
            var speechRecognizer = new SpeechRecognizer(SpeechRecognizer.SystemSpeechLanguage);

            var dictationConstraint = new SpeechRecognitionTopicConstraint(SpeechRecognitionScenario.Dictation, "dictation");

            speechRecognizer.Constraints.Add(dictationConstraint);

            var srcpres = await speechRecognizer.CompileConstraintsAsync();

            if (srcpres.Status != SpeechRecognitionResultStatus.Success)
            {
                Console.WriteLine("Failed to compile constraints");
                exitEvent.Set();
                return;
            }

            while (true)
            {
                var res = await speechRecognizer.RecognizeAsync();

                switch (res.Status)
                {
                case SpeechRecognitionResultStatus.Success:
                    break;

                default:
                    Console.WriteLine($"Failed ({res.Status.ToString()}), try again");
                    continue;
                }

                switch (res.Confidence)
                {
                case SpeechRecognitionConfidence.Low:
                case SpeechRecognitionConfidence.Rejected:
                    Console.WriteLine("Not enough confidence...");
                    continue;
                }

                UiBuiltins.Notification(
                    header: "Text spoken",
                    message: res.Text
                    );

                if (res.Text == ExitKeyword)
                {
                    exitEvent.Set();
                    break;
                }
            }
        }
コード例 #5
0
ファイル: TestPlugin.cs プロジェクト: liulaojian/KodiSharp
        public void MainHandler(NameValueCollection parameters)
        {
            TestPlugin      addon = KodiBridge.RunningAddon as TestPlugin;
            List <ListItem> items = new List <ListItem> {
                new ListItem(
                    label: "AudioPlayer",
                    url: addon.BuildNavUrl("/audio"),
                    isFolder: true,
                    art: new Dictionary <Art, string> {
                    { Art.Poster, "https://upload.wikimedia.org/wikipedia/commons/2/25/Kodi-logo-Thumbnail-light-transparent.png" },
                    { Art.Fanart, "https://images.pexels.com/photos/167092/pexels-photo-167092.jpeg?dl&fit=crop&crop=entropy&w=6000&h=4000" }
                }
                    ),
                new ListItem(
                    label: "Events",
                    url: addon.BuildNavUrl("/events"),
                    isFolder: true
                    ),
                new ListItem(
                    label: "Nav",
                    url: addon.BuildNavUrl("/nav"),
                    isFolder: true
                    ),
                new ListItem(
                    label: "Playlist",
                    url: addon.BuildNavUrl("/playlist"),
                    isFolder: true
                    ),
                new ListItem("Item 2"),
                new ListItem("Item 3")
            };

            List.Add(items);
            List.Show();

            UiBuiltins.Notification(
                header: "My Notification",
                message: "Hello World from C#",
                duration: TimeSpan.FromSeconds(10)
                );

            /*
             * Persistent variables preserve their value between multiple plugin invokations,
             * unlike python in XBMC where everything is destroyed when the plugin is invoked again (e.g navigating between pages).
             * This is possible due to Assembly Domain that is created by the CLR once the plugin is loaded for the first time.
             **/
            TestPluginState.LastMainPageVisitTime = DateTime.Now;
        }
コード例 #6
0
ファイル: TestPlugin.cs プロジェクト: mediabuff/KodiSharp
        public static void MainHandler(NameValueCollection parameters)
        {
            TestPlugin      addon = KodiBridge.RunningAddon as TestPlugin;
            List <ListItem> items = new List <ListItem> {
                new ListItem(
                    label: "AudioPlayer",
                    url: addon.BuildNavUrl("/audio"),
                    isFolder: true
                    ),
                new ListItem(
                    label: "Events",
                    url: addon.BuildNavUrl("/events"),
                    isFolder: true
                    ),
                new ListItem(
                    label: "Nav",
                    url: addon.BuildNavUrl("/nav"),
                    isFolder: true
                    ),
                new ListItem("Item 2"),
                new ListItem("Item 3")
            };

            List.Add(items);
            List.Show();

            //Console.WriteLine("Settings Test: " + addon.Settings["test"]);

            UiBuiltins.Notification(
                header: "My Notification",
                message: "Hello World from C#",
                duration: TimeSpan.FromSeconds(10)
                );

            /*
             * Persistent variables preserve their value between multiple plugin invokations,
             * unlike python in XBMC where everything is destroyed when the plugin is invoked again (e.g navigating between pages).
             * This is possible due to Assembly Domain that is created by the CLR once the plugin is loaded for the first time.
             **/
            TestPluginState.LastMainPageVisitTime = DateTime.Now;
        }
コード例 #7
0
 public virtual int DefaultRoute()
 {
     UiBuiltins.Notification(header: "KodiSharp", message: "No Routes found", duration: TimeSpan.FromSeconds(30));
     return(0);
 }