コード例 #1
0
ファイル: App.xaml.cs プロジェクト: jindal1979/SoundByteOSS
        private async Task AppSuspendingAsync(object sender, SuspendingEventArgs e)
        {
            var def = e.SuspendingOperation.GetDeferral();

            try
            {
                // Clear live tile
                var updater = TileUpdateManager.CreateTileUpdaterForApplication();
                updater.Clear();

                var playbackService = SimpleIoc.Default.GetInstance <IPlaybackService>();
                if (playbackService != null)
                {
                    // Save current position
                    var currentPosition = playbackService.GetMediaPlayer()?.PlaybackSession?.Position;
                    await RoamingService.StopActivityAsync(currentPosition);

                    // Update the resume files
                    var roamingFolder = ApplicationData.Current.RoamingFolder;

                    var track    = new BaseSoundByteItem(playbackService.GetCurrentTrack());
                    var playlist = playbackService.GetMediaPlaybackList().Items.Select(x => new BaseSoundByteItem(x.Source.AsBaseTrack()));
                    var token    = playbackService.GetPlaylistToken();
                    var source   = playbackService.GetPlaylistSource();

                    var playbackFile = await roamingFolder.CreateFileAsync("currentPlayback.txt", CreationCollisionOption.OpenIfExists);

                    await FileIO.WriteTextAsync(playbackFile,
                                                ProtocolHelper.EncodeTrackProtocolItem(new ProtocolHelper.TrackProtocolItem(source, track, playlist, token, SimpleIoc.Default.GetInstance <IPlaybackService>().GetTrackPosition(), SimpleIoc.Default.GetInstance <IPlaybackService>().IsPlaylistShuffled()), false) + "\n" + SettingsService.Instance.SessionId);
                }
            }
            catch (Exception ex)
            {
                SimpleIoc.Default.GetInstance <ITelemetryService>().TrackException(ex);
            }
            finally
            {
                def.Complete();
            }
        }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: mediabuff/SoundByte
 private async void AppSuspending(object sender, SuspendingEventArgs e)
 {
     var currentPosition = PlaybackService.Instance.MediaPlayer?.PlaybackSession?.Position;
     await RoamingService.StopActivityAsync(currentPosition);
 }