Exemplo n.º 1
0
        private async Task OnNavigated(NavigationEventArgs e)
        {
            // If something is already playing, and it's not a theme song, leave it alone
            if (string.IsNullOrEmpty(_currentPlayingOwnerId) && _playback.MediaPlayers.Any(i => i.PlayState != PlayState.Idle))
            {
                return;
            }

            var itemPage = e.NewPage as ISupportsItemThemeMedia;

            if (itemPage == null || _session.LocalUserId == null || string.IsNullOrEmpty(itemPage.ThemeMediaItemId))
            {
                if (!string.IsNullOrEmpty(_currentPlayingOwnerId) && !(e.NewPage is ISupportsThemeMedia))
                {
                    _playback.StopAllPlayback();
                }
                return;
            }

            var itemId = itemPage.ThemeMediaItemId;

            var apiClient = _session.ActiveApiClient;

            var themeMediaResult = await GetThemeMedia(apiClient, itemId).ConfigureAwait(false);

            if (string.Equals(_currentPlayingOwnerId, themeMediaResult.OwnerId))
            {
                return;
            }

            // Don't replay the same one over and over
            if (string.Equals(_lastPlayedOwnerId, themeMediaResult.OwnerId))
            {
                return;
            }

            _lastPlayedOwnerId = null;

            if (themeMediaResult.Items.Length > 0)
            {
                await Play(GetItemsToPlay(themeMediaResult)).ConfigureAwait(false);

                _currentPlayingOwnerId = themeMediaResult.OwnerId;
                _lastPlayedOwnerId     = themeMediaResult.OwnerId;
            }
            else if (!string.IsNullOrEmpty(_currentPlayingOwnerId))
            {
                _playback.StopAllPlayback();
            }
        }
Exemplo n.º 2
0
        public async Task Logout()
        {
            _playback.StopAllPlayback();

            _apiClient.CurrentUserId = null;

            var previous = CurrentUser;

            CurrentUser = null;

            if (previous != null)
            {
                EventHelper.FireEventIfNotNull(UserLoggedOut, this, EventArgs.Empty, _logger);
            }

            await _navService.NavigateToLoginPage();

            _navService.ClearHistory();
        }
Exemplo n.º 3
0
        public async Task Logout()
        {
            _playback.StopAllPlayback();

            await _apiClient.Logout();

            var previous = CurrentUser;

            CurrentUser = null;

            if (previous != null)
            {
                EventHelper.FireEventIfNotNull(UserLoggedOut, this, EventArgs.Empty, _logger);
            }

            // Clear auto login info
            _config.Configuration.AutoLoginConfiguration = new AutoLoginConfiguration();
            _config.SaveConfiguration();

            await _navService.NavigateToLoginPage();

            _navService.ClearHistory();
        }