Beispiel #1
0
        public void InitLinphoneCore()
        {
            LinphoneManager.Instance.Core.ChatDatabasePath     = GetChatDatabasePath();
            LinphoneManager.Instance.Core.RootCa               = GetRootCaPath();
            LinphoneManager.Instance.Core.UserCertificatesPath = GetCertificatesPath();

            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
            {
                AudioRoutingManager.GetDefault().AudioEndpointChanged += AudioEndpointChanged;
            }

            if (LinphoneManager.Instance.Core.VideoSupported())
            {
                DetectCameras();
            }
            LinphoneManager.Instance.Core.UsePreviewWindow(true);
            LinphoneManager.Instance.Core.SetUserAgent("LinphoneW10", Core.Version);
            if (LinphoneManager.Instance.Core.Config != null)
            {
                EnableLogCollection(
                    (LinphoneManager.Instance.Core.Config.GetInt("app", "LogLevel", (int)LogCollectionState.Disabled) == 1) ? true : false);
            }
            InitPushNotifications();
            isLinphoneRunning = true;
            TimeSpan period = TimeSpan.FromMilliseconds(20);

            ThreadPoolTimer.CreatePeriodicTimer((source) => {
                CoreDispatcher.RunIdleAsync((args) => {
                    Core.Iterate();
                });
            }, period);
        }
Beispiel #2
0
        public void InitLinphoneCore()
        {
            Core.LogLevel = OutputTraceLevel.Debug;

            LinphoneManager.Instance.Core.ChatDatabasePath = GetChatDatabasePath();
            LinphoneManager.Instance.Core.RootCa           = GetRootCaPath();

            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
            {
                AudioRoutingManager.GetDefault().AudioEndpointChanged += AudioEndpointChanged;
            }

            if (LinphoneManager.Instance.Core.IsVideoSupported)
            {
                DetectCameras();
            }

            LinphoneManager.Instance.Core.SetUserAgent("LinphoneW10", Core.Version);
            InitPushNotifications();
            isLinphoneRunning = true;
            TimeSpan period = TimeSpan.FromMilliseconds(20);

            ThreadPoolTimer.CreatePeriodicTimer((source) => {
                CoreDispatcher.RunIdleAsync((args) => {
                    Core.Iterate();
                });
            }, period);
        }
Beispiel #3
0
        /// <summary>
        /// Method called when the page is displayed.
        /// Searches for a matching contact using the current call address or number and display information if found.
        /// </summary>
        protected override void OnNavigatedTo(NavigationEventArgs nee)
        {
            base.OnNavigatedTo(nee);
            this.ViewModel.MuteListener  = this;
            this.ViewModel.PauseListener = this;
            this.ViewModel.CallUpdatedByRemoteListener = this;
            LinphoneManager.Instance.CallStateChanged += CallStateChanged;
            AudioRoutingManager.GetDefault().AudioEndpointChanged += AudioEndpointChanged;

            if (NavigationContext.QueryString.ContainsKey("sip"))
            {
                String          calledNumber = NavigationContext.QueryString["sip"];
                LinphoneAddress address      = LinphoneManager.Instance.LinphoneCore.InterpretURL(calledNumber);
                calledNumber = String.Format("{0}@{1}", address.UserName, address.Domain);
                // While we dunno if the number matches a contact one, we consider it won't and we display the phone number as username
                Contact.Text = calledNumber;

                if (calledNumber != null && calledNumber.Length > 0)
                {
                    ContactManager cm = ContactManager.Instance;
                    cm.ContactFound += cm_ContactFound;
                    cm.FindContact(calledNumber);
                }
            }

            ApplicationSettingsManager settings = new ApplicationSettingsManager();

            settings.Load();

            // Callback CallStateChanged set too late when call is incoming, so trigger it manually
            if (LinphoneManager.Instance.LinphoneCore.CallsNb > 0)
            {
                LinphoneCall call = (LinphoneCall)LinphoneManager.Instance.LinphoneCore.Calls[0];
                if (call.State == LinphoneCallState.StreamsRunning)
                {
                    CallStateChanged(call, LinphoneCallState.StreamsRunning);
                    if (settings.VideoActiveWhenGoingToBackground)
                    {
                        LinphoneManager.Instance.LinphoneCore.VideoPolicy.AutomaticallyAccept = settings.VideoAutoAcceptWhenGoingToBackground;
                        LinphoneCallParams callParams = call.GetCurrentParamsCopy();
                        callParams.VideoEnabled = true;
                        LinphoneManager.Instance.LinphoneCore.UpdateCall(call, callParams);
                    }
                }
                else if (call.State == LinphoneCallState.UpdatedByRemote)
                {
                    // The call was updated by the remote party while we were in background
                    LinphoneManager.Instance.CallState(call, call.State, "call updated while in background");
                }
            }

            settings.VideoActiveWhenGoingToBackground = false;
            settings.Save();

            oneSecondTimer          = new DispatcherTimer();
            oneSecondTimer.Interval = TimeSpan.FromSeconds(1);
            oneSecondTimer.Tick    += timerTick;
            oneSecondTimer.Start();
        }
