Esempio 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();
            }
        }
Esempio 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();
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Get ShareServices instance for current view.
        /// </summary>
        /// <returns></returns>
        public static ShareServices GetForCurrentView()
        {
            var viewId = ApplicationView.GetForCurrentView().Id;

            if (_viewDict.ContainsKey(viewId))
            {
                return(_viewDict[viewId]);
            }
            else
            {
                var instance = new ShareServices();
                _viewDict.Add(viewId, instance);
                return(instance);
            }
        }
Esempio n. 4
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();
        }