コード例 #1
1
        /// <summary>
        /// Maps data from the media file edit form to the media file object.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        public static void MapFile(HttpRequestBase request, string fieldSuffix, MediaFile file)
        {
            HttpPostedFileBase hpf = request.Files["file" + fieldSuffix];
            string externalfilename = request.Params["externalfile" + fieldSuffix];
            string filename = hpf.ContentLength == 0 ? externalfilename : hpf.FileName;
            file.Title = request.Params["title" + fieldSuffix];
            file.Description = request.Params["description" + fieldSuffix];
            file.SortIndex = ComLib.Extensions.NameValueExtensions.GetOrDefault<int>(request.Params, "SortIndex", file.SortIndex);
            file.IsPublic = true;
            if (file.LastWriteTime == DateTime.MinValue)
                file.LastWriteTime = DateTime.Now;

            // No Content?
            if (hpf.ContentLength == 0 && string.IsNullOrEmpty(externalfilename))
                return;

            // Get the file as a byte[]
            if (hpf.ContentLength > 0)
                file.Contents = ComLib.Web.WebUtils.GetContentOfFileAsBytes(hpf);

            // This will autoset the Name and Extension properties.
            file.FullNameRaw = filename;
            file.Length = hpf.ContentLength;
            
            // Set up the thumbnail.
            if (!file.IsExternalFile && file.IsImage)
                file.ToThumbNail(processLocalFileSystemFile: true);
        }
コード例 #2
0
ファイル: LocalDBImageProvider.cs プロジェクト: nexus49/grado
 public ImageInfo GetImage(MediaFile file)
 {
     DataList<ImageInfo> returnList = ClientDb.GetImages(file.ArtistName, file.AlbumName, true);
     if (returnList.Count == 1)
         return returnList[0];
     else return null;
 }
コード例 #3
0
        public ImageInfo GetImage(MediaFile file)
        {
            ImageInfo returnValue = null;
            ILocalImageProvider localProvider = new LocalDBImageProvider();

            returnValue = localProvider.GetImage(file);

            if (returnValue != null)
                return returnValue;
            else
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    IImageProvider webProvider = new AmazonAssociatesImageProvider();
                    returnValue = webProvider.GetImage(file);

                    if (returnValue != null)
                    {
                        localProvider.StoreImages(file.ArtistName, file.AlbumName, new DataList<ImageInfo>(returnValue));
                        ObjectRepository.RefreshImagesFiles(file.ArtistName, file.AlbumName);
                    }

                });
            }

            if (returnValue == null)
                Logging.Debug(typeof(IImageProviderFactory), String.Format("No Picture found for: {0}, {1}, {2}", file.ArtistName, file.AlbumName, file.fileId));

            return returnValue;
        }
コード例 #4
0
ファイル: FFHelper.cs プロジェクト: yanzichu/FileTools
 public void GetVideoInfo(MediaFile mFile)
 {
     Process p = ExcuteCMD(Program.FFmpegPath, string.Format(@" -i ""{0}""  ", mFile.Path));
     string[] lines = p.StandardError.ReadToEnd().Split(new string[] { "\r\n" }, StringSplitOptions.None);
     foreach (string line in lines)
     {
         if (line.Trim().StartsWith("Duration"))
         {
             string[] paras = line.Split(new char[] { ',' });
             mFile.Duration = paras[0].Replace("Duration:", "").Trim();
         }
         if (line.Trim().StartsWith("Stream"))
         {
             string[] paras = line.Split(new char[] { ',', ' ' });
             for (int i = 0; i < paras.Length; i++)
             {
                 if (paras[i].Contains("Video"))
                 {
                     mFile.VEncode = paras[i + 1].Trim();
                 }
                 if (paras[i].Contains("Audio"))
                 {
                     mFile.AEncode = paras[i + 1].Trim();
                 }
             }
         }
     }
 }