Beispiel #4
0
 private async void AudioEndpointChanged(AudioRoutingManager sender, object args)
 {
     await RunOnUiThread(() =>
     {
         var routingManager = AudioRoutingManager.GetDefault();
         SpeakerPhoneActive = (routingManager.GetAudioEndpoint() == AudioRoutingEndpoint.Speakerphone);
     });
 }
Beispiel #5
0
        private void OnUnloaded(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("Unloaded");

            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
            {
                AudioRoutingManager.GetDefault().AudioEndpointChanged -= AudioEndpointChanged;
            }
        }
Beispiel #6
0
        private void OnUnloaded(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("Unloaded");

            if (ApiInfo.IsPhoneContractPresent)
            {
                AudioRoutingManager.GetDefault().AudioEndpointChanged -= AudioEndpointChanged;
            }
        }
        public void Dispose()
        {
            _disposed = true;
            _debugTimer.Stop();
            _durationTimer.Stop();

            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
            {
                AudioRoutingManager.GetDefault().AudioEndpointChanged -= AudioEndpointChanged;
            }
        }
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
     {
         Routing.Visibility = Visibility.Visible;
         AudioRoutingManager.GetDefault().AudioEndpointChanged += AudioEndpointChanged;
     }
     else
     {
         Routing.Visibility = Visibility.Collapsed;
     }
 }
Beispiel #9
0
        int eventCount = 0; //used in AudioEndpointChangedEvent
        private void OnAudioEndpointChanged(AudioRoutingManager sender, object args)
        {
            var currentEndpoint = sender.GetAudioEndpoint();

            //when this event is initialized, it is invoked 2 times.
            //to avoid changing the device at that time, we use this statement.
            if (eventCount > 1)
            {
                SharedLogic.Player.ChangeDevice(currentEndpoint.ToString());
            }
            //increase the event count
            eventCount += 1;
        }
Beispiel #10
0
        private async void AudioEndpointChanged(AudioRoutingManager sender, object args)
        {
            if (_disposed)
            {
                return;
            }

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                var routingManager = AudioRoutingManager.GetDefault();
                Routing.IsChecked  = routingManager.GetAudioEndpoint() == AudioRoutingEndpoint.Speakerphone;
            });
        }
Beispiel #11
0
        private void DeactivateSpeakerPhoneExecute()
        {
            var routingManager = AudioRoutingManager.GetDefault();

            if (routingManager.AvailableAudioEndpoints.HasFlag(AvailableAudioRoutingEndpoints.Bluetooth))
            {
                routingManager.SetAudioEndpoint(AudioRoutingEndpoint.Bluetooth);
            }
            else if (routingManager.AvailableAudioEndpoints.HasFlag(AvailableAudioRoutingEndpoints.Earpiece))
            {
                routingManager.SetAudioEndpoint(AudioRoutingEndpoint.Earpiece);
            }
        }
