Exemple #1
0
 public void Pause()
 {
     try
     {
         _itunesApp.Pause();
     }
     catch (COMException) { }
 }
        public void Pause()
        {
            if (!IsActive)
            {
                return;
            }

            _app.Pause();
        }
Exemple #3
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( UnhandledException );
            iTunesApp application = new iTunesApp();

            if( application.PlayerState == ITPlayerState.ITPlayerStateStopped )
                application.Play();
            else
                application.Pause();
        }
Exemple #4
0
 private void bPlay_Click(object sender, EventArgs e)
 {
     if (!CheckPlayingState())
     {
         iTunes.Play();
         bPlay.Text = "■";
     }
     else
     {
         iTunes.Pause();
         bPlay.Text = "▶";
     }
 }
Exemple #5
0
        static void Main(string[] args)
        {
            iTunesApp iTunesInstance = new iTunesApp();

            if (args.Length == 0)
            {
                return;
            }

            switch(args[0].ToLower())
            {
                case "next":
                    iTunesInstance.NextTrack();

                    break;

                case "prev":
                    iTunesInstance.PreviousTrack();

                    break;

                case "play":
                    iTunesInstance.Play();

                    break;

                case "pause":
                    iTunesInstance.Pause();

                    break;

                case "current_track_artist":
                    Console.WriteLine(iTunesInstance.CurrentTrack.Artist);

                    break;

                case "current_track_name":
                    Console.WriteLine(iTunesInstance.CurrentTrack.Name);

                    break;

                case "state":
                    Console.WriteLine(iTunesInstance.PlayerState.ToString());

                    break;

                default:
                    break;
            }
        }
Exemple #6
0
        public static void Speak(this iTunesApp itunes, string message)
        {
            var pasueMusic = itunes.PlayerState == ITPlayerState.ITPlayerStatePlaying;

            if (pasueMusic)
            {
                itunes.Pause();
            }
            var voice = new SpVoice();

            voice.Speak(message, SpeechVoiceSpeakFlags.SVSFDefault);
            if (pasueMusic)
            {
                itunes.Play();
            }
        }
Exemple #7
0
 void doPause()
 {
     if (iTunesControl == null)
     {
         return;
     }
     // Pause track
     try
     {
         iTunesControl.Pause();
     }
     catch (COMException ex)
     {
         iTunesError(ex, "Could not pause in iTunes.");
     }
 }
Exemple #8
0
        private void initRecognizer()
        {
            mRecognizerRule = new SpeechLib.SpInProcRecoContext();
            bool hit = false;

            foreach (SpObjectToken recoPerson in mRecognizerRule.Recognizer.GetRecognizers())
            {
                if (recoPerson.GetAttribute("Language") == "411")
                {
                    mRecognizerRule.Recognizer.Recognizer = recoPerson;
                    hit = true;
                    break;
                }
            }
            if (!hit)
            {
                MessageBox.Show("日本語認識が利用できません");
                Application.Exit();
            }

            mRecognizerRule.Recognizer.AudioInput = createMicrofon();

            if (mRecognizerRule.Recognizer.AudioInput == null)
            {
                MessageBox.Show("マイク初期化エラー");
                Application.Exit();
            }

            mRecognizerRule.Hypothesis +=
                delegate(int streamNumber, object streamPosition, SpeechLib.ISpeechRecoResult result)
            {
                string strText = result.PhraseInfo.GetText();
                textBox1.Text = strText;
            };
            mRecognizerRule.Recognition +=
                delegate(int streamNumber, object streamPosition, SpeechLib.SpeechRecognitionType srt, SpeechLib.ISpeechRecoResult isrr)
            {
                SpeechEngineConfidence confidence = isrr.PhraseInfo.Rule.Confidence;
                switch (confidence)
                {
                case SpeechEngineConfidence.SECHighConfidence:
                    label3.Text = "Confidence is High";
                    break;

                case SpeechEngineConfidence.SECNormalConfidence:
                    label3.Text = "Confidence is Normal";
                    break;

                case SpeechEngineConfidence.SECLowConfidence:
                    label3.Text   = "Confidence is Low";
                    textBox2.Text = "信頼性が低すぎます";
                    return;
                }
                string strText = isrr.PhraseInfo.GetText();
                //isrr.PhraseInfo.
                label4.Text = isrr.RecoContext.Voice.Volume.ToString();
                if (strText == "えんいー")
                {
                    Application.Exit();
                }

                if (itunes != null)
                {
                    switch (strText)
                    {
                    case "あいちゅーんず.つぎのきょく":
                    case "あいちゅーんず.つぎ":
                        itunes.NextTrack();
                        break;

                    case "あいちゅーんず.まえのきょく":
                    case "あいちゅーんず.まえ":
                        itunes.PreviousTrack();
                        break;

                    case "あいちゅーんず.いちじていし":
                        itunes.Pause();
                        break;

                    case "あいちゅーんず.ていし":
                        itunes.Stop();
                        break;

                    case "あいちゅーんず.さいせい":
                        itunes.Play();
                        break;

                    case "あいちゅーんず.しね":
                        itunes.Quit();
                        unhockiTunes();
                        break;

                    case "あいちゅーんず.しずかに":
                        itunes.SoundVolume = 50;
                        break;

                    case "あいちゅーんず.おおきく":
                        itunes.SoundVolume = 100;
                        break;

                    case "あいちゅーんず.らんだむ":
                        itunes.CurrentPlaylist.Shuffle = !itunes.CurrentPlaylist.Shuffle;
                        break;
                    }
                }
                else
                {
                    if (strText == "あいちゅーんず.おきろ")
                    {
                        initiTunes();
                    }
                }
                textBox2.Text = strText;
            };
            mRecognizerRule.StartStream +=
                delegate(int streamNumber, object streamPosition)
            {
                textBox1.Text = textBox2.Text = "";
            };
            mRecognizerRule.FalseRecognition +=
                delegate(int streamNumber, object streamPosition, SpeechLib.ISpeechRecoResult isrr)
            {
                textBox1.Text = textBox2.Text = label3.Text = "--Error!--";
            };

            mRecognizerGrammarRule = mRecognizerRule.CreateGrammar();
            mRecognizerGrammarRule.Reset();
            mRecognizerGrammarRuleGrammarRule = mRecognizerGrammarRule.Rules.Add("TopLevelRule", SpeechRuleAttributes.SRATopLevel | SpeechRuleAttributes.SRADynamic);

            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.おきろ");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.つぎのきょく");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.まえのきょく");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.つぎ");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.まえ");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.いちじていし");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.ていし");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.さいせい");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.しね");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.しずかに");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.おおきく");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.らんだむ");
            // mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "えんいー");

            mRecognizerGrammarRule.Rules.Commit();
            mRecognizerGrammarRule.CmdSetRuleState("TopLevelRule", SpeechRuleState.SGDSActive);
        }
