资源简介
使用AForge类库的视频播放C#例子,这个小工具使用AForge类库实现C# 操作摄像头, 代码超级简捷。
代码片段和文件信息
// Simple Player sample application
// AForge.NET framework
// http://www.aforgenet.com/framework/
//
// Copyright © AForge.NET 2006-2011
// contacts@aforgenet.com
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using AForge.Video;
using AForge.Video.DirectShow;
namespace Player
{
public partial class MainForm : Form
{
private Stopwatch stopWatch = null;
// Class constructor
public MainForm( )
{
InitializeComponent( );
}
private void MainForm_FormClosing( object sender FormClosingEventArgs e )
{
CloseCurrentVideoSource( );
}
// “Exit“ menu item clicked
private void exitToolStripMenuItem_Click( object sender EventArgs e )
{
this.Close( );
}
// Open local video capture device
private void localVideoCaptureDeviceToolStripMenuItem_Click( object sender EventArgs e )
{
VideoCaptureDeviceForm form = new VideoCaptureDeviceForm( );
if ( form.ShowDialog( this ) == DialogResult.OK )
{
// create video source
VideoCaptureDevice videoSource = form.VideoDevice;
// open it
OpenVideoSource( videoSource );
}
}
// Open video file using DirectShow
private void openVideofileusingDirectShowToolStripMenuItem_Click( object sender EventArgs e )
{
if ( openFileDialog.ShowDialog( ) == DialogResult.OK )
{
// create video source
FileVideoSource fileSource = new FileVideoSource( openFileDialog.FileName );
// open it
OpenVideoSource( fileSource );
}
}
// Open JPEG URL
private void openJPEGURLToolStripMenuItem_Click( object sender EventArgs e )
{
URLForm form = new URLForm( );
form.Description = “Enter URL of an updating JPEG from a web camera:“;
form.URLs = new string[]
{
“http://195.243.185.195/axis-cgi/jpg/image.cgi?camera=1“
};
if ( form.ShowDialog( this ) == DialogResult.OK )
{
// create video source
JPEGStream jpegSource = new JPEGStream( form.URL );
// open it
OpenVideoSource( jpegSource );
}
}
// Open MJPEG URL
private void openMJPEGURLToolStripMenuItem_Click( object sender EventArgs e )
{
URLForm form = new URLForm( );
form.Description = “Enter URL of an MJPEG video stream:“;
form.URLs = new string[]
{
“http://195.243.185.195/axis-cgi/mjpg/video.cgi?
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-12-18 12:06 AForge_Pla
文件 6133 2011-08-22 23:03 AForge_Pla
文件 10749 2008-10-03 12:44 AForge_Pla
文件 6612 2008-09-11 06:09 AForge_Pla
文件 6332 2011-11-24 20:40 AForge_Pla
文件 905 2011-11-24 20:40 AForge_Pla
文件 488 2008-09-06 09:45 AForge_Pla
目录 0 2012-12-18 12:06 AForge_Pla
文件 1467 2010-07-29 09:42 AForge_Pla
文件 2860 2008-09-06 09:45 AForge_Pla
文件 5612 2008-09-06 09:45 AForge_Pla
文件 1102 2008-09-06 09:45 AForge_Pla
文件 249 2008-09-06 09:45 AForge_Pla
文件 1196 2008-10-03 12:44 AForge_Pla
文件 4302 2008-10-03 12:44 AForge_Pla
文件 5814 2008-10-03 12:44 AForge_Pla
评论
共有 条评论