Beispiel #1
0
        private async void DataSourceOnUpdateRequired(object sender, AudioFeedResponseItem e)
        {
            try
            {
                var result = await _agent.FullDesktopClient.UpdateAudioFeedAsync(new UpdateAudioFeedRequest()
                {
                    Item = e
                });

                ToastHelper.DisplaySuccess(result.Success, ToastLength.Short);

                if (result.Success)
                {
                    var feeds = await _agent.FullDesktopClient.GetAudioFeedsAsync(new AudioFeedRequest());

                    if (_recyclerView.GetAdapter() is AudioApplicationDataSource audioDataSource)
                    {
                        var match = feeds.Items.FirstOrDefault(d => d.Id == e.Id);
                        if (match != null)
                        {
                            audioDataSource.UpdateSingle(match);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
                ToastHelper.Display("Update failed", ToastLength.Short);
            }
        }
Beispiel #2
0
        public static bool TryUpdateFeed(AudioFeedResponseItem requestItem)
        {
            var sessionManager = GetMultiMediaSessionManager(DataFlow.Render);
            var foundSession   = false;

            try
            {
                sessionManager.RefreshSessions();
                Log.Trace("Found {Count} running audio sessions", sessionManager.Sessions.Count);
                for (int sessionIndex = 0; sessionIndex < sessionManager.Sessions.Count; sessionIndex++)
                {
                    var session = sessionManager.Sessions[sessionIndex];
                    if (session.IsSystemSoundsSession)
                    {
                        continue;
                    }

                    if (session.GetSessionIdentifier.Equals(requestItem.Id))
                    {
                        Log.Trace("Found session which matches requested session - Updating");

                        var fixedValue = requestItem.Volume <= 0f ? 0f : requestItem.Volume / 100;
                        session.SimpleAudioVolume.Mute   = requestItem.Muted;
                        session.SimpleAudioVolume.Volume = fixedValue;
                        foundSession = true;

                        Log.Debug("SimpleAudioVolume for {Name} updated", requestItem.Name);
                        break;
                    }
                }

                return(foundSession);
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(false);
            }
            finally
            {
                sessionManager.Dispose();
            }
        }