public async static Task <AbMediaContent> takePicture(Card card, Page parentPage) { //NOTE: must set compile using to "Android 6" and target android version 6 //Otherwise a null pointer error occurs when using Android 7.1 ... await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await parentPage.DisplayAlert("No Camera", ":( No camera available.", "OK"); return(null); } var file = await CrossMedia.Current.TakePhotoAsync( new Plugin.Media.Abstractions.StoreCameraMediaOptions { Name = $@"{Guid.NewGuid()}.jpg", #if __IOS__ Directory = "Pictures", #endif SaveToAlbum = false } ); if (file == null) { return(null); } ImageMediaContent newMedia = new ImageMediaContent(file.Path); card?.addMedia(newMedia); MediaManager.addNewMedia(newMedia); return(newMedia); }
public async static Task <AbMediaContent> takeVideo(Card card, Page parentPage) { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakeVideoSupported) { await parentPage.DisplayAlert("No Camera", ":( No camera for video available.", "OK"); return(null); } var file = await CrossMedia.Current.TakeVideoAsync( new Plugin.Media.Abstractions.StoreVideoOptions { Name = $@"{Guid.NewGuid()}.mp4", #if __IOS__ Directory = "Movies", #endif SaveToAlbum = false } ); if (file == null) { return(null); } await VideoThumbnailHelper.createVideoThumbnailAsync(file.Path); VideoMediaContent newMedia = new VideoMediaContent(file.Path); card?.addMedia(newMedia); MediaManager.addNewMedia(newMedia); return(newMedia); }
/// <summary> /// Must be called in starting activity! /// </summary> public async static Task initializeAsync() { await FilePaths.initFoldersAsync(); allCardsDict = new Dictionary <string, Card>(); //Read in and deserialize all JSON file cards List <Card> allCards = await JSONSerialManager.deserializeDirAsync <Card>(FilePaths.allCardsDir); foreach (Card card in allCards) { //NOTE: exception handling for messed up serialization leading to null writes if (card != null) { allCardsDict.Add(card.name, card); } } //Read in all MEDIA await MediaManager.initializeAsync(); //FirebaseDownloadManager downloadManager = new FirebaseDownloadManager(); //downloadManager.initialize(); }
private async static Task <List <AbMediaContent> > readMediaSortAsync() { List <AbMediaContent> allReadMedia; allReadMedia = await MediaManager.deserializeMediaFilesAsync(FilePaths.allImagesDir); allReadMedia.AddRange(await MediaManager.deserializeMediaFilesAsync(FilePaths.allVideosDir)); allReadMedia.AddRange(await MediaManager.deserializeMediaFilesAsync(FilePaths.allAudiosDir)); allReadMedia.AddRange(await MediaManager.deserializeMediaFilesAsync(FilePaths.allNotesDir)); allReadMedia.AddRange(await MediaManager.deserializeContactFilesAsyc(FilePaths.allContactsDir)); //UserGalleryLoadManager galleryLoadManager = new UserGalleryLoadManager(); //allReadMedia.AddRange(galleryLoadManager.loadImages()); allReadMedia.Sort(new CardItemDateComparer <AbMediaContent>(true)); return(allReadMedia); }