Example #1
0
        //-------------------------------------------------------------------------
        // FMEが動作中かチェック
        //-------------------------------------------------------------------------
        public static bool hasFME()
        {
            Process[] ps;

            if (Properties.Settings.Default.fme_gui)
            {
                return(FMEGUI.hasFME());
            }
            else
            {
                ps = Process.GetProcessesByName("FMLECmd");
            }

            return(ps.Length > 0);
        }
Example #2
0
        //-------------------------------------------------------------------------
        // 停止
        //-------------------------------------------------------------------------
        public static void Stop()
        {
            if (Properties.Settings.Default.fme_gui)
            {
                FMEGUI.Kill();
            }
            else
            {
                Process[] ps = Process.GetProcessesByName("FMLECmd");

                foreach (System.Diagnostics.Process p in ps)
                {
                    try
                    {
                        p.Kill();
                    }
                    catch (Exception e) {
                        Utils.WriteLog("FMLE() " + e.Message);
                    }
                }

                ps = Process.GetProcessesByName("FlashMediaLiveEncoder");

                foreach (System.Diagnostics.Process p in ps)
                {
                    p.Kill();
                }

                // すべてのFMEがいなくなったことを確認する
                do
                {
                    System.Threading.Thread.Sleep(500);
                    ps = Process.GetProcessesByName("FlashMediaLiveEncoder");
                } while (ps.Length > 0);
            }
            mFMEStarted = false;
            DeleteSessionfile();
        }
Example #3
0
        //-------------------------------------------------------------------------
        // 開始
        //-------------------------------------------------------------------------
        public static void Start(Dictionary <string, string> iParams, string profile_path)
        {
            DeleteSessionfile();
            if (Properties.Settings.Default.fme_gui)
            {
                Thread th = new Thread(delegate()
                {
                    mFMEStarted = FMEGUI.Start(iParams);
                });
                th.Name = "NivoLive.FMLE.Start(): gui";
                th.Start();
            }
            else
            {
                if (hasFME())
                {
                    return;
                }
                // FMLECmdのパス
                string APP_PATH = Properties.Settings.Default.fmle_path;
                // プロファイルのパス
                //string profile_path = Path.GetTempPath() + "nicovideo_fme.xml";

                Thread th = new Thread(delegate()
                {
                    // プロファイル作成
                    if (!MakeProfile(profile_path, iParams))
                    {
                        mFMEStarted = false;
                        return;
                    }

                    // FMLECmd起動
                    string args = " /p \"" + profile_path + "\"";

                    if (Properties.Settings.Default.fme_dos)
                    {
                        ProcessStartInfo psInfo = new ProcessStartInfo();
                        psInfo.FileName         = APP_PATH;
                        psInfo.CreateNoWindow   = false;
                        psInfo.UseShellExecute  = true;
                        if (Properties.Settings.Default.fme_dos_min)
                        {
                            psInfo.WindowStyle = ProcessWindowStyle.Minimized;
                        }
                        psInfo.Arguments = args;
                        Process.Start(psInfo);
                    }
                    else
                    {
                        ProcessStartInfo psInfo = new ProcessStartInfo();
                        psInfo.FileName         = APP_PATH;
                        psInfo.CreateNoWindow   = true;
                        psInfo.UseShellExecute  = false;
                        psInfo.Arguments        = args;
                        Process.Start(psInfo);
                    }
                    using (Bouyomi bm = new Bouyomi())
                    {
                        bm.Talk("えふえむいー配信を開始しました");
                    }
                    mFMEStarted = true;
                });
                th.Name = "NivoLive.FMLE.Start(): cui";
                th.Start();
            }
        }