Exemple #9
0
        private void myVoice_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            string input = e.Result.Text;

            Console.WriteLine(input);

            switch (input.ToUpper())
            {
            case ("HOW IS THE WEATHER"):
            case ("WEATHER"):
            case ("HOWS THE WEATHER"):
            case ("HOW'S THE WEATHER"):
                getWeather();
                break;

            case ("TOMORROWS FORECAST"):
            case ("TOMORROWS WEATHER"):
            case ("HOWS TOMORROWS WEATHER"):
            case ("HOW IS TOMORROWS WEATHER"):
            case ("WHATS TOMORROW LIKE"):
            case ("WHATS IT LIKE TOMORROW"):
            case ("FORECAST"):
                getForecast();
                break;

            case ("MAIL"):
            case ("EMAIL"):
            case ("EMAILS"):
            case ("OPEN MAIL"):
            case ("OPEN EMAIL"):
            case ("OUTLOOK"):
            case ("SHOW MAIL"):
            case ("SHOW EMAIL"):
            case ("SHOW EMAILS"):
                openMail();
                break;

            case ("SEND MAIL"):
            case ("SEND EMAIL"):
            case ("SEND EMAILS"):
            case ("SEND AN EMAIL"):
            case ("SEND MESSAGE"):
                sendMail();
                break;

            case ("READ MAIL"):
            case ("READ EMAIL"):
            case ("READ EMAILS"):
                readMail();
                break;

            case ("SEARCH"):
            case ("SEARCH FOR"):
            case ("FIND"):
                search();
                break;

            //Works with no appointments - Haven't checked when appointment is present
            case ("CALENDER"):
            case ("CHECK CALENDER"):
            case ("APPOINTMENTS"):
            case ("TASKS"):
                Console.WriteLine("Calender");
                checkCalender();
                break;

            case ("GOOGLE"):
                googleSearch();
                break;

            case ("SHOW TIME"):
            case ("TIME"):
            case ("CURRENT TIME"):
            case ("TELL TIME"):
            case ("SAY TIME"):
                currentTime();
                break;

            case ("SHOW DAY"):
            case ("DAY"):
            case ("CURRENT DAY"):
            case ("TELL DAY"):
            case ("SAY DAY"):
            case ("SHOW DATE"):
            case ("DATE"):
            case ("CURRENT DATE"):
            case ("TELL DATE"):
            case ("SAY DATE"):
                currentDate();
                break;

            case ("HELLO"):
            case ("HEY JARVIS"):
            case ("HEY"):
            case ("SUP"):
            case ("GOOD MORNING"):
            case ("GOOD AFTERNOON"):
            case ("GOOD EVENING"):
                helloResponse();
                break;

            case ("PLAY"):
            case ("PLAY ITUNES"):
            case ("PLAY SONG"):
                app = new iTunesApp();
                app.Play();
                break;

            case ("PAUSE"):
            case ("PAUSE ITUNES"):
            case ("PAUSE SONG"):
                app = new iTunesApp();
                app.Pause();
                break;

            case ("NEXT"):
            case ("NEXT SONG"):
                app = new iTunesApp();
                app.NextTrack();
                app.Play();
                break;

            case ("PREVIOUS"):
            case ("PREVIOUS SONG"):
            case ("LAST SONG"):
                app = new iTunesApp();
                app.PreviousTrack();
                app.Play();
                break;

            case ("SHUFFLE"):
            case ("SHUFFLE ITUNES"):
                app = new iTunesApp();
                app.CurrentPlaylist.Shuffle = true;
                app.Play();
                break;

            case ("TURN DOWN VOLUME"):
            case ("TURN DOWN ITUNES"):
            case ("TURN DOWN SONG VOLUME"):
            case ("TURN DOWN THE VOLUME"):
            case ("TURN DOWN THE SONG VOLUME"):
            case ("TURN DOWN"):
            case ("VOLUME DOWN"):
                turnDownItunes();
                break;

            case ("TURN UP VOLUME"):
            case ("TURN UP ITUNES"):
            case ("TURN UP SONG VOLUME"):
            case ("TURN UP THE VOLUME"):
            case ("TURN UP THE SONG VOLUME"):
            case ("TURN UP"):
            case ("VOLUME UP"):
                turnUpItunes();
                break;

            case ("LEAGUE OF LEGENDS"):
            case ("LOL"):
            case ("LEAGUE"):
                Process.Start(@"C:\Riot Games\League of Legends\lol.launcher.exe");
                break;

            case ("LOLESPORTS"):
            case ("LOL ESPORTS"):
            case ("WATCH LEAGUE"):
                Process.Start("http://euw.lolesports.com/");
                Thread loadLeague = new Thread(new ThreadStart(() => speak.loading()));
                loadLeague.IsBackground = true;
                loadLeague.Start();
                break;

            case ("JARVIS QUIET"):
            case ("JARVIS SH"):
            case ("JARVIS VOLUME DOWN"):
                jarvisVolume(true);
                break;

            case ("JARVIS LOUD"):
            case ("I CANT HEAR YOU"):
            case ("I CANT HEAR YOU JARVIS"):
            case ("JARVIS VOLUME UP"):
                jarvisVolume(false);
                break;

            case ("JARVIS MUTE"):
            case ("MUTE"):
                jarvisMute(true);
                break;

            case ("JARVIS SPEAK"):
            case ("UNDO MUTE"):
                jarvisMute(false);
                break;

            case ("STOP LISTENING"):
                stopListening();
                break;

            case ("EXIT CHROME"):
            case ("CLOSE CHROME"):
                exitChromeWindows();
                break;

            case ("OPEN CHROME"):
                openChromeWindow();
                break;

            case ("ALL PROCESSES"):
            case ("SHOW PROCESSES"):
                showProcesses();
                break;

            case ("CLOSE MAIL"):
            case ("EXIT MAIL"):
            case ("CLOSE OUTLOOK"):
            case ("EXIT OUTLOOK"):
                closeEmail();
                break;

            case ("CLOSE ITUNES"):
            case ("EXIT ITUNES"):
                endProcess("itunes");
                break;

            case ("MOVIES"):
                loadMovies();
                break;

            case ("MINIMIZE"):
            case ("JARVIS SMALL"):
                minimize();
                break;

            case ("JARVIS COME BACK"):
            case ("JARVIS NORMAL"):
            case ("NORMAL"):
                normalSize();
                break;

            case ("QUIT"):
            case ("Q"):
            case ("STOP"):
            case ("END"):
                endProgram(this);
                break;

            default:
                noCommand();
                break;
            }
        }
        public MediaState Pause()
        {
            iTunesApp iTunes = null;

            try
            {
                iTunes = new iTunesApp();
                iTunes.Pause();
                return GetMediaState();
            }
            catch (Exception ex)
            {
                LogUtility.LogException(ex);
                throw;
            }
            finally
            {
                // Marshall.ReleaseComObject?
            }
        }
 public void PauseSong()
 {
     itunes.Pause();
 }