コード例 #5
0
        public void TestSerialization()
        {
            MediaFile mf = new MediaFile ("path", 34000, 25, true, true, "mp4", "h264",
                               "aac", 320, 240, 1.3, null, "Test asset");
            var pd = new ProjectDescription ();
            Utils.CheckSerialization (pd);

            pd.FileSet = new MediaFileSet ();
            pd.FileSet.Add (mf);
            pd.Competition = "Comp";
            pd.Category = "Cat";
            pd.Group = "Group";
            pd.Phase = "Phase";
            pd.Season = "Season";
            pd.LastModified = DateTime.UtcNow.ToUniversalTime ();
            pd.LocalGoals = 1;
            pd.VisitorGoals = 2;
            pd.MatchDate = DateTime.UtcNow.ToUniversalTime ();

            Utils.CheckSerialization (pd);

            ProjectDescription newpd = Utils.SerializeDeserialize (pd);
            Assert.AreEqual (pd.FileSet.First ().FilePath,
                newpd.FileSet.First ().FilePath);
            Assert.AreEqual (pd.Competition, newpd.Competition);
            Assert.AreEqual (pd.Category, newpd.Category);
            Assert.AreEqual (pd.Group, newpd.Group);
            Assert.AreEqual (pd.Phase, newpd.Phase);
            Assert.AreEqual (pd.Season, newpd.Season);
            Assert.AreEqual (pd.LocalGoals, newpd.LocalGoals);
            Assert.AreEqual (pd.VisitorGoals, newpd.VisitorGoals);
            Assert.AreEqual (pd.MatchDate, newpd.MatchDate);
        }
コード例 #6
0
        public ImageInfo GetImage(MediaFile file)
        {
            DataList<ImageInfo> returnList = new DataList<ImageInfo>();
            returnList = getImages(file.ArtistName, file.AlbumName, file.fileId, true);

            if (returnList != null && returnList.Count == 1)
                return returnList[0];
            else return null;
        }
コード例 #7
0
ファイル: Album.cs プロジェクト: nexus49/grado
        public static Int64 CheckAlbumInformations(MediaFile file, Int64 artistId, Transaction tran)
        {
            const String select =
                        "select a.LIBRARY_ID,a.PARENT_ID, b.PROPERTY_VALUE from MEDIA_LIBRARY a " +
                        "inner join MEDIA_LIBRARY_PROPERTY b on a.LIBRARY_ID = b.LIBRARY_ID " +
                        "where a.TYPE_ID = @ML_TYPE_ID and b.TYPE_ID = @TYPE_ID and b.PROPERTY_VALUE = @NAME";

            Int64 returnId;
            if (String.IsNullOrEmpty(file.AlbumName))
            {
                return getUnknownAlbum(tran);
            }
            else
            {
                using (DataReader reader = tran.CallReader(select,
                    Static.Db.NewParameter("@ML_TYPE_ID", MediaLibraryType.Album),
                    Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.Name),
                    Static.Db.NewParameter("@NAME", file.AlbumName)))
                {

                    if (reader.Read())
                    {
                        if (artistId != reader["PARENT_ID"])
                            tran.CallNonQuery(MediaLibrary.UpdateMediaLibrarySql,
                               Static.Db.NewParameter("@LIBRARY_ID", reader["LIBRARY_ID"]),
                               Static.Db.NewParameter("@PARENT_ID", artistId),
                               Static.Db.NewParameter("@MOD_DATE", DateTime.Now));

                        if (!file.AlbumName.Equals((String)reader["PROPERTY_VALUE"], StringComparison.InvariantCultureIgnoreCase))
                            tran.CallNonQuery(MediaLibrary.UpdateMediaLibraryPropertySql,
                                Static.Db.NewParameter("@LIBRARY_ID", reader["LIBRARY_ID"]),
                                Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.Name),
                                Static.Db.NewParameter("@PROPERTY_VALUE", file.AlbumName),
                                Static.Db.NewParameter("@MOD_DATE", DateTime.Now));

                        returnId = reader["LIBRARY_ID"];
                    }
                    else
                    {
                        tran.CallNonQuery(MediaLibrary.InsertMediaLibrarySql,
                            Static.Db.NewParameter("@TYPE_ID", MediaLibraryType.Album),
                            Static.Db.NewParameter("@MOD_DATE", DateTime.Now),
                            Static.Db.NewParameter("@PARENT_ID", artistId));

                        returnId = tran.CallValue(Static.GetIdentityStatement);

                        tran.CallNonQuery(MediaLibrary.InsertMediaLibraryPropertySql,
                            Static.Db.NewParameter("@LIBRARY_ID", returnId),
                            Static.Db.NewParameter("@TYPE_ID", MediaLibraryPropertyType.Name),
                            Static.Db.NewParameter("@PROPERTY_VALUE", file.AlbumName),
                            Static.Db.NewParameter("@MOD_DATE", DateTime.Now));
                    }
                }
            }
            return returnId;
        }