Example #4
0
        //-------------------------------------------
        // PushStart
        //-------------------------------------------
        public static bool PushStart()
        {
            const int padding  = 10;
            const int padding2 = 10;

            mFMEStarted = false;

            // プロセスが確保されていなければ、リターン
            if (mFMEprocess == null)
            {
                return(false);
            }

            // プロセスが存在しても、終了していれば、リターン
            if (mFMEprocess.HasExited)
            {
                return(false);
            }

            // ウインドウのサイズをあわせる
            FitWindowSize();

            RECT clientrect = new RECT();


            // クライアント領域のスクリーンをキャプチャする
            Bitmap bmp = null;


            bool bStartPushed   = false;
            bool bStartComplete = false;

            using (ScreenCapture scr = new ScreenCapture())
            {
                int   i;
                Point outPos = new Point();

                Point start_offs = new Point(417, 512);
                Point stop_offs  = new Point(556, 512);
                Point ng_offs    = new Point(489, 357);


                // スタートボタンを探して押す
                for (i = 0; i < 60; i++)
                {
                    // ウインドウをフォアグラウンドに
                    SetForegroundWindow(m_fme_hwnd);  // アクティブにする

                    // クライアント領域のサイズを取得
                    GetClientRect(m_fme_hwnd, ref clientrect);
                    POINT p1, p2;
                    p1.x = clientrect.left;
                    p1.y = clientrect.top;
                    p2.x = clientrect.right;
                    p2.y = clientrect.bottom;

                    //クライアント領域座標をスクリーン座標に変換
                    ClientToScreen(m_fme_hwnd, ref p1);
                    ClientToScreen(m_fme_hwnd, ref p2);

                    // クライアント領域のレクトアングルを設定
                    Rectangle iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                    bmp = scr.Capture(iRect);
                    if (ContainBitmap(mStartBmp, bmp, start_offs.X - padding2, start_offs.Y - padding, start_offs.X + padding2, start_offs.Y + padding, ref outPos, 5))
                    {
                        MouseClick(p1.x + outPos.X + 18, p1.y + outPos.Y + 14);
                        bStartPushed = true;
                        // 立ち上がるのを待つ
                        using (Bouyomi bm = new Bouyomi())
                        {
                            bm.Talk("スタートボタン、プッシュ");
                        }
                        break;
                    }

                    bmp.Dispose();
                    bmp = null;
                    FitWindowSize();
                    // 0.5[s] wait
                    System.Threading.Thread.Sleep(500);
                }

                // スタートボタンが押せなかった場合
                if (!bStartPushed)
                {
                    if (bmp != null)
                    {
                        bmp.Dispose();
                        bmp = null;
                    }
                    // 立ち上がるのを待つ
                    using (Bouyomi bm = new Bouyomi())
                    {
                        bm.Talk("スタートボタンを代わりに押してください");
                    }
                }

                // スタートできたかのチェック
                for (i = 0; i < 40; i++)
                {
                    // ウインドウをフォアグラウンドに
                    SetForegroundWindow(m_fme_hwnd);  // アクティブにする

                    GetClientRect(m_fme_hwnd, ref clientrect);
                    POINT p1, p2;
                    p1.x = clientrect.left;
                    p1.y = clientrect.top;
                    p2.x = clientrect.right;
                    p2.y = clientrect.bottom;

                    //クライアント領域座標をスクリーン座標に変換
                    ClientToScreen(m_fme_hwnd, ref p1);
                    ClientToScreen(m_fme_hwnd, ref p2);

                    Rectangle iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                    bmp = scr.Capture(iRect);

                    // Stop が押せるようになれば、とりあえず成功判定
                    if (ContainBitmap(mStopBmp, bmp, stop_offs.X - padding2, stop_offs.Y - padding, stop_offs.X + padding2, stop_offs.Y + padding, ref outPos, 5))
                    {
                        // 立ち上がるのを待つ
                        using (Bouyomi bm = new Bouyomi())
                        {
                            bm.Talk("ストップボタン、点灯確認");
                        }
                        bStartComplete = true;
                        mFMEStarted    = true;
                        bmp.Dispose();
                        bmp = null;
                        break;
                    }

                    // NGダイアログが出てきたら、NG判定
                    if (ContainBitmap(mNgBmp, bmp, ng_offs.X - padding2, ng_offs.Y - padding, ng_offs.X + padding2, ng_offs.Y + padding, ref outPos, 5))
                    {
                        MouseClick(p1.x + outPos.X + 10, p1.y + outPos.Y + 10);
                        if (bmp != null)
                        {
                            bmp.Dispose();
                            bmp = null;
                        }

                        // NG ダイアログが消えるのを待つ
                        int j;
                        for (j = 0; j < 10; j++)
                        {
                            GetClientRect(m_fme_hwnd, ref clientrect);

                            p1.x = clientrect.left;
                            p1.y = clientrect.top;
                            p2.x = clientrect.right;
                            p2.y = clientrect.bottom;

                            //クライアント領域座標をスクリーン座標に変換
                            ClientToScreen(m_fme_hwnd, ref p1);
                            ClientToScreen(m_fme_hwnd, ref p2);

                            iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                            bmp = scr.Capture(iRect);
                            if (!ContainBitmap(mNgBmp, bmp, ng_offs.X - padding2, ng_offs.Y - padding, ng_offs.X + padding2, ng_offs.Y + padding, ref outPos, 5))
                            {
                                if (bmp != null)
                                {
                                    bmp.Dispose();
                                    bmp = null;
                                }
                                break;
                            }
                            // 0.5[s] wait
                            System.Threading.Thread.Sleep(500);
                        }
                        break;
                    }
                    if (bmp != null)
                    {
                        bmp.Dispose();
                        bmp = null;
                    }

                    // 0.5[s] wait
                    FitWindowSize();
                    System.Threading.Thread.Sleep(500);
                }
            }

            //// Start領域
            //iRect = new Rectangle(p1.x+417, p1.y+512, 36, 28);
            //bmp = scr.Capture(iRect);
            //filePath = @"F:\FMEstart.bmp";
            //bmp.Save(filePath, ImageFormat.Bmp);

            //// Stop領域
            //iRect = new Rectangle(p1.x + 556, p1.y + 512, 34, 28);
            //bmp = scr.Capture(iRect);
            //filePath = @"F:\FMEstop.bmp";
            //bmp.Save(filePath, ImageFormat.Bmp);

            //// NG領域
            //iRect = new Rectangle(p1.x + 489, p1.y + 357, 21, 19);
            //bmp = scr.Capture(iRect);
            //filePath = @"F:\FMEng.bmp";
            //bmp.Save(filePath, ImageFormat.Bmp);

            //filePath = @"F:\screen.bmp";
            //Process.Start(filePath);

            //一秒間(1000ミリ秒)停止する
            System.Threading.Thread.Sleep(2000);

            if (bStartComplete)
            {
                using (Bouyomi bm = new Bouyomi())
                {
                    bm.Talk("えふえむいー配信を開始しました");
                }
            }
            else
            {
                using (Bouyomi bm = new Bouyomi())
                {
                    bm.Talk("えふえむいー起動失敗しました");
                }
                FMEGUI.Kill();
            }

            // ウインドウを最小化する
            ShowWindow(m_fme_hwnd, SW_MINIMIZE);
            return(bStartComplete);
        }