Beispiel #12
0
        private int eventCount = 0; //used in AudioEndpointChangedEvent
        private async void OnAudioEndpointChanged(AudioRoutingManager sender, object args)
        {
            var currentEndpoint = sender.GetAudioEndpoint();

            //when this event is initialized, it is invoked 2 times.
            //to avoid changing the device at that time, we use this statement.
            if (eventCount > 1)
            {
                BLogger.I($"Switching audio render device to [{currentEndpoint.ToString()}].");
                await SharedLogic.Instance.Player.ChangeDevice(currentEndpoint.ToString());
            }
            //increase the event count
            eventCount += 1;
        }
Beispiel #13
0
        // Avoid memory leak by unsubscribing from foregroundUpdateService object
        // because its lifetime may be much longer.
        public void Dispose()
        {
            if (_foregroundUpdateService == null)
            {
                return;
            }

            _foregroundUpdateService.OnRelayMessagesUpdated -= OnRelayMessagesUpdated;
            _foregroundUpdateService.OnCallStatusUpdate     -= OnCallStatusUpdate;
            _foregroundUpdateService.OnFrameFormatUpdate    -= OnFrameFormatUpdate;
            if (IsAudioRoutingApiAvailable)
            {
                AudioRoutingManager.GetDefault().AudioEndpointChanged -= AudioEndpointChanged;
            }
        }
Beispiel #14
0
        private void AudioEndpointChanged(AudioRoutingManager sender, object args)
        {
            BaseModel.UIDispatcher.BeginInvoke(() =>
            {
                bool isBluetoothAudioRouteAvailable    = LinphoneManager.Instance.IsBluetoothAvailable;
                buttons.bluetooth.IsEnabled            = isBluetoothAudioRouteAvailable;
                buttons_landscape.bluetooth.IsEnabled  = isBluetoothAudioRouteAvailable;
                buttons.bluetoothImg.Opacity           = isBluetoothAudioRouteAvailable ? BUTTON_ENABLED_OPACITY : BUTTON_DISABLED_OPACITY;
                buttons_landscape.bluetoothImg.Opacity = isBluetoothAudioRouteAvailable ? BUTTON_ENABLED_OPACITY : BUTTON_DISABLED_OPACITY;

                bool isUsingBluetoothAudioRoute       = LinphoneManager.Instance.BluetoothEnabled;
                buttons.bluetooth.IsChecked           = isUsingBluetoothAudioRoute;
                buttons_landscape.bluetooth.IsChecked = isUsingBluetoothAudioRoute;
                buttons.bluetoothImg.Source           = new BitmapImage(new Uri(isUsingBluetoothAudioRoute ? bluetoothOn : bluetoothOff, UriKind.RelativeOrAbsolute));
                buttons_landscape.bluetoothImg.Source = new BitmapImage(new Uri(isUsingBluetoothAudioRoute ? bluetoothOn : bluetoothOff, UriKind.RelativeOrAbsolute));
            });
        }