コード例 #8
0
ファイル: CameraObject.cs プロジェクト: GNOME/longomatch
        public CameraObject(MediaFile mf)
            : base(new TimeNode { Start = new Time (-mf.Offset.MSeconds),
				Stop = mf.Duration - mf.Offset, Name = mf.Name
			})
        {
            mediaFile = mf;
            // Video boundaries can't be changed, only the segment can move.
            DraggingMode = NodeDraggingMode.Segment;
            SelectionMode = NodeSelectionMode.Segment;
            StrictClipping = false;
        }
コード例 #9
0
ファイル: TimelineObject.cs プロジェクト: GNOME/longomatch
        public CameraTimeline(MediaFile mediaFile, bool showName, bool showLine,
		                       Time maxTime, double offsetY, Color background, Color lineColor)
            : base(maxTime, StyleConf.TimelineCameraHeight, offsetY, background)
        {
            ShowName = showName;
            ShowLine = showLine;
            LineColor = lineColor;
            Height = StyleConf.TimelineCameraHeight;

            AddMediaFile (mediaFile);
        }
コード例 #10
0
        private void m_btnPlay_Click(object sender, EventArgs e)
        {
            MediaFile file = new MediaFile(m_txtPath.Text);

            foreach (DecoderStream stream in file.Streams)
            {
                VideoDecoderStream videoStream = stream as VideoDecoderStream;
                if (videoStream != null)
                    m_videoSurface.Stream = new VideoScalingStream(videoStream, 720,  576, PixelFormat.PIX_FMT_RGB32);
            }
        }
コード例 #11
0
ファイル: VideoFile.cs プロジェクト: nkasozi/Nkujukira
        public VideoFile(int id, string file_name)
        {
            this.id                  = id;
            this.file_name           = file_name;
            this.video_capture       = new Capture(file_name);

            //GET PROPERTIES OF THE VIDEO FILE
            MediaFile video_properties = new MediaFile(file_name);
            video_length_in_millisecs = video_properties.General.DurationMillis;
            video_length_string = video_properties.General.DurationString;
        }
コード例 #12
0
 public CollidingFiles(MediaFile ie1, MediaFile ie2)
 {
     InitializeComponent();
     this.ie1 = ie1;
     this.ie2 = ie2;
     label2.Text = ie1.FilePath.Path + Path.DirectorySeparatorChar + ie1.Filename;
     label4.Text = ie1.GetFormattedFullDestination();
     if (!ie2.ProcessingRequested)
     {
         btnSkipSecond.Enabled = false;
     }
 }
コード例 #13
0
 public void CanSetupInternalFileSystemFile()
 {
     var mediafile = new MediaFile();
     mediafile.Contents = new byte[] { }; 
     mediafile.FullNameRaw = "/content/media/photos/my_user_profile.jpg";
     Assert.IsFalse(mediafile.IsExternalFile);
     Assert.AreEqual(mediafile.FullName, "/content/media/photos/my_user_profile.jpg");
     Assert.AreEqual(mediafile.Name, "my_user_profile.jpg");
     Assert.AreEqual(mediafile.Extension, ".jpg");
     mediafile.Id = 1234;
     Assert.AreEqual(mediafile.AbsoluteUrl, "/content/media/photos/my_user_profile.jpg");
 }
