gpt4 book ai didi

c# - 设置 AxShockwaveFlash 的 FlashVars

转载 作者:行者123 更新时间:2023-11-30 17:19:38 25 4
gpt4 key购买 nike

我的一个程序使用 AxShockwaveFlash 组件作为流播放器。问题是我的代码适用于大多数流媒体提供商(livestream、ustream、own3d.tv),但 Justin.TV 的播放器有点问题。

在继续解决实际问题之前,让我总结一下我的代码;

继承的 FlashControl - 这允许我覆盖 flashplayer 的内置菜单:

public class FlashPlayer : AxShockwaveFlashObjects.AxShockwaveFlash // Customized Flash Player.
{
private const int WM_MOUSEMOVE = 0x0200;
private const int WM_MOUSEWHEEL = 0x020A;
private const int WM_LBUTTONDOWN = 0x0201;
private const int WM_LBUTTONUP = 0x0202;
private const int WM_LBUTTONDBLCLK = 0x0203;
private const int WM_RBUTTONDOWN = 0x0204;
private const int WM_RBUTTONUP = 0x0205;

public new event MouseEventHandler DoubleClick;
public new event MouseEventHandler MouseDown;
public new event MouseEventHandler MouseUp;
public new event MouseEventHandler MouseMove;

public FlashPlayer():base()
{
this.HandleCreated += FlashPlayer_HandleCreated;
}

void FlashPlayer_HandleCreated(object sender, EventArgs e)
{
this.AllowFullScreen = "true";
this.AllowNetworking = "all";
this.AllowScriptAccess = "always";
}

protected override void WndProc(ref Message m) // Override's the WndProc and disables Flash activex's default right-click menu and if exists shows the attached ContextMenuStrip.
{
if (m.Msg == WM_LBUTTONDOWN)
{
if (this.MouseDown != null) this.MouseDown(this, new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, Cursor.Position.X, Cursor.Position.Y, 0));
}
else if (m.Msg == WM_LBUTTONUP)
{
if (this.MouseUp != null) this.MouseUp(this, new MouseEventArgs(System.Windows.Forms.MouseButtons.None, 0, Cursor.Position.X, Cursor.Position.Y, 0));
}
else if (m.Msg == WM_MOUSEMOVE)
{
if (this.MouseMove != null) this.MouseMove(this, new MouseEventArgs(System.Windows.Forms.MouseButtons.None, 0, Cursor.Position.X, Cursor.Position.Y, 0));
}
else if (m.Msg == WM_RBUTTONDOWN)
{
if (this.ContextMenuStrip != null) this.ContextMenuStrip.Show(Cursor.Position.X, Cursor.Position.Y);
m.Result = IntPtr.Zero;
return;
}
else if (m.Msg == WM_LBUTTONDBLCLK)
{
if (this.DoubleClick != null) this.DoubleClick(this, new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 2, Cursor.Position.X, Cursor.Position.Y, 0));
m.Result = IntPtr.Zero;
return;
}

base.WndProc(ref m);
}
}

Player窗口代码:(Player是FlashPlayer的一个实例)

private void Player_Load(object sender, EventArgs e) 
{
try
{
this.Text = string.Format("Stream: {0}", this._stream.Name); // set the window title.
this.Player.LoadMovie(0, this._stream.Movie); // load the movie.

if (this._stream.ChatAvailable && Settings.Instance.AutomaticallyOpenChat) this.OpenChatWindow();
}
catch (Exception exc)
{
// log stuff.
}
}

所以这对 livestream.com、ustream.com、own3d.tv 非常有用,但是当涉及到 justin.tv 的播放器时,我收到 1337 错误(无效的嵌入代码)。所以我试着ask them寻求支持,但无法得到有效答案。

_stream.movi​​e 变量实际上包含流源的有效 URL;

http://cdn.livestream.com/grid/LSPlayer.swf?channel=%slug%&autoPlay=true (livestream sample)

http://www.justin.tv/widgets/live_embed_player.swf?channel=%slug%&auto_play=true&start_volume=100 (justin.tv sample)

尝试对 justin.tv 的“channel=%slug%&auto_play=true&start_volume=100”部分进行 urlencode,但这也不起作用。

所以我开始尝试一些解决方法,首先我想设置控件的 flashVars 变量。

但我有一个奇怪的问题,每当我尝试设置 flashVars 变量时,它永远不会被设置。我找到了有关该问题的示例屏幕截图;

alt text

因此,如果我能够设置 flashVariables,我就可以解决 justin.tv 播放器的错误。顺便说一句,我还尝试使用 Player.SetVariable(key,value) 设置变量 - 这也不起作用。

注意事项:

  • 我在 .net 4.0 客户端配置文件上运行。
  • 使用 Flash10l.ocx。
  • 使用“aximp.exe –source "C:\WINDOWS\system32\Macromed\Flash\Flash10l.ocx”生成了 AxShockwaveFlashObjects.dll、ShockwaveFlashObjects.dll 包装器

最佳答案

我最近遇到了让 justin.tv 工作的问题,但最终它变得很简单

axShockwaveFlash1.FlashVars = "auto_play=true&channel=adventuretimed&start_volume=25";
axShockwaveFlash1.Movie = "http://www.justin.tv/widgets/live_embed_player.swf";

而且效果很好

关于c# - 设置 AxShockwaveFlash 的 FlashVars,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4726053/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com