//------------------------------------------------------------- // 概要:MovieStartイベントが発生するか確認 //------------------------------------------------------------- private static void OpenTest(string streamUrl) { // 再生中の判定 bool isPlaying = false; // イベント登録 PecaPlayerForm form = new PecaPlayerForm(); form.Show(); PecaPlayerControl pecaPlayer = form.pecaPlayer; PrivateObject accessor = new PrivateObject(pecaPlayer); IMoviePlayer moviePlayer = (IMoviePlayer)accessor.GetField("moviePlayer"); moviePlayer.MovieStart += (sender, e) => { isPlaying = true; }; // テスト対象を実行 pecaPlayer.Open(streamUrl); // 再生されるまで待つ while (isPlaying == false) { Application.DoEvents(); Thread.Sleep(100); } }
//------------------------------------------------------------- // 概要:コマンド作成 //------------------------------------------------------------- private void CreateCommand(Form form, PecaPlayerControl pecaPlayer, StatusBarControl statusBar) { commandMap = new Dictionary <Commands, ShortcutCommand>() { { Commands.None, new ShortcutCommand(new NullCommand(), new CommandArgs()) }, // 処理なし { Commands.VolumeUp, new ShortcutCommand(new VolumeUpCommand(pecaPlayer), new CommandArgs()) }, // 音量UP { Commands.VolumeDown, new ShortcutCommand(new VolumeDownCommand(pecaPlayer), new CommandArgs()) }, // 音量DOWN { Commands.VolumeBalanceLeft, new ShortcutCommand(new VolumeBalanceCommand(pecaPlayer), new VolumeBalanceCommandArgs(VolumeBalanceCommandArgs.BalanceLeft)) }, // 音量バランス:左 { Commands.VolumeBalanceMiddle, new ShortcutCommand(new VolumeBalanceCommand(pecaPlayer), new VolumeBalanceCommandArgs(VolumeBalanceCommandArgs.BalanceMiddle)) }, // 音量バランス:中央 { Commands.VolumeBalanceRight, new ShortcutCommand(new VolumeBalanceCommand(pecaPlayer), new VolumeBalanceCommandArgs(VolumeBalanceCommandArgs.BalanceRight)) }, // 音量バランス:右 { Commands.Mute, new ShortcutCommand(new MuteCommand(pecaPlayer), new CommandArgs()) }, // ミュート切替 { Commands.WindowMinimize, new ShortcutCommand(new WindowMinimize(form), new CommandArgs()) }, // ウィンドウを最小化 { Commands.WindowMaximize, new ShortcutCommand(new WindowMaximize(form), new CommandArgs()) }, // ウィンドウを最大化 { Commands.MiniMute, new ShortcutCommand(new MiniMuteCommand(form, pecaPlayer), new CommandArgs()) }, // 最小化ミュート { Commands.Close, new ShortcutCommand(new CloseCommand(form, pecaPlayer), new CommandArgs()) }, // 閉じる { Commands.VisibleStatusBar, new ShortcutCommand(new VisibleStatusBarCommand(form, statusBar), new CommandArgs()) }, // ステータスバーの表示切り替え { Commands.OpenPeerstViewer, new ShortcutCommand(new OpenPeerstViewerCommand(statusBar), new CommandArgs()) }, // PeerstViewerを開く { Commands.UpdateChannelInfo, new ShortcutCommand(new UpdateChannelInfoCommand(pecaPlayer), new CommandArgs()) }, // チャンネル情報更新 //{ Commands.ShowNewRes, new ShortcutCommand(new ShowNewResCommand(form, statusBar), new CommandArgs()) }, // 新着レス表示 { Commands.TopMost, new ShortcutCommand(new TopMostCommand(form), new CommandArgs()) }, // 最前列表示切り替え { Commands.WindowSizeUp, new ShortcutCommand(new WindowSizeUpCommand(form, pecaPlayer), new CommandArgs()) }, // ウィンドウサイズUP { Commands.WindowSizeDown, new ShortcutCommand(new WindowSizeDownCommand(form, pecaPlayer), new CommandArgs()) }, // ウィンドウサイズDOWN { Commands.DisconnectRelay, new ShortcutCommand(new DisconnectRelayCommand(form, pecaPlayer), new CommandArgs()) }, // リレー切断 { Commands.Bump, new ShortcutCommand(new BumpCommand(pecaPlayer), new CommandArgs()) }, // Bump { Commands.RetryPlayer, new ShortcutCommand(new RetryPlayerCommand(pecaPlayer), new CommandArgs()) }, // 再接続(プレイヤー) { Commands.WmpMenu, new ShortcutCommand(new WmpMenuCommand(pecaPlayer), new CommandArgs()) }, // WMPメニュー表示 { Commands.FitMovieSize, new ShortcutCommand(new FitMovieSizeCommand(form, pecaPlayer), new CommandArgs()) }, // 黒枠を消す { Commands.WindowSize160x120, new ShortcutCommand(new WindowSizeCommand(form, pecaPlayer), new WindowSizeCommandArgs(160, 120)) }, // ウィンドウサイズ指定 { Commands.WindowSize320x240, new ShortcutCommand(new WindowSizeCommand(form, pecaPlayer), new WindowSizeCommandArgs(320, 240)) }, // ウィンドウサイズ指定 { Commands.WindowSize480x360, new ShortcutCommand(new WindowSizeCommand(form, pecaPlayer), new WindowSizeCommandArgs(480, 360)) }, // ウィンドウサイズ指定 { Commands.WindowSize640x480, new ShortcutCommand(new WindowSizeCommand(form, pecaPlayer), new WindowSizeCommandArgs(640, 480)) }, // ウィンドウサイズ指定 { Commands.WindowSize800x600, new ShortcutCommand(new WindowSizeCommand(form, pecaPlayer), new WindowSizeCommandArgs(800, 600)) }, // ウィンドウサイズ指定 { Commands.WindowScale25Per, new ShortcutCommand(new WindowScaleCommand(form, pecaPlayer), new WindowScaleCommandArgs(0.25f)) }, // ウィンドウサイズ拡大率指定 { Commands.WindowScale50Per, new ShortcutCommand(new WindowScaleCommand(form, pecaPlayer), new WindowScaleCommandArgs(0.5f)) }, // ウィンドウサイズ拡大率指定 { Commands.WindowScale75Per, new ShortcutCommand(new WindowScaleCommand(form, pecaPlayer), new WindowScaleCommandArgs(0.75f)) }, // ウィンドウサイズ拡大率指定 { Commands.WindowScale100Per, new ShortcutCommand(new WindowScaleCommand(form, pecaPlayer), new WindowScaleCommandArgs(1.0f)) }, // ウィンドウサイズ拡大率指定 { Commands.WindowScale150Per, new ShortcutCommand(new WindowScaleCommand(form, pecaPlayer), new WindowScaleCommandArgs(1.5f)) }, // ウィンドウサイズ拡大率指定 { Commands.WindowScale200Per, new ShortcutCommand(new WindowScaleCommand(form, pecaPlayer), new WindowScaleCommandArgs(2.0f)) }, // ウィンドウサイズ拡大率指定 { Commands.ScreenSplitWidthx5, new ShortcutCommand(new ScreenSplitCommand(form, pecaPlayer), new ScreenSplitCommandArgs(5, -1)) }, // 画面分割 { Commands.ScreenSplitWidthx4, new ShortcutCommand(new ScreenSplitCommand(form, pecaPlayer), new ScreenSplitCommandArgs(4, -1)) }, // 画面分割 { Commands.ScreenSplitWidthx3, new ShortcutCommand(new ScreenSplitCommand(form, pecaPlayer), new ScreenSplitCommandArgs(3, -1)) }, // 画面分割 { Commands.ScreenSplitWidthx2, new ShortcutCommand(new ScreenSplitCommand(form, pecaPlayer), new ScreenSplitCommandArgs(2, -1)) }, // 画面分割 { Commands.ScreenSplitWidthx1, new ShortcutCommand(new ScreenSplitCommand(form, pecaPlayer), new ScreenSplitCommandArgs(1, -1)) }, // 画面分割 { Commands.ScreenSplitHeightx5, new ShortcutCommand(new ScreenSplitCommand(form, pecaPlayer), new ScreenSplitCommandArgs(-1, 5)) }, // 画面分割 { Commands.ScreenSplitHeightx4, new ShortcutCommand(new ScreenSplitCommand(form, pecaPlayer), new ScreenSplitCommandArgs(-1, 4)) }, // 画面分割 { Commands.ScreenSplitHeightx3, new ShortcutCommand(new ScreenSplitCommand(form, pecaPlayer), new ScreenSplitCommandArgs(-1, 3)) }, // 画面分割 { Commands.ScreenSplitHeightx2, new ShortcutCommand(new ScreenSplitCommand(form, pecaPlayer), new ScreenSplitCommandArgs(-1, 2)) }, // 画面分割 { Commands.ScreenSplitHeightx1, new ShortcutCommand(new ScreenSplitCommand(form, pecaPlayer), new ScreenSplitCommandArgs(-1, 1)) }, // 画面分割 { Commands.Screenshot, new ShortcutCommand(new ScreenshotCommand(pecaPlayer), new CommandArgs()) }, // スクリーンショット { Commands.OpenScreenshotFolder, new ShortcutCommand(new OpenScreenshotFolderCommand(), new CommandArgs()) }, // スクリーンショットフォルダを開く }; }
public ScreenshotCommand(PecaPlayerControl pecaPlayer) { this.pecaPlayer = pecaPlayer; worker.DoWork += (sender, args) => { // コンテキストメニューから呼ばれた時用に少し待機する Thread.Sleep(50); pecaPlayer.Invoke((MethodInvoker)(() => { // // SSのディレクトリが存在していなければ作る if (!Directory.Exists(PlayerSettings.ScreenshotFolder)) { Directory.CreateDirectory(PlayerSettings.ScreenshotFolder); } var fileName = Format(PlayerSettings.ScreenshotFormat, pecaPlayer.ChannelInfo); // 書式にディレクトリが含まれているかもしれないので確認しておく if (!Directory.Exists(PlayerSettings.ScreenshotFolder + Path.GetDirectoryName(fileName))) { Directory.CreateDirectory(PlayerSettings.ScreenshotFolder + Path.GetDirectoryName(fileName)); } // SS撮影 using (var image = new Bitmap(pecaPlayer.Width, pecaPlayer.Height, PixelFormat.Format24bppRgb)) using (var graphics = Graphics.FromImage(image)) { var location = pecaPlayer.Location; var screenPoint = pecaPlayer.PointToScreen(location); graphics.CopyFromScreen(screenPoint.X, screenPoint.Y, 0, 0, image.Size); var format = GetImageFormat(PlayerSettings.ScreenshotExtension); var name = string.Format("{0}/{1}.{2}", PlayerSettings.ScreenshotFolder, fileName, format.ToString().ToLower()); try { image.Save(name, format); } catch (ExternalException) { MessageBox.Show(pecaPlayer, "スクリーンショットの保存に失敗しました。\n" + "保存フォルダが間違っている、既にファイルが開かれている、\n" + "ドライブの空き容量が無い可能性があります。", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } })); }; }
//------------------------------------------------------------- // 概要:初期化 //------------------------------------------------------------- public void Init(PlayerView playerView, PecaPlayerControl pecaPlayer, StatusBarControl statusBar) { // コマンド作成 CreateCommand(playerView, pecaPlayer, statusBar); // ショートカット設定の読み込み try { settings = SettingSerializer.LoadSettings <ShortcutSettings>("ShortcutSettings.xml"); } catch { Logger.Instance.Error("ショートカット設定ファイルの読み込みに失敗したため、デフォルト設定を読み込みます。"); LoadDefaultSettings(); } // 設定ファイルが壊れている場合 if ((settings.EventMap == null) || (settings.GestureMap == null) || (settings.KeyMap == null)) { Logger.Instance.Error("ショートカット設定ファイルが壊れているため、デフォルト設定を読み込みます。"); LoadDefaultSettings(); } }
public WindowSizeCommand(Form form, PecaPlayerControl pecaPlayer) { this.form = form; this.pecaPlayer = pecaPlayer; }
public DisconnectRelayCommand(Form form, PecaPlayerControl pecaPlayer) { this.form = form; this.pecaPlayer = pecaPlayer; }
public UpdateChannelInfoCommand(PecaPlayerControl pecaPlayer) { this.pecaPlayer = pecaPlayer; }
public MuteCommand(PecaPlayerControl pecaPlayer) { this.pecaPlayer = pecaPlayer; }
public FlashMoviePlayerControl(PecaPlayerControl parent) { try { InitializeComponent(); } catch (COMException) { MessageBox.Show("Flash Playerがインストールされていません。\nInternet ExplorerからFlash Playerをインストールする必要があります。", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } Dock = DockStyle.Fill; // FlashManagerの初期化 flashManager = new FlashMoviePlayerManager(axShockwaveFlash); flashManager.Initialized += (sender, args) => { flashManager.EnableGpu(PlayerSettings.Gpu); flashManager.EnableRtmp(PlayerSettings.Rtmp); flashManager.SetBufferTime(PlayerSettings.BufferTime); flashManager.SetBufferTimeMax(PlayerSettings.BufferTimeMax); }; // ステート変更イベント flashManager.OpenStateChange += (sender, args) => { if (isFirstMediaOpen) { var width = ((IMoviePlayer)this).ImageWidth; var height = ((IMoviePlayer)this).ImageHeight; axShockwaveFlash.Width = width; axShockwaveFlash.Height = height; movieStart(this, new EventArgs()); isFirstMediaOpen = false; } // 動画切替時に、ミュートが解除されるための対応 ((IMoviePlayer)this).Mute = isMute; if (!isMute) { flashManager.ChangeVolume(volume); } }; // プレイヤーからBump要求のイベント flashManager.RequestBump += (sender, args) => parent.Bump(); // 再生支援を使う設定が変更されたら PlayerSettings.Changed += (s) => { switch (s) { case "Gpu": flashManager.EnableGpu(PlayerSettings.Gpu); break; case "Rtmp": flashManager.EnableRtmp(PlayerSettings.Rtmp); break; case "BufferTime": flashManager.SetBufferTime(PlayerSettings.BufferTime); break; case "BufferTimeMax": flashManager.SetBufferTimeMax(PlayerSettings.BufferTimeMax); break; } }; // Flashウィンドウをフックする FlashNativeWindow flash = new FlashNativeWindow(axShockwaveFlash); flash.MouseDownEvent += (sender, e) => { mouseDownEvent(this, e); Focus(); }; flash.MouseUpEvent += (sender, e) => mouseUpEvent(this, e); flash.MouseMoveEvent += (sender, e) => mouseMoveEvent(this, e); flash.DoubleClickEvent += (sender, e) => doubleClickEvent(this, e); flash.KeyDownEvent += (sender, e) => keyDownEvent(this, e); }
public WmpMenuCommand(PecaPlayerControl pecaPlayer) { this.pecaPlayer = pecaPlayer; }
public RetryPlayerCommand(PecaPlayerControl pecaPlayer) { this.pecaPlayer = pecaPlayer; }
public BumpCommand(PecaPlayerControl pecaPlayer) { this.pecaPlayer = pecaPlayer; }
public ScreenSplitCommand(Form form, PecaPlayerControl pecaPlayer) { this.form = form; this.pecaPlayer = pecaPlayer; }
public VolumeDownCommand(PecaPlayerControl pecaPlayer) { this.pecaPlayer = pecaPlayer; }
public FitMovieSizeCommand(Form form, PecaPlayerControl pecaPlayer) { this.form = form; this.pecaPlayer = pecaPlayer; }
public CloseCommand(Form form, PecaPlayerControl pecaPlayer) { this.form = form; this.pecaPlayer = pecaPlayer; }
public VolumeBalanceCommand(PecaPlayerControl pecaPlayer) { this.pecaPlayer = pecaPlayer; }