Beispiel #15
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            if (Routing == null)
            {
                return;
            }

            if (ApiInfo.IsPhoneContractPresent)
            {
                Routing.Visibility = Visibility.Visible;
                AudioRoutingManager.GetDefault().AudioEndpointChanged += AudioEndpointChanged;
            }
            else
            {
                Routing.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #16
0
        public void Dispose()
        {
            _disposed = true;
            _debugTimer.Stop();
            _durationTimer.Stop();

            if (_controller != null)
            {
                //_controller.CallStateChanged -= OnCallStateChanged;
                //_controller.SignalBarsChanged -= OnSignalBarsChanged;
                _controller = null;
            }

            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
            {
                AudioRoutingManager.GetDefault().AudioEndpointChanged -= AudioEndpointChanged;
            }
        }
Beispiel #17
0
        /// <summary>
        /// Creates a new LinphoneCore (if not created yet) using a LinphoneCoreFactory.
        /// </summary>
        public void InitLinphoneCore()
        {
            if (server.LinphoneCoreFactory != null && server.LinphoneCore != null)
            {
                // Reconnect the listeners when coming back from background mode
                Logger.Dbg("[LinphoneManager] LinphoneCore already created, skipping");

                server.LinphoneCore.CoreListener = this;
                // Set user-agent because it is not set if coming back from background mode
                try
                {
                    server.LinphoneCore.SetUserAgent(Customs.UserAgent, Linphone.Version.Number);
                    isLinphoneRunning = true;
                    return;
                } catch {
                    // It happens server.LinphoneCore is available but the real core behind is broken, we'll catch this here and force recreate a new core
                    Logger.Dbg("[LinphoneManager] Exception happened while setting the UA, force creation of a new LinphoneCore");
                }
            }

            Debug.WriteLine("[LinphoneManager] Creating LinphoneCore");
            InitManager.CreateLinphoneCore(server, this, LogLevel);
            Logger.Dbg("[LinphoneManager] LinphoneCore created");

            AudioRoutingManager.GetDefault().AudioEndpointChanged += AudioEndpointChanged;
            CallController.MuteRequested   += MuteRequested;
            CallController.UnmuteRequested += UnmuteRequested;

            if (server.LinphoneCore.VideoSupported)
            {
                DetectCameras();
            }

            server.LinphoneCore.SetUserAgent(Customs.UserAgent, Linphone.Version.Number);
            AddPushInformationsToContactParams();

            lastNetworkState = DeviceNetworkInformation.IsNetworkAvailable;
            server.LinphoneCore.NetworkReachable = lastNetworkState;
            DeviceNetworkInformation.NetworkAvailabilityChanged += new EventHandler <NetworkNotificationEventArgs>(OnNetworkStatusChanged);
            ConfigureTunnel();

            server.LinphoneCore.IterateEnabled = true;
            isLinphoneRunning = true;
        }
Beispiel #18
0
        public ConversationViewModel(IClientChannel clientChannel,
                                     IForegroundUpdateService foregroundUpdateService,
                                     ICallChannel callChannel, CoreDispatcher uiDispatcher,
                                     IMediaSettingsChannel settingsChannel)
        {
            _clientChannel           = clientChannel;
            _callChannel             = callChannel;
            _settingsChannel         = settingsChannel;
            _uiDispatcher            = uiDispatcher;
            _foregroundUpdateService = foregroundUpdateService;
            foregroundUpdateService.OnRelayMessagesUpdated += OnRelayMessagesUpdated;
            foregroundUpdateService.OnCallStatusUpdate     += OnCallStatusUpdate;
            foregroundUpdateService.OnFrameFormatUpdate    += OnFrameFormatUpdate;
            foregroundUpdateService.OnFrameRateUpdate      += OnFrameRateUpdate;
            SendInstantMessageCommand = new DelegateCommand(OnSendInstantMessageCommandExecute,
                                                            OnSendInstantMessageCommandCanExecute);
            AudioCallCommand         = new DelegateCommand(OnCallCommandExecute, OnCallCommandCanExecute);
            VideoCallCommand         = new DelegateCommand(OnVideoCallCommandExecute, OnVideoCallCommandCanExecute);
            HangupCommand            = new DelegateCommand(OnHangupCommandExecute, OnHangupCommandCanExecute);
            AnswerCommand            = new DelegateCommand(OnAnswerCommandExecute, OnAnswerCommandCanExecute);
            RejectCommand            = new DelegateCommand(OnRejectCommandExecute, OnRejectCommandCanExecute);
            CloseConversationCommand = new DelegateCommand(OnCloseConversationCommandExecute,
                                                           () => _canCloseConversation);
            MuteMicrophoneCommand   = new DelegateCommand(MuteMicCommandExecute, MicCommandCanExecute);
            UnMuteMicrophoneCommand = new DelegateCommand(UnMuteCommandExecute, MicCommandCanExecute);
            SwitchVideoCommand      = new DelegateCommand(SwitchVideoCommandExecute, SwitchVideoCommandCanExecute);

            IsAudioRoutingApiAvailable = ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1);
            if (IsAudioRoutingApiAvailable)
            {
                ActivateSpeakerPhone   = new DelegateCommand(ActivateSpeakerPhoneExecute, ActivateSpeakerPhoneCanExecute);
                DeactivateSpeakerPhone = new DelegateCommand(DeactivateSpeakerPhoneExecute, DeactivateSpeakerPhoneCanExecute);
                AudioRoutingManager.GetDefault().AudioEndpointChanged += AudioEndpointChanged;
            }

            ActivateFrontCamera = new DelegateCommand(ActivateFrontCameraExecute, ActivateFrontCameraCanExecute);
            ActivateBackCamera  = new DelegateCommand(ActivateBackCameraExecute, ActivateBackCameraCanExecute);

            LayoutService.Instance.LayoutChanged += LayoutChanged;
            LayoutChanged(LayoutService.Instance.LayoutType);
            SetVideoPresenters();
        }
