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 ...
随机推荐
- WebStorm11 注册
WebStorm11 注册 http://2.idea.lanyus.com/
- js后退一直停留在当前页面或者禁止后退
//禁用后退按钮 function stopHistoryGo() { //禁用回退 window.location.hash="no-back-button"; window.l ...
- ASP.NET MVC 自定义路由中几个需要注意的小细节
本文主要记录在ASP.NET MVC自定义路由时,一个需要注意的参数设置小细节. 举例来说,就是在访问 http://localhost/Home/About/arg1/arg2/arg3 这样的自定 ...
- exerunexplorer.exe
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...
- C# Json帮助类
using System; using System.Collections.Generic; using System.Web; using System.Text; using System.Re ...
- 读书笔记_Effective_C++_条款四十三:学习处理模板化基类的名称
背景是这样的,有两个不同的公司,然后想设计一个MessageSender,为这两个公司发送不同的消息,既支持明文发送SendClearText,也支持密文发送SendEncryptedText.一种思 ...
- 【Android学习】数据传递三种方式
1.Application 注意在清单文件中的Application节点下注册android:name属性, 继承Application类,重写onCreate方法, 使用数据时,实例化自定义类时需要 ...
- 简单设置 navgationbar(导航栏) 的 title 字体跟颜色
NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys: [UIColor white ...
- css3 画圆记录
<style> .radar-wrapper * { -moz-box-sizing: border-box; box-sizing: border-box; margin:; paddi ...
- Android之startActivityForResult的使用
在Android中startActivityForResult主要作用就是: A-Activity需要在B-Activtiy中执行一些数据操作,而B-Activity又要将,执行操作数据的结果返回给A ...