csharp: Flash Player play *.flv file in winform
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Xml;
using AxShockwaveFlashObjects; /*
* VS2005在添加Shockwave时很多人都碰到一个这个问题,就是会说ActiveX注册失败
* 先要用Regsvr32来注册ActiveX(运行:Regsvr32 控件名)-u为卸载参数
* Regsvr32 C:\WINDOWS\system32\Macromed\Flash\Flash32_18_0_0_203.ocx -u
* Regsvr32 C:\WINDOWS\system32\Macromed\Flash\Flash32_18_0_0_203.ocx
* 在VS2005下项目-属性-生成-目标平台改为x86
在选择生成-清理解决方案与重新生成解决方案直到资源管理器的引用下的AxShochwaveFlashObj的黄色感叹号消失
*/
namespace AdobeFlashPlayDemo
{ /// <summary>
/// http://www.codeproject.com/Articles/12010/Fun-with-C-and-the-Flash-Player-External-API
/// http://www.codeproject.com/Articles/10863/Flash-and-NET-with-FlashRemoting
/// http://www.codeproject.com/Articles/15742/Multiple-File-Upload-With-Progress-Bar-Using-Flash
/// http://www.codeproject.com/Articles/12928/Flash-GUI-for-Your-EXE-Using-Minimalistic-Approach
/// </summary>
public partial class FLVPlayer : Form
{
// private StatusBarPanel fileNameStatusBarPanel; /// <summary>
///
/// </summary>
public FLVPlayer()
{
InitializeComponent(); //this.fileNameStatusBarPanel = new System.Windows.Forms.StatusBarPanel();
try
{
axShockwaveFlash1.LoadMovie(0, Application.StartupPath + "\\player.swf");
axShockwaveFlash1.FlashCall += new _IShockwaveFlashEvents_FlashCallEventHandler(flashPlayer_FlashCall);
}
catch (Exception ex)
{
ExceptionUtilities.DisplayException("Unable to load SWF video player, please verify you have Flash Player 8 installed and try again.");
this.Dispose();
}
}
/// <summary>
///
/// </summary>
/// <param name="moviePath"></param>
public FLVPlayer(string moviePath)
: this()
{
this.LoadVideo(moviePath);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_Load(object sender, EventArgs e)
{ }
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
openVideoDialog = new OpenFileDialog();
openVideoDialog.Filter = "*.flv|*.flv";
openVideoDialog.Title = "Select a Flash Video file...";
openVideoDialog.Multiselect = false;
openVideoDialog.RestoreDirectory = true; if (openVideoDialog.ShowDialog() == DialogResult.OK)
{
LoadVideo(openVideoDialog.FileName);
}
}
/// <summary>
///
/// </summary>
/// <param name="videoPath"></param>
private void LoadVideo(string videoPath)
{
fileNameStatusBarPanel.Text = videoPath;
axShockwaveFlash1.CallFunction("<invoke name=\"loadAndPlayVideo\" returntype=\"xml\"><arguments><string>" + videoPath + "</string></arguments></invoke>");
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FLVPlayer_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (fileNameStatusBarPanel.Text != files[0])
{
LoadVideo(files[0]);
}
} /// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FLVPlayer_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
{
e.Effect = DragDropEffects.All;
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FLVPlayer_DragLeave(object sender, EventArgs e)
{ }
/// <summary>
///
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
public void ResizePlayer(int width, int height)
{
axShockwaveFlash1.Width = width;
axShockwaveFlash1.Height = height;
videoPlaceholder.Width = width;
videoPlaceholder.Height = height;
} private void flashPlayer_FlashCall(object sender, _IShockwaveFlashEvents_FlashCallEvent e)
{
XmlDocument document = new XmlDocument();
document.LoadXml(e.request); // Since I have only one call back I just grab the arguments and call
// the function. This needs to be made much more flexible when there are
// multiple call backs going back and forth
XmlNodeList list = document.GetElementsByTagName("arguments");
ResizePlayer(Convert.ToInt32(list[0].FirstChild.InnerText), Convert.ToInt32(list[0].ChildNodes[1].InnerText));
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void axShockwaveFlash1_FlashCall(object sender, _IShockwaveFlashEvents_FlashCallEvent e)
{
XmlDocument document = new XmlDocument();
document.LoadXml(e.request); // Since I have only one call back I just grab the arguments and call
// the function. This needs to be made much more flexible when there are
// multiple call backs going back and forth
XmlNodeList list = document.GetElementsByTagName("arguments");
ResizePlayer(Convert.ToInt32(list[0].FirstChild.InnerText), Convert.ToInt32(list[0].ChildNodes[1].InnerText));
} private void axShockwaveFlash1_Enter(object sender, EventArgs e)
{ } }
}
csharp: Flash Player play *.flv file in winform的更多相关文章
- ubuntu下chromium 安装flash player
原文地址 :http://blog.sina.com.cn/s/blog_858820890102v63w.html 不记得从什么时候起,Chromium 不再支持 Netscape plugin A ...
- Flash cc 添加目标Flash Player
原文出处:http://zengrong.net/post/1568.htm 第一步 首先下载最新的 playerglobal.swc(基于Flash Player11): http://www.ad ...
- Ubuntu14.04下安装Flash Player
Ubuntu14.04下安装Flash Player youhaidong@youhaidong:~$ sudo apt-get install flashplugin-nonfree [sudo] ...
- 让旧版本的 Flash IDE 支持更新的 Flash Player/AIR 功能
转载:https://blog.zengrong.net/post/1568.html 让旧版本的 Flash IDE 支持更新的 Flash Player/AIR 功能 今天在论坛上看到一篇文章:H ...
- linux下为firfox安装flash player
1.去官网下载×.tar.gz包,如:flash_player_npapi_linux.x86_64.tar.gz 2.解压 tar -zxvf flash_player_npapi_linux.x8 ...
- Flash Player的终章——赠予它的挽歌
本文由葡萄城技术团队原创并首发 转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 12月28日消息,微软已经确认Windows 10在下一次更新时将自动删除F ...
- 解决浏览器Adobe Flash Player不是最新版本问题
关键:选择谷歌浏览器的PPAPI版本的flash下载直接安装即可 搜索: Adobe Flash Player PPAPI 下载地址: http://www.wmzhe.com/soft-30259. ...
- [转]Flash Player、AIR、Flex SDK 大全
平时不断看到有朋友在各种论坛.空间.知道.群里求 Flash 平台各种版本的运行时(Flash Player)和SDK(Flex.AIR).今天就看到不下10次!所以决定把 Macromedia.Ad ...
- chrome 'adobe flash player 已过期'解决方法
http://labs.adobe.com/downloads/flashplayer.html下载 WindowsDownload Flash Player for Opera and Chromi ...
随机推荐
- 私服 Nexus 的配置
一.概述 1.概要 现在的项目基本都是用Maven来管理工程,这样一来在公司内容搭建一个私服就非常有必要了,这样一来可以管理公司内部用的JAR包,也可以管理第三方的各种JAR来,以免每次都要从外网的仓 ...
- XSHELL配色方案及导入配色方案的方法
[ubuntu] text(bold)=ffffff magenta(bold)=ad7fa8 text=ffffff white(bold)=eeeeec green=4e9a06 red(bold ...
- Mac mongodb 配置安装
简单总结就几条,比较简单配置mongodb. 1,首先下载安装包:百度云下载地址 2,下载之后解压到自己常放的工作目录下,然后开始配置一下你的Mac环境 vim ~/.bash_profile 添加m ...
- [C++] memset 和sizeof 的使用注意
因为使用C++写小题目时经常需要清除数组,这里记录下Memset函数的sizeof运算符的使用注意. memset的特点是:将给定地址后连续的内存(包括给定地址),逐个byte初始化为参数中指明的值. ...
- C#简易播放器(基于开源VLC)
可见光通信技术(Visible Light Communication,VLC)是指利用可见光波段的光作为信息载体,不使用光纤等有线信道的传输介质,而在空气中直接传输光信号的通信方式.LED可见光通信 ...
- Google Chrome 扩展程序开发
根据公司的规定,每月八小时,弹性工作制.所以大家平时来的不太准时,如果有事,下班也就早些回去了.所以一个月下来工作时间可能不够,但是公司的考勤日历是这样的: 除了请假和法定节假日外,其他样式显示都是一 ...
- Three.js源码阅读笔记-5
Core::Ray 该类用来表示空间中的“射线”,主要用来进行碰撞检测. THREE.Ray = function ( origin, direction ) { this.origin = ( or ...
- smartjs 0.2发布 - 新增oop模块&AOP增强
SmartJS2.0发布,更新内容如下: 新增oop(klass,factory)模块: promiseEvent加入非阻塞模式noBlock: trigger加入属性监听; smartjs主模块优化 ...
- ServiceStack 介绍
关于ServiceStack ServiceStack 官网介绍: Opensource .NET and Mono REST Web Services framework 什么是 ServiceSt ...
- [Code::Blocks] Install wxWidgets & openCV
The open source, cross platform, free C++ IDE. Code::Blocks is a free C++ IDE built to meet the most ...