[Winform]Media Player組件全屏播放的設定

來源:互聯網
上載者:User

標籤:dia   png   logs   define   運行時   pre   ssi   事件   運行   

摘要

在設定程式開始運行時,讓視頻全屏播放時,直接設定

windowsMediaPlay.fullScreen = true;

會報錯,代碼如下

                windowsMediaPlay.URL = _videoPath;                windowsMediaPlay.Ctlcontrols.play();                windowsMediaPlay.fullScreen = true;                windowsMediaPlay.ClickEvent += windowsMediaPlay_ClickEvent;                windowsMediaPlay.KeyUpEvent += windowsMediaPlay_KeyUpEvent;                windowsMediaPlay.StatusChange += windowsMediaPlay_StatusChange;

錯誤

抱著相信微軟的心情,就在猜想,可能是位置不對,是不是必須視頻在播放中才可以設定全屏?

所以在視頻狀態變化的事件中,這樣設定

        void windowsMediaPlay_StatusChange(object sender, EventArgs e)        {            /*               * 0 Undefined Windows Media Player is in an undefined state.(未定義)                1 Stopped Playback of the current media item is stopped.(停止)                2 Paused Playback of the current media item is paused. When a media item is paused, resuming 
playback begins from the same location.(停留) 3 Playing The current media item is playing.(播放) 4 ScanForward The current media item is fast forwarding. 5 ScanReverse The current media item is fast rewinding. 6 Buffering The current media item is getting additional data from the server.(轉換) 7 Waiting Connection is established, but the server is not sending data. Waiting for session to begin.(暫停) 8 MediaEnded Media item has completed playback. (播放結束) 9 Transitioning Preparing new media item. 10 Ready Ready to begin playing.(準備就緒) 11 Reconnecting Reconnecting to stream.(重新串連) */ //判斷視頻是否已停止播放 if ((int)windowsMediaPlay.playState == 1) { //停頓2秒鐘再重新播放 System.Threading.Thread.Sleep(1000); //重新播放 windowsMediaPlay.Ctlcontrols.play(); } else if ((int)windowsMediaPlay.playState == 3) { windowsMediaPlay.fullScreen = true; } }

親測,解決問題。

[Winform]Media Player組件全屏播放的設定

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.