Beispiel #19
0
        public ShellViewModel()
        {
            NavigateToNowPlayingViewCommand = new RelayCommand(NavigateToNowPlayingView);
            WatchAnAdCommand      = new DelegateCommand(WatchAnAd);
            IncreaseVolumeCommand = new DelegateCommand(IncreaseVolume);
            DecreaseVolumeCommand = new DelegateCommand(DecreaseVolume);
            SeekForwardCommand    = new DelegateCommand(SeekForward);
            SeekBackwardCommand   = new DelegateCommand(SeekBackward);
            MuteCommand           = new DelegateCommand(Mute);
            Messenger.Instance.Register(MessageTypes.MsgPlaylistLoaded, new Action <Message>(HandleLibraryLoadedMessage));
            Messenger.Instance.Register(MessageTypes.MsgLibraryLoaded, new Action <Message>(HandleLibraryLoadedMessage));
            Messenger.Instance.Register(MessageTypes.MsgPlaySong, new Action <Message>(HandlePlaySongMessage));
            Messenger.Instance.Register(MessageTypes.MsgDispose, HandleDisposeMessage);
            Messenger.Instance.Register(MessageTypes.MsgExecuteCmd, new Action <Message>(HandleExecuteCmdMessage));
            Messenger.Instance.Register(MessageTypes.MsgUpdateSongCount, new Action <Message>(HandleEnablePlayMessage));
            Messenger.Instance.Register(MessageTypes.MsgStopAfterSong, new Action <Message>(HandleSaveSongToStopAfterMessage));
            PlayPauseIcon = new SymbolIcon(Symbol.Play);
            //PlaylistsItems = new ObservableCollection<SimpleNavMenuItem>();
            SharedLogic.Instance.Player.PlayerState = PlayerState.Stopped;
            DontUpdatePosition = false;
            _timer             = new DispatcherTimer(new BreadDispatcher())
            {
                Interval = TimeSpan.FromMilliseconds(1)
            };
            _timer.Tick += Timer_Tick;
            _timer.Stop();
            SharedLogic.Instance.Player.MediaEnded += Player_MediaEnded;
            PropertyChanged += ShellViewModel_PropertyChanged;
            SharedLogic.Instance.Player.MediaAboutToEnd += Player_MediaAboutToEnd;
            SharedLogic.Instance.Player.MediaChanging   += OnMediaChanging;

            //these events are for detecting when the default audio
            //device is changed in PC and Mobile.
            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
            {
                AudioRoutingManager.GetDefault().AudioEndpointChanged += OnAudioEndpointChanged;
            }
            else
            {
                MediaDevice.DefaultAudioRenderDeviceChanged += OnDefaultAudioRenderDeviceChanged;
            }
        }
Beispiel #20
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            AudioRoutingManager.GetDefault().AudioEndpointChanged += AudioEndpointChanged_Handler;
            base.OnNavigatedTo(e);
            // AudioRoutingManager.GetDefault().AudioEndpointChanged += AudioEndpointChanged_Handler;

            radioRegionSetter();

            plyBtnTextUpdater();
            // Radyo zaten çalıyorken uygulama tekrar çalıştırıldığında duruma adapte ol
            if (fmRadioInstance.PowerMode == RadioPowerMode.On || fmRadioInstance.SignalStrength != 0.0)
            {
                // frequency_text.Text = fmRadioInstance.Frequency.ToString();
                // string addition = frequency_text.Text + ".0";
                // frequency_slider.Value = Convert.ToDouble(addition);

                frequency_slider.Value = Convert.ToDouble(fmRadioInstance.Frequency.ToString());

                plyBtnTextUpdater();
            }
            frequency_slider.ValueChanged += Slider_Value_Changed;
        }
