久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

c# winform播放MP4視頻

 心有樹(shù) 2024-07-24

1,、在所有windows窗體中添加windows media player控件

 

 

2,、拖入windows media player控件,編寫(xiě)代碼

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Linq;
  8. using System.Windows.Forms;
  9. using DevExpress.XtraEditors;
  10. namespace DXProject.Core.page
  11. {
  12. public partial class YrForm : DevExpress.XtraEditors.XtraForm
  13. {
  14. public YrForm(string path)
  15. {
  16. InitializeComponent();
  17. try
  18. {
  19. SetStyle(ControlStyles.UserPaint, true);
  20. SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
  21. SetStyle(ControlStyles.DoubleBuffer, true); // 雙緩沖
  22. //FileDialog open = new OpenFileDialog();
  23. //wxWindowsMediaplayer1是控件名
  24. this.axWindowsMediaPlayer1.settings.playCount = 1;//播放次數(shù),;
  25. //open.Filter = "*.mp4|*.mp4"; //文件格式
  26. //open.Title = "打開(kāi)文件";
  27. //if (open.ShowDialog() == DialogResult.OK)
  28. {
  29. axWindowsMediaPlayer1.URL = path;
  30. axWindowsMediaPlayer1.Ctlcontrols.play();//播放文件
  31. axWindowsMediaPlayer1.StatusChange += windowsMediaPlay_StatusChange;
  32. }
  33. }
  34. catch { }
  35. }
  36. #region 解決閃爍問(wèn)題
  37. protected override void WndProc(ref Message m)
  38. {
  39. if (m.Msg == 0x0014) // 禁掉清除背景消息
  40. return;
  41. base.WndProc(ref m);
  42. }
  43. protected override CreateParams CreateParams
  44. {
  45. get
  46. {
  47. CreateParams cp = base.CreateParams;
  48. cp.ExStyle |= 0x02000000;
  49. return cp;
  50. }
  51. }
  52. #endregion
  53. void windowsMediaPlay_StatusChange(object sender, EventArgs e)
  54. {
  55. /*
  56. * 0 Undefined Windows Media Player is in an undefined state.(未定義)
  57. 1 Stopped Playback of the current media item is stopped.(停止)
  58. 2 Paused Playback of the current media item is paused. When a media item is paused, resuming playback begins from the same location.(停留)
  59. 3 Playing The current media item is playing.(播放)
  60. 4 ScanForward The current media item is fast forwarding.
  61. 5 ScanReverse The current media item is fast rewinding.
  62. 6 Buffering The current media item is getting additional data from the server.(轉(zhuǎn)換)
  63. 7 Waiting Connection is established, but the server is not sending data. Waiting for session to begin.(暫停)
  64. 8 MediaEnded Media item has completed playback. (播放結(jié)束)
  65. 9 Transitioning Preparing new media item.
  66. 10 Ready Ready to begin playing.(準(zhǔn)備就緒)
  67. 11 Reconnecting Reconnecting to stream.(重新連接)
  68. */
  69. //判斷視頻是否已停止播放
  70. if ((int)axWindowsMediaPlayer1.playState == 1)
  71. {
  72. //停頓2秒鐘再重新播放
  73. System.Threading.Thread.Sleep(100);
  74. //重新播放
  75. //axWindowsMediaPlayer1.Ctlcontrols.play();
  76. }
  77. else if ((int)axWindowsMediaPlayer1.playState == 3)
  78. {
  79. //axWindowsMediaPlayer1.fullScreen = true;
  80. // this.axWindowsMediaPlayer1.Ctlcontrols.stop();
  81. }
  82. }
  83. private void YrForm_Load(object sender, EventArgs e)
  84. {
  85. }
  86. private void YrForm_FormClosing(object sender, FormClosingEventArgs e)
  87. {
  88. //this.axWindowsMediaPlayer1.Ctlcontrols.stop();
  89. }
  90. private void simpleButton1_Click(object sender, EventArgs e)
  91. {
  92. axWindowsMediaPlayer1.fullScreen = true;
  93. }
  94. }
  95. }

 

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn),。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多