/// <summary> /// Retrieves the format information of the media file. /// </summary> /// <param name="options"></param> public void getFormatData(string options) { try { MediaFormatOptions mediaFormatOptions; try { mediaFormatOptions = new MediaFormatOptions(); string[] optionStrings = JSON.JsonHelper.Deserialize <string[]>(options); mediaFormatOptions.FullPath = optionStrings[0]; mediaFormatOptions.Type = optionStrings[1]; } catch (Exception ex) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message)); return; } if (string.IsNullOrEmpty(mediaFormatOptions.FullPath)) { DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); } string mimeType = mediaFormatOptions.Type; if (string.IsNullOrEmpty(mimeType)) { mimeType = MimeTypeMapper.GetMimeType(mediaFormatOptions.FullPath); } if (mimeType.Equals("image/jpeg")) { Deployment.Current.Dispatcher.BeginInvoke(() => { WriteableBitmap image = ExtractImageFromLocalStorage(mediaFormatOptions.FullPath); if (image == null) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "File not found")); return; } MediaFileData mediaData = new MediaFileData(image); DispatchCommandResult(new PluginResult(PluginResult.Status.OK, mediaData)); }); } else { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR)); } } catch (Exception) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR)); } }
public MediaFile(string filePath, Stream stream) { this.FilePath = filePath; this.FileName = System.IO.Path.GetFileName(this.FilePath); this.Type = MimeTypeMapper.GetMimeType(FileName); this.Size = stream.Length; using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) { this.LastModifiedDate = storage.GetLastWriteTime(filePath).DateTime.ToString(); } }