Beispiel #21
0
        /// <summary>
        /// Method called when the page is leaved.
        /// </summary>
        protected override void OnNavigatedFrom(NavigationEventArgs nee)
        {
            if (((InCallModel)ViewModel).IsVideoActive)
            {
                LinphoneCall call = null;
                try
                {
                    call = (LinphoneCall)LinphoneManager.Instance.LinphoneCore.Calls[0];
                }
                catch (System.ArgumentOutOfRangeException) { }
                if (call != null)
                {
                    ApplicationSettingsManager settings = new ApplicationSettingsManager();
                    settings.Load();
                    settings.VideoActiveWhenGoingToBackground     = true;
                    settings.VideoAutoAcceptWhenGoingToBackground = LinphoneManager.Instance.LinphoneCore.VideoPolicy.AutomaticallyAccept;
                    settings.Save();
                    LinphoneManager.Instance.LinphoneCore.VideoPolicy.AutomaticallyAccept = false;
                    LinphoneCallParams callParams = call.GetCurrentParamsCopy();
                    callParams.VideoEnabled = false;
                    LinphoneManager.Instance.LinphoneCore.UpdateCall(call, callParams);
                }
            }

            oneSecondTimer.Stop();
            if (fadeTimer != null)
            {
                fadeTimer.Dispose();
                fadeTimer = null;
            }

            base.OnNavigatedFrom(nee);
            this.ViewModel.MuteListener  = null;
            this.ViewModel.PauseListener = null;
            LinphoneManager.Instance.CallStateChanged -= CallStateChanged;
            AudioRoutingManager.GetDefault().AudioEndpointChanged -= AudioEndpointChanged;
        }
Beispiel #22
0
        private void Routing_Click(object sender, RoutedEventArgs e)
        {
            var routingManager = AudioRoutingManager.GetDefault();

            var toggle = sender as ToggleButton;

            toggle.IsChecked = !toggle.IsChecked;

            if (toggle.IsChecked.Value)
            {
                routingManager.SetAudioEndpoint(AudioRoutingEndpoint.Speakerphone);
            }
            else
            {
                if (routingManager.AvailableAudioEndpoints.HasFlag(AvailableAudioRoutingEndpoints.Bluetooth))
                {
                    routingManager.SetAudioEndpoint(AudioRoutingEndpoint.Bluetooth);
                }
                else if (routingManager.AvailableAudioEndpoints.HasFlag(AvailableAudioRoutingEndpoints.Earpiece))
                {
                    routingManager.SetAudioEndpoint(AudioRoutingEndpoint.Earpiece);
                }
            }
        }
Beispiel #23
0
 private void OnReadingChanged(ProximitySensor sender, ProximitySensorReadingChangedEventArgs args)
 {
     AudioRoutingManager.GetDefault().SetAudioEndpoint(args.Reading.IsDetected ? AudioRoutingEndpoint.Earpiece : AudioRoutingEndpoint.Speakerphone);
 }
 public AudioRoutingManagerEvents(AudioRoutingManager This)
 {
     this.This = This;
 }
