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的更多相关文章

  1. ubuntu下chromium 安装flash player

    原文地址 :http://blog.sina.com.cn/s/blog_858820890102v63w.html 不记得从什么时候起,Chromium 不再支持 Netscape plugin A ...

  2. Flash cc 添加目标Flash Player

    原文出处:http://zengrong.net/post/1568.htm 第一步 首先下载最新的 playerglobal.swc(基于Flash Player11): http://www.ad ...

  3. Ubuntu14.04下安装Flash Player

    Ubuntu14.04下安装Flash Player youhaidong@youhaidong:~$ sudo apt-get install flashplugin-nonfree [sudo] ...

  4. 让旧版本的 Flash IDE 支持更新的 Flash Player/AIR 功能

    转载:https://blog.zengrong.net/post/1568.html 让旧版本的 Flash IDE 支持更新的 Flash Player/AIR 功能 今天在论坛上看到一篇文章:H ...

  5. linux下为firfox安装flash player

    1.去官网下载×.tar.gz包,如:flash_player_npapi_linux.x86_64.tar.gz 2.解压 tar -zxvf flash_player_npapi_linux.x8 ...

  6. Flash Player的终章——赠予它的挽歌

    本文由葡萄城技术团队原创并首发 转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 12月28日消息,微软已经确认Windows 10在下一次更新时将自动删除F ...

  7. 解决浏览器Adobe Flash Player不是最新版本问题

    关键:选择谷歌浏览器的PPAPI版本的flash下载直接安装即可 搜索: Adobe Flash Player PPAPI 下载地址: http://www.wmzhe.com/soft-30259. ...

  8. [转]Flash Player、AIR、Flex SDK 大全

    平时不断看到有朋友在各种论坛.空间.知道.群里求 Flash 平台各种版本的运行时(Flash Player)和SDK(Flex.AIR).今天就看到不下10次!所以决定把 Macromedia.Ad ...

  9. chrome 'adobe flash player 已过期'解决方法

    http://labs.adobe.com/downloads/flashplayer.html下载 WindowsDownload Flash Player for Opera and Chromi ...

随机推荐

  1. android 开发 - 对图片进行虚化(毛玻璃效果,模糊)

    概述 IPAD,IPHONE上首页背景的模糊效果是不是很好看,那么在 Android中如何实现呢.我通过一种方式实现了这样的效果. 开源库名称:anroid-image-blur 一个android ...

  2. synchronized关键字,Lock接口以及可重入锁ReentrantLock

    多线程环境下,必须考虑线程同步的问题,这是因为多个线程同时访问变量或者资源时会有线程争用,比如A线程读取了一个变量,B线程也读取了这个变量,然后他们同时对这个变量做了修改,写回到内存中,由于是同时做修 ...

  3. ios 数组排序

    第一种:利用数组的sortedArrayUsingComparator调用 NSComparator  示例: obj1和obj2指的是数组中的对象 //1.数组中存放的是字符 NSComparato ...

  4. 如何使用MVC编写Winform程序代码

    efwplus开源框架官网:www.efwplus.cn 前提:业务分析设计已完成,界面设计完成   1.代码结构划分 1)界面层:FrmSugeryApplyList.ISugeryApplyLis ...

  5. CSS 块状元素和内联元素

    在用CSS布局页面的时候,我们会将HTML标签分成两种,块状元素和内联元素(我们平常用到的div和p就是块状元素,链接标签a就是内联元素) 块状元素一般是其他元素的容器,可容纳内联元素和其他块状元素, ...

  6. 比较HTML元素和Native组件的区别

    我们开发web应用,会使用到各种Html基本元素,比较<div>,<span>,<img>等. 当我们在开发React Native时,我们不能使用HTML元素,但 ...

  7. [IR] Index Construction

    Three steps to construct Inverted Index as following: 最难的step中: Token sequence. Sort by term. Dictio ...

  8. [c++] Collection of key and difficult points

    Operator Overload 1. 在重载下标运算符时(数组符号):不可重载为友元函数,必须是非static类的成员函数. why 2. overload ++ 时,如果是:   int a;  ...

  9. [Node.js] Cluster,把多核用起来

    原文地址: http://www.moye.me/?p=496 引子 众所周知,虽然Node的底层有一个IO线程池,但其应用层默认是单线程运行的,对于多核CPU环境来说,是一种资源的浪费. 所幸Nod ...

  10. Fenix – 基于 Node.js 的桌面静态 Web 服务器

    Fenix 是一个提供给开发人员使用的简单的桌面静态 Web 服务器,基于 Node.js 开发.您可以同时在上面运行任意数量的项目,特别适合前端开发人员使用. 您可以通过免费的 Node.js 控制 ...