Пример #1
0
 public override void Pause()
 {
     if (FlvControl == null)
     {
         return;
     }
     GetState();
     //if (_started == false) return;
     try
     {
         if (_playState == PlayState.Paused)
         {
             //FlvControl.Player.Play();
             FlvControl.Player.CallFunction("<invoke name=\"playVideo\"></invoke>");
             //FlvControl.Player.CallFunction("<invoke name=\"playpause\" returntype=\"xml\"></invoke>");
             //FlvControl.Player.CallFunction("<invoke name=\"sendEvent\" returntype=\"xml\"><arguments><string>playpause</string></arguments></invoke>");
             //_playerIsPaused = false;
         }
         else
         {
             FlvControl.Player.CallFunction("<invoke name=\"pauseVideo\"></invoke>");
             //FlvControl.Player.CallFunction("<invoke name=\"playpause\" returntype=\"xml\"></invoke>");
             //FlvControl.Player.CallFunction("<invoke name=\"sendEvent\" returntype=\"xml\"><arguments><string>playpause</string></arguments></invoke>");
             //FlvControl.Player.StopPlay();
             //_playerIsPaused = true;
         }
     }
     catch (Exception ex)
     {
         FlvControl = null;
         Log.Error("Flv on pause error {0} {1} {2}", ex.Message, ex.Source, ex.StackTrace);
         return;
     }
 }
Пример #2
0
        public override void Stop()
        {
            Log.Info("Attempting to stop...{0}", FlvControl);
            if (FlvControl == null)
            {
                return;
            }
            try
            {
                //Log.Info("before {0}", Playing);
                //FlvControl.Player.Stop();
                FlvControl.Player.StopPlay();
                FlvControl.Player.DisableLocalSecurity();
                try
                {
                    if (_playState == PlayState.Playing || _playState == PlayState.Paused)
                    {
                        FlvControl.Player.CallFunction("<invoke name=\"stopVideo\"></invoke>");
                    }
                }
                catch
                {
                }
                FlvControl.ClientSize     = new Size(0, 0);
                FlvControl.Player.Visible = false;
                FlvControl.Visible        = false;
                GUIGraphicsContext.form.Controls[0].Enabled = false;
                GUIGraphicsContext.form.Controls[0].Visible = false;
                FlvControl.Dispose();
                //_playerIsPaused = false;
                //_started = false;
                //Playing = false;
                //GUIGraphicsContext.OnNewAction -= new OnActionHandler(OnAction2);
                //Log.Info("after {0}", Playing);
            }
            catch (Exception ex)
            {
                Log.Error("Flv on stop error {0} \n {1} \n {2}", ex.Message, ex.Source, ex.StackTrace);

                FlvControl = null;
            }
        }
