Ejemplo n.º 1
0
        /// <summary>
        /// Share an album.
        /// </summary>
        /// <param name="album">The album to be shared.</param>
        public static async Task ShareAsync(this DbAlbum album)
        {
            if (album != null)
            {
                var files = new List <StorageFile>();
                // Prep files.
                foreach (var et in album.MediaFiles)
                {
                    try
                    {
                        files.Add(await StorageFile.GetFileFromPathAsync(et.Path));
                    }
                    catch (COMException)
                    {
                        // WinRT error: ignore
                    }
                    catch (UnauthorizedAccessException)
                    {
                        // WinRT error: ignore
                    }
                    catch (FileNotFoundException)
                    {
                        // File not found: ignore
                    }
                }

                var shareService = ShareServices.GetForCurrentView();
                shareService.PrecleanForSession();
                shareService.Title       = album.Title;
                shareService.Description = album.Intro ?? string.Empty;
                shareService.AddFiles(files);
                shareService.ShowShareUI();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Share an artist.
 /// </summary>
 /// <param name="artist">The artist to be shared.</param>
 public static void Share(this DbArtist artist)
 {
     if (artist != null)
     {
         var shareService = ShareServices.GetForCurrentView();
         shareService.PrecleanForSession();
         shareService.SetArtistContent(artist);
         shareService.ShowShareUI();
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Share a file.
        /// </summary>
        /// <param name="file">The file to be shared.</param>
        /// <returns>An awaitable task.</returns>
        public static async Task ShareAsync(this DbMediaFile fileEntity)
        {
            var shareService = ShareServices.GetForCurrentView();

            shareService.PrecleanForSession();
            // FIXME: External file should still set this field, but they should retrieve file from MRU.
            // Currently no external files will be shared.
            await shareService.AddFileAsync(fileEntity.Path);

            shareService.Title       = fileEntity.Title;
            shareService.Description = string.Format(CommonSharedStrings.GetString(SongDescriptionFieldId),
                                                     fileEntity.Album,
                                                     fileEntity.AlbumArtist,
                                                     MiliSecToNormalTimeConverter.GetTimeStringFromTimeSpanOrDouble(fileEntity.Duration));
            shareService.ShowShareUI();
        }