コード例 #14
0
ファイル: TimelineObject.cs プロジェクト: GNOME/longomatch
 public void AddMediaFile(MediaFile mediaFile)
 {
     CameraObject co = new CameraObject (mediaFile);
     co.OffsetY = OffsetY;
     co.Height = Height;
     co.SecondsPerPixel = SecondsPerPixel;
     co.DraggingMode = NodeDraggingMode.Segment;
     co.MaxTime = maxTime;
     co.ShowName = ShowName;
     co.LineColor = LineColor;
     AddNode (co);
 }
コード例 #15
0
ファイル: TestMediaFile.cs プロジェクト: GNOME/longomatch
 public void TestExists()
 {
     string path = Path.GetTempFileName ();
     MediaFile mf = new MediaFile ();
     try {
         Assert.IsFalse (mf.Exists ());
         mf.FilePath = path;
         Assert.IsTrue (mf.Exists ());
     } finally {
         File.Delete (path);
     }
 }
コード例 #16
0
 private XElement Write(MediaFile item, string nodeName)
 {
     return new XElement(nodeName,
         new XAttribute("Id", item.Id),
         new XAttribute("Name", item.Name),
         new XAttribute("Path", item.Path),
         new XAttribute("LastModified", item.LastModified),
         new XAttribute("Size", item.Size.Bytes),
         new XAttribute("Duration", item.Duration.ToString()),
         new XAttribute("Type", item.MediaFileType.Name),
         _tagConverter.WriteChildren(item.Tags, "Tag")
     );
 }
コード例 #17
0
 public void CanSetupUploadedFile()
 {
     var mediafile = new MediaFile();
     mediafile.Contents = new byte[] { };
     mediafile.FullNameRaw = "my_user_profile.jpg";
     Assert.IsFalse(mediafile.IsExternalFile);
     Assert.AreEqual(mediafile.FullName, "my_user_profile.jpg");
     Assert.AreEqual(mediafile.Name, "my_user_profile.jpg");
     Assert.AreEqual(mediafile.Extension, ".jpg");
     Assert.IsTrue(mediafile.IsImage);
     mediafile.Id = 1234;
     Assert.AreEqual(mediafile.AbsoluteUrl, "/media/1234/my_user_profile.jpg");
 }
コード例 #18
0
ファイル: FormMain.cs プロジェクト: Nicholi/MediaInfoDotNet
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     MediaInfoDotNet.MediaFile mf;
     string selpath = (string)e.Argument;
     backgroundWorker1.ReportProgress(0, "Scanning directory...");
     string[] files = Directory.GetFiles(selpath, "*.*", SearchOption.AllDirectories);
     float progstep = 100.0f / files.Count(); float progress = 0.0f;
     foreach (string file in files) {
         progress += progstep;
         mf = new MediaFile(file);
         if (mf.HasStreams) {
             backgroundWorker1.ReportProgress((int)(progress), mf);
         }
         else {
             backgroundWorker1.ReportProgress((int)(progress), null);
         }
         if (backgroundWorker1.CancellationPending)
             break;
     }
 }
コード例 #19
0
ファイル: TestMediaFile.cs プロジェクト: GNOME/longomatch
        public void TestSerialization()
        {
            MediaFile mf = new MediaFile ("path", 34000, 25, true, true, "mp4", "h264",
                                          "aac", 320, 240, 1.3, null, "Test asset");
            Utils.CheckSerialization (mf);

            MediaFile newmf = Utils.SerializeDeserialize (mf);
            Assert.AreEqual (mf.FilePath, newmf.FilePath);
            Assert.AreEqual (mf.Duration, newmf.Duration);
            Assert.AreEqual (mf.Fps, newmf.Fps);
            Assert.AreEqual (mf.HasAudio, newmf.HasAudio);
            Assert.AreEqual (mf.HasVideo, newmf.HasVideo);
            Assert.AreEqual (mf.Container, newmf.Container);
            Assert.AreEqual (mf.VideoCodec, newmf.VideoCodec);
            Assert.AreEqual (mf.AudioCodec, newmf.AudioCodec);
            Assert.AreEqual (mf.VideoWidth, newmf.VideoWidth);
            Assert.AreEqual (mf.VideoHeight, newmf.VideoHeight);
            Assert.AreEqual (mf.Par, newmf.Par);
            Assert.AreEqual (mf.Offset, new Time (0));
            Assert.AreEqual (mf.Name, newmf.Name);
        }
