Exemple #1
0
        /// <summary>
        /// Retrieves the format information of the media file.
        /// </summary>
        /// <param name="options"></param>
        public void getFormatData(string options)
        {
            if (String.IsNullOrEmpty(options))
            {
                this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
                return;
            }

            try
            {
                MediaFormatOptions mediaFormatOptions;
                try
                {
                    mediaFormatOptions = JSON.JsonHelper.Deserialize <MediaFormatOptions>(options);
                }
                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"))
                {
                    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));
            }
        }
Exemple #2
0
            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();
                }
            }