Beispiel #1
0
        public bool playFile(string filename)
        {
            //using (Stream fin = File.OpenRead(filename))
            using (Stream fin = new MemoryStream(File.ReadAllBytes(filename)))
                using (FrameDecoder FrameDecoder = new FrameDecoder(fin))
                {
                    try
                    {
                        while (true)
                        {
                            var picture = FrameDecoder.DecodeFrame();

                            var Width  = picture.imageWidthWOEdge;
                            var Height = picture.imageHeightWOEdge;

                            if (frame.ClientSize.Width < Width || frame.ClientSize.Height < Height)
                            {
                                frame.Invoke((Action)(() =>
                                {
                                    frame.ClientSize = new Size(Width, Height);
                                    CenterForm(frame);
                                }));
                            }
                            frame.CreateGraphics().DrawImage(picture.ToImageWOEdges(Width, Height), Point.Empty);
                        }
                    }
                    catch (EndOfStreamException)
                    {
                    }
                }

            Console.WriteLine("Stop playing video.");

            return(true);
        }
Beispiel #2
0
        private void TestItem(string fixtureName, string videoName)
        {
            var RemotePath = BaseUrl + videoName;
            var LocalPath = Directory.GetCurrentDirectory() + "/../../Cache/" + videoName;
            try { Directory.CreateDirectory(Path.GetDirectoryName(LocalPath)); } catch { }
            if (!File.Exists(LocalPath)) new WebClient().DownloadFile(RemotePath, LocalPath);

            var FrameDecoder = new FrameDecoder(File.OpenRead(LocalPath));
            var Index = 0;
            while (FrameDecoder.HasMorePackets)
            {
                //var Packet = FrameDecoder._ReadPacket();
                //Console.WriteLine("{0}: {1}", Index, FrameCrc.GetFrameLine(Packet));
                var Frame = FrameDecoder.DecodeFrame();
                var Image = FrameUtils.imageFromFrame(Frame);
                Console.WriteLine("{0}: {1}, {2}, {3}", Index, Frame.pkt_dts, Frame.pkt_pts, Frame.imageWidthWOEdge * Frame.imageHeightWOEdge);
                Index++;
            }
        }
Beispiel #3
0
        public bool playFile(string filename)
        {
            //using (Stream fin = File.OpenRead(filename))
            using (Stream fin = new MemoryStream(File.ReadAllBytes(filename)))
            using (FrameDecoder FrameDecoder = new FrameDecoder(fin))
            {
                try
                {
                    while (true)
                    {
                        var picture = FrameDecoder.DecodeFrame();

                        var Width = picture.imageWidthWOEdge;
                        var Height = picture.imageHeightWOEdge;

                        if (frame.ClientSize.Width < Width || frame.ClientSize.Height < Height)
                        {
                            frame.Invoke((Action)(() =>
                            {
                                frame.ClientSize = new Size(Width, Height);
                                CenterForm(frame);
                            }));
                        }
                        frame.CreateGraphics().DrawImage(picture.ToImageWOEdges(Width, Height), Point.Empty);
                    }
                }
                catch (EndOfStreamException)
                {
                }
            }

            Console.WriteLine("Stop playing video.");

            return true;
        }