开发者

Setting FlashVars of AxShockwaveFlash

开发者 https://www.devze.com 2023-02-05 12:53 出处:网络
a program of mine uses AxShockwaveFlash component used as stream player. The probl开发者_开发知识库em is that my code works with most stream-providers (livestream, ustream, own3d.tv) but Justin.TV\'s

a program of mine uses AxShockwaveFlash component used as stream player. The probl开发者_开发知识库em is that my code works with most stream-providers (livestream, ustream, own3d.tv) but Justin.TV's player is somewhat problematic.

Before moving on the actual problem let me summarize my code;

Inherited FlashControl - this allows me to override the flashplayer's built-in menu:

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 window code: (Player is an instance of 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.
            }
        }

So this works great for livestream.com, ustream.com, own3d.tv but when it come's to justin.tv's player i'm getting a 1337 error (invalid embed code). So i tried to ask them for support but could't get a valid answer.

_stream.movie variable actually holds a valid URL for the stream source like;

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

or

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

Tried to urlencode the 'channel=%slug%&auto_play=true&start_volume=100' part for justin.tv but that did not work also.

So i started trying some work-arounds which at first place i thought setting flashVars variable of the control.

But i've a strange problem there, whenever i try to set flashVars variable it never get's set. I found a sample screenshot on the issue;

Setting FlashVars of AxShockwaveFlash

So if i was able to set the flashVariables may be i could work-around the justin.tv player's error. Btw, i also tried setting variables using Player.SetVariable(key,value) - that didn't work also.

Notes:

  • I'm running on .net 4.0 client profile.
  • Using the Flash10l.ocx.
  • Have generated the AxShockwaveFlashObjects.dll, ShockwaveFlashObjects.dll wrappers using "aximp.exe –source "C:\WINDOWS\system32\Macromed\Flash\Flash10l.ocx"


I recently had an issue with making justin.tv work, but in the end it was as simple as

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

and it works perfectly

0

精彩评论

暂无评论...
验证码 换一张
取 消