コード例 #20
0
        public void CanSetupMediaFileAsExternal()
        {
            var mediafile = new MediaFile();
            mediafile.FullNameRaw = "http://www.flickr.com/kishore/my_profile.jpg";
            Assert.IsTrue(mediafile.IsExternalFile);
            Assert.AreEqual(mediafile.FullName, "http://www.flickr.com/kishore/my_profile.jpg");            
            Assert.AreEqual(mediafile.Name, "my_profile.jpg");
            Assert.AreEqual(mediafile.Extension, ".jpg");
            Assert.IsTrue(mediafile.IsImage);
            // Simulate persistance
            mediafile.Id = 1;
            Assert.AreEqual(mediafile.AbsoluteUrl, "http://www.flickr.com/kishore/my_profile.jpg");

            mediafile = new MediaFile();
            mediafile.FullNameRaw = "http://www.flickr.com/kishore/my_profile";
            Assert.IsTrue(mediafile.IsExternalFile);
            Assert.AreEqual(mediafile.FullName, "http://www.flickr.com/kishore/my_profile");
            Assert.AreEqual(mediafile.Name, "my_profile");
            Assert.AreEqual(mediafile.Extension, string.Empty);
            mediafile.Id = 1;
            Assert.AreEqual(mediafile.AbsoluteUrl, "http://www.flickr.com/kishore/my_profile");
        }
コード例 #21
0
 private void reset()
 {
     seriesNameFromDirectory = false;
     name = null;
     ie = null;
     filenameBlacklisted = false;
 }
コード例 #22
0
 /// <summary>
 /// Map a Media File from the Form to an object.
 /// </summary>
 /// <param name="request"></param>
 /// <param name="fieldSuffix"></param>
 /// <returns></returns>
 public static MediaFile MapFile(HttpRequestBase request, string fieldSuffix)
 {
     var file = new MediaFile();
     MapFile(request, fieldSuffix, file);
     return file;
 }
コード例 #23
0
ファイル: TestProject.cs プロジェクト: LongoMatch/longomatch
        ProjectLongoMatch CreateProject(bool fill = true)
        {
            ProjectLongoMatch p = new ProjectLongoMatch ();
            p.Dashboard = DashboardLongoMatch.DefaultTemplate (10);
            p.UpdateEventTypesAndTimers ();
            p.LocalTeamTemplate = SportsTeam.DefaultTemplate (10);
            p.VisitorTeamTemplate = SportsTeam.DefaultTemplate (12);
            MediaFile mf = new MediaFile ("path", 34000, 25, true, true, "mp4", "h264",
                               "aac", 320, 240, 1.3, null, "Test asset");
            var pd = new ProjectDescription ();
            pd.FileSet = new MediaFileSet ();
            pd.FileSet.Add (mf);
            p.Description = pd;
            if (fill) {
                p.AddEvent (p.EventTypes [0], new Time (1000), new Time (2000), null, null);
                p.AddEvent (p.EventTypes [0], new Time (1000), new Time (2000), null, null);
                p.AddEvent (p.EventTypes [1], new Time (1000), new Time (2000), null, null);
                p.AddEvent (p.EventTypes [2], new Time (1000), new Time (2000), null, null);
                p.AddEvent (p.EventTypes [2], new Time (1000), new Time (2000), null, null);
                p.AddEvent (p.EventTypes [2], new Time (1000), new Time (2000), null, null);
                p.AddEvent (p.EventTypes [6], new Time (1000), new Time (2000), null, null);
            }

            return p;
        }