Beispiel #25
0
 private void AudioEndpointChanged(AudioRoutingManager sender, object args)
 {
     Debug.WriteLine("[LinphoneManager] AudioEndpointChanged:" + sender.GetAudioEndpoint().ToString() + "\r\n");
 }
        private void AudioEndpointChanged(AudioRoutingManager sender, object args)
        {
            BaseModel.UIDispatcher.BeginInvoke(() =>
            {
                bool isBluetoothAudioRouteAvailable = LinphoneManager.Instance.IsBluetoothAvailable;
                buttons.bluetooth.IsEnabled = isBluetoothAudioRouteAvailable;
                buttons_landscape.bluetooth.IsEnabled = isBluetoothAudioRouteAvailable;
                buttons.bluetoothImg.Opacity = isBluetoothAudioRouteAvailable ? BUTTON_ENABLED_OPACITY : BUTTON_DISABLED_OPACITY;
                buttons_landscape.bluetoothImg.Opacity = isBluetoothAudioRouteAvailable ? BUTTON_ENABLED_OPACITY : BUTTON_DISABLED_OPACITY;

                bool isUsingBluetoothAudioRoute = LinphoneManager.Instance.BluetoothEnabled;
                buttons.bluetooth.IsChecked = isUsingBluetoothAudioRoute;
                buttons_landscape.bluetooth.IsChecked = isUsingBluetoothAudioRoute;
                buttons.bluetoothImg.Source = new BitmapImage(new Uri(isUsingBluetoothAudioRoute ? bluetoothOn : bluetoothOff, UriKind.RelativeOrAbsolute));
                buttons_landscape.bluetoothImg.Source = new BitmapImage(new Uri(isUsingBluetoothAudioRoute ? bluetoothOn : bluetoothOff, UriKind.RelativeOrAbsolute));
            });
        }
 private void AudioEndpointChanged(AudioRoutingManager sender, object args)
 {
     Logger.Msg("[LinphoneManager] AudioEndpointChanged:" + sender.GetAudioEndpoint().ToString() + "\r\n");
 }
Beispiel #28
0
        //code to create new tiles - can be used for preset pinning and directly tuning into radio stations.
        //private void pinPrimaryTile(object sender, EventArgs e)
        //{
        //    StandardTileData standardTileData = new StandardTileData();
        //    ShellTile tileToPin = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("MainPage.xaml"));

        //    standardTileData.Title = "fmRadio";
        //    standardTileData.BackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative);

        //    if (tileToPin == null)
        //    {
        //        ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), standardTileData);
        //    }
        //    else
        //    {
        //        MessageBox.Show("Application tile is already pinned");
        //    }
        //}

        public void AudioEndpointChanged_Handler(AudioRoutingManager sender, object args)
        {
            string title = AppResources.NoAntenna;
            string msg   = AppResources.NoAntennaErrorMessage;

            if (IsolatedStorageSettings.ApplicationSettings.Contains("language"))
            {
                var languageKey = IsolatedStorageSettings.ApplicationSettings["language"].ToString();
                switch (languageKey)
                {
                case App.Languages.English:
                    title = "No Antenna";
                    msg   = "Your headphones are used as an FM radio antenna. To listen to the radio, connect your headphones.";
                    break;

                case App.Languages.Turkce:
                    title = "Anten Yok";
                    msg   = "Kulaklığınız FM radyo anteni olarak kullanılmaktadır. FM radyo dinleyebilmek için kulaklık takınız.";
                    break;
                }
            }

            var AudioEndPoint = sender.GetAudioEndpoint();

            switch (AudioEndPoint)
            {
            case AudioRoutingEndpoint.Default:
            case AudioRoutingEndpoint.Earpiece:
            case AudioRoutingEndpoint.Speakerphone:
            case AudioRoutingEndpoint.Bluetooth:
            case AudioRoutingEndpoint.BluetoothWithNoiseAndEchoCancellation:
            {
                isJackPlugged = false;
                Dispatcher.BeginInvoke(() =>
                    {
                        MessageBox.Show(msg, title, MessageBoxButton.OK);
                    });
                break;
            }

            case AudioRoutingEndpoint.WiredHeadset:
            {
                isJackPlugged = true;
                break;
            }

            case AudioRoutingEndpoint.WiredHeadsetSpeakerOnly:
            {
                isJackPlugged = true;
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
            if (!isJackPlugged)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    playButtonImage.Source = new BitmapImage(new Uri(@"Assets/AppBar/transport.play.png", UriKind.RelativeOrAbsolute));
                });
            }
        }
Beispiel #29
0
 private void MainPage_Unloaded(object sender, RoutedEventArgs e)
 {
     AudioRoutingManager.GetDefault().AudioEndpointChanged -= AudioEndpointChanged_Handler;
 }
Beispiel #30
0
        private void ActivateSpeakerPhoneExecute()
        {
            var routingManager = AudioRoutingManager.GetDefault();

            routingManager.SetAudioEndpoint(AudioRoutingEndpoint.Speakerphone);
        }