protected override async void LoadState(object param, Dictionary <string, object> pageState) { base.LoadState(param, pageState); int id = (int)param; VideoDataItem item = VideoDataSource.GetItem(id); if (item != null) { OpenFile(item.File); } else if (pageState["fileToken"] != null) { StorageItemAccessList future = StorageApplicationPermissions.FutureAccessList; StorageFile file = await future.GetFileAsync(pageState["fileToken"] as string); future.Clear(); OpenFile(file); } if (pageState != null) { MediaPlayerState state = pageState["MediaState"] as MediaPlayerState; if (state != null) { MediaPlayer.RestorePlayerState(state); } } }
async void GetProfilePicAsync() { string profilePicPlaceholderPath = "ms-appx:///Assets/StoreLogo.scale-400.png"; ProfilePic = new BitmapImage(new Uri(profilePicPlaceholderPath)); ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; if (localSettings.Values["PerformerImageFolder"] is string token) { StorageItemAccessList futureAccessList = StorageApplicationPermissions.FutureAccessList; StorageFolder profilePicFolder = await futureAccessList.GetFolderAsync(token); List <string> fileTypeFilter = new List <string> { ".jpg" }; var queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, fileTypeFilter) { ApplicationSearchFilter = "System.FileName:*\"" + Name + "\"*" }; StorageFileQueryResult queryResult = profilePicFolder.CreateFileQueryWithOptions(queryOptions); var files = await queryResult.GetFilesAsync(); if (files.Count > 0) { BitmapImage screen = new BitmapImage(); screen.SetSource(await files[0].GetThumbnailAsync(ThumbnailMode.SingleItem)); ProfilePic = screen; } } }
private async Task AddBackgroundAudioTrack() { var picker = new FileOpenPicker(); picker.SuggestedStartLocation = PickerLocationId.MusicLibrary; picker.FileTypeFilter.Add(".mp3"); picker.FileTypeFilter.Add(".wav"); picker.FileTypeFilter.Add(".flac"); StorageFile audioFile = await picker.PickSingleFileAsync(); if (audioFile != null) { StorageItemAccessList storageItemAccessList = StorageApplicationPermissions.FutureAccessList; storageItemAccessList.Add(audioFile); BackgroundAudioTrack backgroundTrack = await BackgroundAudioTrack.CreateFromFileAsync(audioFile); App.Model.MediaComposition.BackgroundAudioTracks.Add(backgroundTrack); //裁剪,防止播出 if (backgroundTrack.TrimmedDuration > App.Model.MediaComposition.Duration) { backgroundTrack.Delay = TimeSpan.Zero; backgroundTrack.TrimTimeFromEnd = App.Model.MediaComposition.Duration - backgroundTrack.TrimmedDuration; } } else { App.Tip("File picking cancelled"); } }
private async void AddPicturesButton_Tapped(object sender, TappedRoutedEventArgs e) { FileOpenPicker filePicker = new FileOpenPicker { SuggestedStartLocation = PickerLocationId.PicturesLibrary }; filePicker.FileTypeFilter.Add(".jpg"); filePicker.FileTypeFilter.Add(".jpeg"); filePicker.FileTypeFilter.Add(".png"); filePicker.FileTypeFilter.Add(".bmp"); filePicker.FileTypeFilter.Add(".gif"); filePicker.FileTypeFilter.Add(".tiff"); filePicker.ViewMode = PickerViewMode.Thumbnail; StorageFile file = await filePicker.PickSingleFileAsync(); if (file != null) { try { StorageItemAccessList storageItemAccessList = StorageApplicationPermissions.FutureAccessList; storageItemAccessList.Add(file); //新建媒体 Media media = new Media(); //缩略图 using (StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(ThumbnailMode.PicturesView)) { if (thumbnail != null) { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.SetSource(thumbnail); media.Bitmap = bitmapImage; } } //从文件创建媒体剪辑 MediaClip clip = await MediaClip.CreateFromImageFileAsync(file, new TimeSpan(24, 1, 0)); clip.TrimTimeFromEnd = clip.TrimTimeFromStart = new TimeSpan(12, 0, 0); media.Clip = clip; //从颜色创建名称 media.Name = file.Name; MediaClipList.Add(media); SplitShowMethod();// SplitView:侧栏 } catch (Exception) { App.Tip("file err"); } } else { App.Tip("file null"); } }
protected override void OnNavigatedTo(NavigationEventArgs e) //当本页面成为框架中的活动页时调用 { //确保我们不会耗尽StoreItemAccessList条目 //当我们不需要坚持这个跨应用程序会话页 //每次结算应该足够。 storageItemAccessList = StorageApplicationPermissions.FutureAccessList; storageItemAccessList.Clear(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { // Make sure we don't run out of entries in StoreItemAccessList. // As we don't need to persist this across app sessions/pages // every time should be sufficient for us. storageItemAccessList = StorageApplicationPermissions.FutureAccessList; storageItemAccessList.Clear(); }
public RegisteredDbsService(IEventAggregator events) { if (events == null) { throw new ArgumentNullException("events"); } _events = events; _accessList = StorageApplicationPermissions.FutureAccessList; var localFolder = ApplicationData.Current.LocalFolder; _cacheFolder = localFolder.CreateFolderAsync( "Databases", CreationCollisionOption.OpenIfExists); }
protected override void SaveState(Dictionary <string, object> pageState) { MediaPlayerState state = MediaPlayer.GetPlayerState(); StorageItemAccessList future = StorageApplicationPermissions.FutureAccessList; future.Clear(); string token = future.Add(file); pageState.Add("MediaState", state); pageState.Add("fileToken", token); base.SaveState(pageState); if (teardown) { MediaPlayer.Dispose(); } }
public static string Enqueue(this StorageItemAccessList list, IStorageItem item) { if (list.MaximumItemsAllowed - 10 >= list.Entries.Count) { var first = list.Entries.FirstOrDefault(); var token = first.Token; list.Remove(token); } try { return(list.Add(item)); } catch { return(null); } }
public static string Enqueue(this StorageItemAccessList list, IStorageItem item) { try { if (list.Entries.Count >= list.MaximumItemsAllowed - 10) { var first = list.Entries.LastOrDefault(); if (first.Token != null) { list.Remove(first.Token); } } } catch { } try { return(list.Add(item)); } catch { return(null); } }
public FutureService() { _future = StorageApplicationPermissions.FutureAccessList; }
public FileDatabaseTracker() { _folder = ApplicationData.Current.LocalFolder.CreateFolderAsync("opened_databases", CreationCollisionOption.OpenIfExists); _accessList = StorageApplicationPermissions.FutureAccessList; }
private async void AddMusicButton_Tapped(object sender, TappedRoutedEventArgs e) { FileOpenPicker filePicker = new FileOpenPicker { SuggestedStartLocation = PickerLocationId.MusicLibrary }; filePicker.FileTypeFilter.Add(".mp3"); filePicker.FileTypeFilter.Add(".wma"); filePicker.FileTypeFilter.Add(".wav"); filePicker.FileTypeFilter.Add(".asf"); //微软的格式 filePicker.FileTypeFilter.Add(".ogg"); //开源的格式 filePicker.FileTypeFilter.Add(".flac"); //开源的格式 filePicker.FileTypeFilter.Add(".aac"); filePicker.ViewMode = PickerViewMode.Thumbnail; StorageFile file = await filePicker.PickSingleFileAsync(); if (file != null) { try { StorageItemAccessList storageItemAccessList = StorageApplicationPermissions.FutureAccessList; storageItemAccessList.Add(file); //新建媒体 Media media = new Media(); //缩略图 using (StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(ThumbnailMode.MusicView)) { if (thumbnail != null) { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.SetSource(thumbnail); media.Bitmap = bitmapImage; } } //从文件创建媒体剪辑 MediaClip clip = await MediaClip.CreateFromFileAsync(file); media.Clip = clip; //从颜色创建名称 media.Name = file.Name; MediaClipList.Add(media); SplitShowMethod();// SplitView:侧栏 } catch (Exception) { App.Tip("file err"); } } else { App.Tip("file null"); } }