Example #1
0
        /// <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));
            }
        }
        /// <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));
            }
        }