我的程序使用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);
}
}
播放器窗口代码:(播放器是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.movie变量实际上包含流源的有效URL,如;
http://cdn.livestream.com/grid/LSPlayer.swf?channel=%slug%&autoPlay=true(直播样本)
或
http://www.justin.tv/widgets/live_embed_player.swf?channel=%slug%&auto_play=true&start_volume=100(justin.tv示例)
试图对justin.tv的'channel =%slug%& auto_play = true& start_volume = 100'部分进行urlencode,但这也不起作用。
所以我开始尝试一些解决方法,首先我想设置控件的flashVars变量。
但是我有一个奇怪的问题,每当我尝试设置flashVars变量时,它永远不会被设置。我找到了关于这个问题的示例截图;
所以如果我能够设置flashVariables可能是我可以解决justin.tv播放器的错误。顺便说一句,我也尝试使用Player.SetVariable(键,值)设置变量 - 这也不起作用。
注意:
答案 0 :(得分:2)
我最近遇到了使justin.tv工作的问题,但最终它就像
一样简单axShockwaveFlash1.FlashVars = "auto_play=true&channel=adventuretimed&start_volume=25";
axShockwaveFlash1.Movie = "http://www.justin.tv/widgets/live_embed_player.swf";
它完美无缺