3

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

在讨论实际问题之前,让我总结一下我的代码;

Inherited 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 错误(无效的嵌入代码)。所以我试图向他们寻求支持,但无法得到有效的答案。

_stream.movi​​e 变量实际上保存了流源的有效 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(key,value) 设置变量 - 这也不起作用。

笔记:

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

1 回答 1

2

我最近在制作 justin.tv 时遇到了问题,但最后它很简单

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

它工作得很好

于 2012-06-26T01:25:11.917 回答