CodeImp.Gluon.MediaPlayerDisplayForm.PlayFile C# (CSharp) Метод

PlayFile() публичный Метод

public PlayFile ( string filename, int startpos ) : void
filename string
startpos int
Результат void
        public void PlayFile(string filename, int startpos)
        {
            stopintended = false;
            player.URL = filename;

            // Wait for the player to load the file
            while((player.playState == WMPPlayState.wmppsBuffering) ||
                  (player.playState == WMPPlayState.wmppsTransitioning) ||
                  (player.playState == WMPPlayState.wmppsReady))
            {
                Application.DoEvents();
            }

            // Send media length to gluon
            InterProcess.SendMessage(InterProcess.MSG_MEDIA_LENGTH, (int)player.currentMedia.duration);

            if(!string.IsNullOrEmpty(muxingfile))
            {
                player.Visible = false;
                muxplayer.Visible = true;

                // Don't interrupt the muxed video if not needed
                if(muxingfile != muxingfileplaying)
                {
                    muxingfileplaying = muxingfile;
                    muxplayer.URL = muxingfile;

                    // Wait for the player to load the file
                    while((player.playState == WMPPlayState.wmppsBuffering) ||
                          (player.playState == WMPPlayState.wmppsTransitioning) ||
                          (player.playState == WMPPlayState.wmppsReady))
                    {
                        Application.DoEvents();
                    }

                    // Play!
                    muxplayer.Ctlcontrols.play();
                }
            }
            else
            {
                player.Visible = true;
                muxplayer.Visible = false;
                muxplayer.close();
                muxingfileplaying = "";
            }

            // Play!
            player.Ctlcontrols.currentPosition = (double)startpos;
            player.Ctlcontrols.play();

            updatetimer.Start();
        }

Usage Example

Пример #1
0
        static void Main()
        {
            int formleftpos = 0;

            string[] options;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

                        #if HIGH_PRIORITY_PROCESS
            Process thisproc = Process.GetCurrentProcess();
            thisproc.PriorityClass = ProcessPriorityClass.High;
                        #endif
            Thread thisthread = Thread.CurrentThread;
            thisthread.Priority = ThreadPriority.Highest;

            // HWND of Gluon window
            int hwndint;
            options = GetCommandLineOption("hwnd");
            if (options.Length > 1)
            {
                // Remember HWND for inter-process communcation
                int.TryParse(options[1], out hwndint);
                InterProcess.otherhwnd = new IntPtr(hwndint);
            }
            else
            {
                // We can't start without knowing the HWND of the other app
                return;
            }

            // Form left position specified?
            options = GetCommandLineOption("left");
            if (options.Length > 1)
            {
                int.TryParse(options[1], out formleftpos);
            }

            // Show a URL?
            options = GetCommandLineOption("showurl");
            if (options.Length > 1)
            {
                WebPageDisplayForm f = new WebPageDisplayForm();
                f.Left = formleftpos;
                f.ShowURL(options[1]);
                f.Show();
                Application.Run(f);
            }

            // Play media file?
            options = GetCommandLineOption("playmedia");
            if (options.Length > 0)
            {
                MediaPlayerDisplayForm f = new MediaPlayerDisplayForm();
                f.Left = formleftpos;
                f.Show();
                f.WindowState = FormWindowState.Maximized;
                if (options.Length > 1)
                {
                    string filename = options[1];
                    int    startpos = 0;
                    options = GetCommandLineOption("startpos");
                    if (options.Length > 1)
                    {
                        int.TryParse(options[1], out startpos);
                    }
                    options = GetCommandLineOption("mux");
                    if (options.Length > 1)
                    {
                        f.SetMuxingFile(options[1]);
                    }
                    f.PlayFile(filename, startpos);
                }
                Application.Run(f);
            }
        }
All Usage Examples Of CodeImp.Gluon.MediaPlayerDisplayForm::PlayFile