Пример #1
0
        /**
         * Assigns active input and output devices from among those available.
         * Notifies user regarding the name of the selected devices or whether the request failed.
         * <em>Both</em> devices must exist for the request to succeed.
         *
         * @param micIdx
         *  Index into the array of available recording devices of the requested input device.
         * @param spkrIdx
         *  Index into the array of available playback devices of the requested output device.
         *
         * @return
         * <ul>
         *   <li>true: success</li>
         *   <li>false: failure</li>
         * </ul>
         *
         * @see com.skype.api.Skype#getAvailableRecordingDevices()
         * @see com.skype.api.Skype#getAvailableOutputDevices()
         *
         * @since 2.0
         */
        public bool setupAudioDevices(int micIdx, int spkrIdx)
        {
            bool passFail = true;       // Ever the optimist, assume success!

            Skype.GetAvailableRecordingDevicesResponse inputDevices  = mySkype.getAvailableRecordingDevices();
            Skype.GetAvailableOutputDevicesResponse    outputDevices = mySkype.getAvailableOutputDevices();

            if (micIdx > (inputDevices.handleList.Length + 1))
            {
                MySession.myConsole.printf("%s: Invalid mic device no. (%d) passed!%n", myTutorialTag, micIdx);
                passFail = false;
            }

            if (spkrIdx > (outputDevices.handleList.Length + 1))
            {
                MySession.myConsole.printf("%s: Invalid speaker device no. (%d) passed!%n", myTutorialTag, spkrIdx);
                passFail = false;
            }

            if (passFail)
            {
                MySession.myConsole.printf("%s: Setting mic to %s (%s)%n",
                                           myTutorialTag, inputDevices.nameList[micIdx], inputDevices.productIdList[micIdx]);
                MySession.myConsole.printf("%s: Setting speakers to %s  (%s)%n",
                                           myTutorialTag, outputDevices.nameList[spkrIdx], outputDevices.productIdList[spkrIdx]);
                mySkype.selectSoundDevices(inputDevices.handleList[micIdx],
                                           outputDevices.handleList[spkrIdx], outputDevices.handleList[spkrIdx]);
                mySkype.setSpeakerVolume(100);
            }

            return(passFail);
        }
Пример #2
0
        /**
         * Find available input/output devices, then wait for incoming calls..
         * <ol>
         *   <li>List the available playback and recording devices.</li>
         *   <li>Set the current devices (input, output, notification) to the first device in their respective list.</li>
         *   <li>Initialize the speaker volume level.</li>
         *   <li>Wait for in-coming calls.</li>
         * </ol>
         *
         * @param mySession
         *	Populated session object
         *
         * @since 1.0
         */
        static void doAcceptCalls(MySession mySession)
        {
            int i;
            int j;

            Skype.GetAvailableOutputDevicesResponse    outputDevices = mySession.mySkype.getAvailableOutputDevices();
            Skype.GetAvailableRecordingDevicesResponse inputDevices  = mySession.mySkype.getAvailableRecordingDevices();

            // Getting a list of audio output devices.
            MySession.myConsole.println("** Playback devices:");
            j = outputDevices.handleList.Length;
            for (i = 0; i < j; i++)
            {
                MySession.myConsole.printf("\t%d. %s (%s)%n", i, outputDevices.nameList[i], outputDevices.productIdList[i]);
            }
            MySession.myConsole.println("");

            // Getting a list of audio input devices.
            MySession.myConsole.println("** Recording devices:");
            j = inputDevices.handleList.Length;
            for (i = 0; i < j; i++)
            {
                MySession.myConsole.printf("\t%d. %s (%s)%n", i, inputDevices.nameList[i], inputDevices.productIdList[i]);
            }
            MySession.myConsole.println("");

            // Currently setting the sound devices to the first input/output device.
            // The output and notification are routed through the same device. If you want more control,
            // don't invoke SetupAudioDevices -- instead invoke:
            //  mySession.mySkype.SelectSoundDevices(inputDevices.handleList[0],
            //											outputDevices.handleList[0],
            //											outputDevices.handleList[0]);
            //	mySession.mySkype.SetSpeakerVolume(100);
            //
            // If your microphone or speakers fail to work, you might want
            // to change these values.

            if (mySession.setupAudioDevices(0, 0))
            {
                MySession.myConsole.printf("%s: Audio device set-up completed!%n", mySession.myTutorialTag);
            }
            else
            {
                MySession.myConsole.printf("%s: Audio device set-up failed - exiting!%n", mySession.myTutorialTag);
                return;
            }

            MySession.myConsole.printf("%s: Now accepting incoming calls...%nPress Enter to quit.%n%n", mySession.myTutorialTag);
            try
            {
                while (true)
                {
                    int keyboardChar = (int)System.Console.ReadKey().KeyChar;
                    // Some platforms think ENTER is 0x0D; others think it's 0x0A...
                    if ((keyboardChar == 0x0D) || (keyboardChar == 0x0A))
                    {
                        break;
                    }
                }
            }
            catch (IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return;
            }

            MySession.myConsole.println("");
        }