コード例 #24
0
ファイル: Capture.cs プロジェクト: hermwong/phonegap-wp7
        /// <summary>
        /// Handles result of capture to save image information 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">stores inforamation about currrent captured image</param>
        private void cameraTask_Completed(object sender, PhotoResult e)
        {
            if (e.Error != null)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
                return;
            }

            switch (e.TaskResult)
            {
                case TaskResult.OK:
                    try
                    {
                        string fileName = System.IO.Path.GetFileName(e.OriginalFileName);

                        // Save image in media library
                        MediaLibrary library = new MediaLibrary();
                        Picture image = library.SavePicture(fileName, e.ChosenPhoto);

                        // Save image in isolated storage

                        // we should return stream position back after saving stream to media library
                        e.ChosenPhoto.Seek(0, SeekOrigin.Begin);
                        byte[] imageBytes = new byte[e.ChosenPhoto.Length];
                        e.ChosenPhoto.Read(imageBytes, 0, imageBytes.Length);
                        string pathLocalStorage = this.SaveImageToLocalStorage(fileName, isoFolder, imageBytes);

                        // Get image data
                        MediaFile data = new MediaFile(pathLocalStorage, image);

                        this.files.Add(data);

                        if (files.Count < this.captureImageOptions.limit)
                        {
                            cameraTask.Show();
                        }
                        else
                        {
                            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files, "navigator.device.capture._castMediaFile"));
                            files.Clear();
                        }
                    }
                    catch(Exception ex)
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR,"Error capturing image."));
                    }
                    break;

                case TaskResult.Cancel:
                    if (files.Count > 0)
                    {
                        // User canceled operation, but some images were made
                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files, "navigator.device.capture._castMediaFile"));
                        files.Clear();
                    }
                    else
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Canceled."));
                    }
                    break;

                default:
                    if (files.Count > 0)
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files, "navigator.device.capture._castMediaFile"));
                        files.Clear();
                    }
                    else
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Did not complete!"));
                    }
                    break;
            }
        }
コード例 #25
0
ファイル: Capture.cs プロジェクト: rknalakurthi/phonegap
        /// <summary>
        /// Handles result of video recording tasks 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">stores information about current captured video</param>
        private void videoRecordingTask_Completed(object sender, VideoResult e)
        {
            if (e.Error != null)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
                return;
            }

            switch (e.TaskResult)
            {
                case TaskResult.OK:
                    try
                    {
                        // Get image data
                        MediaFile data = new MediaFile(e.VideoFileName, e.VideoFile);

                        this.files.Add(data);

                        if (files.Count < this.captureVideoOptions.Limit)
                        {
                            videoCaptureTask.Show();
                        }
                        else
                        {
                            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
                            files.Clear();
                        }
                    }
                    catch (Exception)
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error capturing video."));
                    }
                    break;

                case TaskResult.Cancel:
                    if (files.Count > 0)
                    {
                        // User canceled operation, but some video clips were made
                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
                        files.Clear();
                    }
                    else
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Canceled."));
                    }
                    break;

                default:
                    if (files.Count > 0)
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
                        files.Clear();
                    }
                    else
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Did not complete!"));
                    }
                    break;
            }
        }
コード例 #26
0
 void HandleCameraDragged(MediaFile mediafile, TimeNode timenode)
 {
     // Start by pausing players
     Pause ();
     // And update
     HandleCameraUpdate (camerasTimeline.SelectedCamera);
 }