Пример #3
0
        public override bool Play(string strFile)
        {
            Log.Info("Playing flv with YoutubeFlvPlayer :{0}", strFile);
            try
            {
                //Uri site = new Uri(strFile);
                if (FlvControl != null)
                {
                }

                //string[] param = site.Query.Substring(1).Split('&');
                string video_id = getIDSimple(strFile);

                FlvControl = new FlashControl();
                FlvControl.Player.AllowScriptAccess = "always";

                Log.Debug("Flash version : {0} ", FlvControl.Player.FlashVersion());

                FlvControl.Player.FlashCall += new _IShockwaveFlashEvents_FlashCallEventHandler(OnFlashCall);
                FlvControl.Player.FSCommand += new _IShockwaveFlashEvents_FSCommandEventHandler(Player_FSCommand);
                //FlvControl.Player.FlashVars = site.Query.Replace("?", "&") + "&eh=myCallbackEventHandler&token=AA7Zx0hd0JeezyPS6TqLB0_1UnEUMZybQEmzIAWcIa7UHPEHNg--";
                FlvControl.Player.OnProgress       += new _IShockwaveFlashEvents_OnProgressEventHandler(Player_OnProgress);
                FlvControl.Player.AllowScriptAccess = "always";
                //FlvControl.Player.LoadMovie(0, string.Format("http://www.youtube.com/v/{0}&color1=0x2b405b&color2=0x6b8ab6&fs=1&autoplay=1&enablejsapi=1&playerapiid=ytplayer", video_id));
                if (strFile.Contains("http://www.youtube.com/v"))
                {
                    FlvControl.Player.LoadMovie(0, "http://www.youtube.com/apiplayer?enablejsapi=1");
                    FlvControl.Visible = false;
                }
                else
                {
                    FlvControl.Player.LoadMovie(0, string.Format("http://www.youtubeflashplayer.com/youtubeflashplayer.swf?vurl={0}&sn=http://&logo=http://www.youtubeflashplayer.com/images/youtubeplayericon.png&showlogo=false&showcontrol=false&autohide=false&delaytime=&autoplay=true&loopplay=false&", HttpUtility.UrlEncode(strFile)));
                    FlvControl.Visible = true;
                    //FlvControl.Player.LoadMovie(0, Config.GetFile(Config.Dir.Plugins, "ExternalPlayers", "yt.swf"));
                    ////FlvControl.Player.FlashVars = String.Format("&file={0}&autostart=true&enablejs=true&allowfullscreen=true", HttpUtility.UrlDecode(strFile));
                    //FlvControl.Player.FlashVars = String.Format("&file={0}&autostart=true&enablejs=true&backcolor=0x000000&frontcolor=0xCCCCCC&showicons=false&showvolume=false&showdigits=false&displayheight={1}&allowfullscreen=true", strFile.Replace("&", "%26").Replace("?", "%3f"), 9999);

                    //Log.Debug("flash vars: {0}", String.Format("&file={0}&autostart=true&enablejs=true&allowfullscreen=true", HttpUtility.UrlEncode(strFile)));
                    //Log.Debug("flash vars: {0}", FlvControl.Player.FlashVars);
                }
                FlvControl.Player.AllowScriptAccess = "always";

                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null);
                msg.Label = strFile;
                GUIWindowManager.SendThreadMessage(msg);

                this.VideoId = getIDSimple2(strFile);

                GUIGraphicsContext.form.SuspendLayout();
                GUIWindowManager.OnNewAction += new OnActionHandler(OnAction2);

                _notifyPlaying        = true;
                FlvControl.ClientSize = new Size(0, 0);
                FlvControl.Enabled    = false;
                FlvControl.TabIndex   = 0;
                GUIGraphicsContext.form.Controls.Add(FlvControl);

                _needUpdate   = true;
                _isFullScreen = GUIGraphicsContext.IsFullScreenVideo;
                _positionX    = GUIGraphicsContext.VideoWindow.Left;
                _positionY    = GUIGraphicsContext.VideoWindow.Top;
                _videoWidth   = GUIGraphicsContext.VideoWindow.Width;
                _videoHeight  = GUIGraphicsContext.VideoWindow.Height;

                _currentFile     = strFile;
                _duration        = -1;
                _currentPosition = -1;
                _playState       = PlayState.Playing;
                _updateTimer     = DateTime.Now;
                SetVideoWindow();
                GUIGraphicsContext.form.ResumeLayout(false);
                return(true);
            }
            catch (Exception ex)
            {
                Log.Error("Flv on Play Error {0} {1} {2}", ex.Message, ex.Source, ex.StackTrace);
            }
            return(false);
        }
        public override void Stop()
        {
            Log.Info("Attempting to stop...{0}", FlvControl);
            if (FlvControl == null) return;
            try
            {
                //Log.Info("before {0}", Playing);
            //FlvControl.Player.Stop();
            FlvControl.Player.StopPlay();
            FlvControl.Player.DisableLocalSecurity();
            try
            {
              if (_playState == PlayState.Playing || _playState == PlayState.Paused)
              {
            FlvControl.Player.CallFunction("<invoke name=\"stopVideo\"></invoke>");
              }
            }
            catch
            {
            }
            FlvControl.ClientSize = new Size(0, 0);
            FlvControl.Player.Visible = false;
                FlvControl.Visible = false;
            GUIGraphicsContext.form.Controls[0].Enabled = false;
            GUIGraphicsContext.form.Controls[0].Visible = false;
            FlvControl.Dispose();
            //_playerIsPaused = false;
            //_started = false;
            //Playing = false;
                //GUIGraphicsContext.OnNewAction -= new OnActionHandler(OnAction2);
                //Log.Info("after {0}", Playing);
            }
            catch (Exception ex)
            {
            Log.Error("Flv on stop error {0} \n {1} \n {2}", ex.Message, ex.Source, ex.StackTrace);

                FlvControl = null;
            }
        }
        public override bool Play(string strFile)
        {
            Log.Info("Playing flv with YoutubeFlvPlayer :{0}",strFile);
              try
            {
            //Uri site = new Uri(strFile);
            if (FlvControl != null)
            {
            }

            //string[] param = site.Query.Substring(1).Split('&');
            string video_id = getIDSimple(strFile);

            FlvControl = new FlashControl();
            FlvControl.Player.AllowScriptAccess = "always";

            Log.Debug("Flash version : {0} ", FlvControl.Player.FlashVersion());

                FlvControl.Player.FlashCall += new _IShockwaveFlashEvents_FlashCallEventHandler(OnFlashCall);
            FlvControl.Player.FSCommand += new _IShockwaveFlashEvents_FSCommandEventHandler(Player_FSCommand);
            //FlvControl.Player.FlashVars = site.Query.Replace("?", "&") + "&eh=myCallbackEventHandler&token=AA7Zx0hd0JeezyPS6TqLB0_1UnEUMZybQEmzIAWcIa7UHPEHNg--";
            FlvControl.Player.OnProgress += new _IShockwaveFlashEvents_OnProgressEventHandler(Player_OnProgress);
            FlvControl.Player.AllowScriptAccess = "always";
            //FlvControl.Player.LoadMovie(0, string.Format("http://www.youtube.com/v/{0}&color1=0x2b405b&color2=0x6b8ab6&fs=1&autoplay=1&enablejsapi=1&playerapiid=ytplayer", video_id));
            if (strFile.Contains("http://www.youtube.com/v"))
            {
              FlvControl.Player.LoadMovie(0, "http://www.youtube.com/apiplayer?enablejsapi=1");
              FlvControl.Visible = false;
            }
            else
            {
              FlvControl.Player.LoadMovie(0, string.Format("http://www.youtubeflashplayer.com/youtubeflashplayer.swf?vurl={0}&sn=http://&logo=http://www.youtubeflashplayer.com/images/youtubeplayericon.png&showlogo=false&showcontrol=false&autohide=false&delaytime=&autoplay=true&loopplay=false&", HttpUtility.UrlEncode(strFile)));
              FlvControl.Visible = true;
              //FlvControl.Player.LoadMovie(0, Config.GetFile(Config.Dir.Plugins, "ExternalPlayers", "yt.swf"));
              ////FlvControl.Player.FlashVars = String.Format("&file={0}&autostart=true&enablejs=true&allowfullscreen=true", HttpUtility.UrlDecode(strFile));
              //FlvControl.Player.FlashVars = String.Format("&file={0}&autostart=true&enablejs=true&backcolor=0x000000&frontcolor=0xCCCCCC&showicons=false&showvolume=false&showdigits=false&displayheight={1}&allowfullscreen=true", strFile.Replace("&", "%26").Replace("?", "%3f"), 9999);

              //Log.Debug("flash vars: {0}", String.Format("&file={0}&autostart=true&enablejs=true&allowfullscreen=true", HttpUtility.UrlEncode(strFile)));
              //Log.Debug("flash vars: {0}", FlvControl.Player.FlashVars);
            }
            FlvControl.Player.AllowScriptAccess = "always";

            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null);
            msg.Label = strFile;
            GUIWindowManager.SendThreadMessage(msg);

            this.VideoId = getIDSimple2(strFile);

            GUIGraphicsContext.form.SuspendLayout();
                GUIWindowManager.OnNewAction +=new OnActionHandler(OnAction2);

                _notifyPlaying = true;
                FlvControl.ClientSize = new Size(0, 0);
            FlvControl.Enabled = false;
            FlvControl.TabIndex = 0;
            GUIGraphicsContext.form.Controls.Add(FlvControl);

                _needUpdate = true;
                _isFullScreen = GUIGraphicsContext.IsFullScreenVideo;
                _positionX = GUIGraphicsContext.VideoWindow.Left;
                _positionY = GUIGraphicsContext.VideoWindow.Top;
                _videoWidth = GUIGraphicsContext.VideoWindow.Width;
                _videoHeight = GUIGraphicsContext.VideoWindow.Height;

                _currentFile = strFile;
                _duration = -1;
                _currentPosition = -1;
                _playState = PlayState.Playing;
                _updateTimer = DateTime.Now;
                SetVideoWindow();
            GUIGraphicsContext.form.ResumeLayout(false);
                return true;
            }
            catch (Exception ex)
            {
            Log.Error("Flv on Play Error {0} {1} {2}", ex.Message, ex.Source, ex.StackTrace);
            }
            return false;
        }
 public override void Pause()
 {
     if (FlvControl == null) return;
       GetState();
     //if (_started == false) return;
     try
     {
         if (_playState == PlayState.Paused)
         {
             //FlvControl.Player.Play();
       FlvControl.Player.CallFunction("<invoke name=\"playVideo\"></invoke>");
             //FlvControl.Player.CallFunction("<invoke name=\"playpause\" returntype=\"xml\"></invoke>");
       //FlvControl.Player.CallFunction("<invoke name=\"sendEvent\" returntype=\"xml\"><arguments><string>playpause</string></arguments></invoke>");
             //_playerIsPaused = false;
         }
         else
         {
       FlvControl.Player.CallFunction("<invoke name=\"pauseVideo\"></invoke>");
             //FlvControl.Player.CallFunction("<invoke name=\"playpause\" returntype=\"xml\"></invoke>");
             //FlvControl.Player.CallFunction("<invoke name=\"sendEvent\" returntype=\"xml\"><arguments><string>playpause</string></arguments></invoke>");
             //FlvControl.Player.StopPlay();
             //_playerIsPaused = true;
         }
     }
     catch (Exception ex)
     {
         FlvControl = null;
     Log.Error("Flv on pause error {0} {1} {2}", ex.Message, ex.Source, ex.StackTrace);
         return;
     }
 }