我的一个程序使用AxShockwaveFlash组件作为流播放器。问题是,我的代码适用于大多数流提供商(livestream、ustream、own3d.tv),但是Justin.tv的播放器有点问题。
在讨论实际问题之前,让我总结一下我的代码;
继承的FlashControl -这允许我覆盖闪存的内置菜单:
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是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错误(无效的嵌入代码)。因此,我试图问他们的支持,但无法得到一个有效的答案。
_stream.movie变量实际上为流源保存了一个有效的URL,如;
http://cdn.livestream.com/grid/LSPlayer.swf?channel=%slug%&autoPlay=true (livestream样品)
或
volume=100 (justin.tv样本)
尝试为'channel=%slug%&auto_play=true&start_volume=100‘部分编写justin.tv代码,但这也不起作用。
因此,我开始尝试一些工作,首先我想设置控件的flashVars变量。
但是这里有一个奇怪的问题,每当我试图设置flashVars变量时,它永远不会被设置。我在这个问题上找到了一个截图样本;

因此,如果我能够设置flashVariables可能是,我可以工作-解决justin.tv播放器的错误。顺便说一句,我还尝试使用Player.SetVariable(key,value)设置变量--这也不起作用。
备注:
发布于 2012-06-26 01:25:11
我最近遇到了一个问题,使justin.tv的工作,但最后,它是简单的
axShockwaveFlash1.FlashVars = "auto_play=true&channel=adventuretimed&start_volume=25";
axShockwaveFlash1.Movie = "http://www.justin.tv/widgets/live_embed_player.swf";而且它工作得很完美
https://stackoverflow.com/questions/4726053
复制相似问题