コード例 #27
0
        /// <summary>
        /// Handles result of capture to save image information 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">stores information about current captured image</param>
        private void cameraTask_Completed(object sender, PhotoResult e)
        {

            if (e.Error != null)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
                return;
            }

            switch (e.TaskResult)
            {
                case TaskResult.OK:
                    try
                    {
                        string fileName = System.IO.Path.GetFileName(e.OriginalFileName);

                        // Save image in media library
                        MediaLibrary library = new MediaLibrary();
                        Picture image = library.SavePicture(fileName, e.ChosenPhoto);

                        int orient = ImageExifHelper.getImageOrientationFromStream(e.ChosenPhoto);
                        int newAngle = 0;
                        switch (orient)
                        {
                            case ImageExifOrientation.LandscapeLeft:
                                newAngle = 90;
                                break;
                            case ImageExifOrientation.PortraitUpsideDown:
                                newAngle = 180;
                                break;
                            case ImageExifOrientation.LandscapeRight:
                                newAngle = 270;
                                break;
                            case ImageExifOrientation.Portrait:
                            default: break; // 0 default already set
                        }

                        Stream rotImageStream = ImageExifHelper.RotateStream(e.ChosenPhoto, newAngle);

                        // Save image in isolated storage    

                        // we should return stream position back after saving stream to media library
                        rotImageStream.Seek(0, SeekOrigin.Begin);

                        byte[] imageBytes = new byte[rotImageStream.Length];
                        rotImageStream.Read(imageBytes, 0, imageBytes.Length);
                        rotImageStream.Dispose();
                        string pathLocalStorage = this.SaveImageToLocalStorage(fileName, isoFolder, imageBytes);
                        imageBytes = null;
                        // Get image data
                        MediaFile data = new MediaFile(pathLocalStorage, image);

                        this.files.Add(data);

                        if (files.Count < this.captureImageOptions.Limit)
                        {
                            cameraTask.Show();
                        }
                        else
                        {
                            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
                            files.Clear();
                        }
                    }
                    catch (Exception)
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error capturing image."));
                    }
                    break;

                case TaskResult.Cancel:
                    if (files.Count > 0)
                    {
                        // User canceled operation, but some images were made
                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
                        files.Clear();
                    }
                    else
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Canceled."));
                    }
                    break;

                default:
                    if (files.Count > 0)
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
                        files.Clear();
                    }
                    else
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Did not complete!"));
                    }
                    break;
            }
        }
コード例 #28
0
 public ThumbnailGeneratedEventArgs(MediaFile file, int index, int totalFiles)
 {
     File = file;
     Index = index;
     TotalFiles = totalFiles;
 }
コード例 #29
0
 public string ExtractSeriesName(MediaFile ie)
 {
     reset();
     this.ie = ie;
     // Read plain configurationFilePath
     string filename = System.IO.Path.GetFileNameWithoutExtension(ie.Filename);
     filename = NameCleanup.RemoveReleaseGroupTag(filename);
     folders = Filepath.extractFoldernamesFromPath(ie.FilePath.Path);
     if (ie.inSeasonFolder() && folders.Length > 2)
     {
         if (!Regex.IsMatch(folders[folders.Length - 2], pathBlacklist, RegexOptions.IgnoreCase))
         {
             return folders[folders.Length - 2];
         }
     }
     extractNameFromSeasonsFolder();
     extractNameFromString(filename);
     if (folders.Length != 0) {
         extractNameFromString(folders[folders.Length - 1]);
     }
     fallbackFolderNames();
     name=NameCleanup.Postprocessing(name);
     if (name == null) return "";
     return name;
 }
コード例 #30
0
        void AppendFile(MediaFile file)
        {
            HBox box;
            Button delButton;
            Gtk.Image delImage;
            VideoFileInfo fileinfo;

            if (file == null)
                return;
            Files.Add (file);
            box = new HBox ();
            delButton = new Button ();
            delButton.Relief = ReliefStyle.None;
            delButton.CanFocus = false;
            delImage = new Gtk.Image ("gtk-remove", IconSize.Button);
            delButton.Add (delImage);
            delButton.Clicked += (object sender, EventArgs e) => {
                filesbox.Remove (box);
                Files.Remove (file);
                CheckStatus ();
            };
            fileinfo = new VideoFileInfo ();
            fileinfo.SetMediaFile (file);
            box.PackStart (fileinfo, true, true, 0);
            box.PackStart (delButton, false, false, 0);
            box.ShowAll ();
            filesbox.PackStart (box, false, true, 0);
        }