Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  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.Windows.Forms;
  8. using System.IO;
  9. using WMPLib;
  10.  
  11. namespace Mp3Player
  12. {
  13. public partial class Form1 : Form
  14. {
  15. IWMPMedia WmpMedia;
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. Player.uiMode = "None";
  20. }
  21. private void btnAdd_Click(object sender, EventArgs e)
  22. {
  23. if (openFileDialog1.ShowDialog() == DialogResult.OK)
  24. {
  25. string[] FileN = openFileDialog1.FileNames;
  26. foreach (string N in FileN)
  27. {
  28. lbPlaylist.Items.Add(Path.GetFileNameWithoutExtension(N));
  29. WmpMedia = Player.newMedia(N);
  30. Player.currentPlaylist.appendItem(WmpMedia);
  31. }
  32. Player.Ctlcontrols.play();
  33. Player.URL = "";
  34.  
  35. }
  36. }
  37.  
  38. private void btnNext_Click(object sender, EventArgs e)
  39. {
  40.  
  41. Player.Ctlcontrols.next();
  42. }
  43.  
  44. private void btnPre_Click(object sender, EventArgs e)
  45. {
  46. Player.Ctlcontrols.previous();
  47. }
  48.  
  49. private void btnPlay_Click(object sender, EventArgs e)
  50. {
  51. Player.Ctlcontrols.play();
  52. }
  53.  
  54. private void btnPause_Click(object sender, EventArgs e)
  55. {
  56. Player.Ctlcontrols.pause();
  57. }
  58.  
  59. private void Form1_Load(object sender, EventArgs e)
  60. {
  61. tbVol.Value = Player.settings.volume;
  62. }
  63.  
  64. private void tbVol_Scroll(object sender, EventArgs e)
  65. {
  66. Player.settings.volume = tbVol.Value;
  67.  
  68. }
  69.  
  70. private void Player_MediaError(object sender, AxWMPLib._WMPOCXEvents_MediaErrorEvent e)
  71. {
  72. MessageBox.Show("Can't play this file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  73. }
  74.  
  75. private void Player_CurrentItemChange(object sender, AxWMPLib._WMPOCXEvents_CurrentItemChangeEvent e)
  76. {
  77. lbPlay.Text = Player.currentMedia.name + " " + Player.currentMedia.durationString;
  78. }
  79.  
  80. private void btnFF_Click(object sender, EventArgs e)
  81. {
  82. try
  83. {
  84. Player.settings.rate++;
  85.  
  86. }
  87. catch
  88. {
  89.  
  90. }
  91. }
  92.  
  93. private void button1_Click(object sender, EventArgs e)
  94. {
  95. try
  96. {
  97. Player.settings.rate--;
  98. }
  99. catch
  100. {
  101.  
  102. }
  103. }
  104.  
  105. private void lbPlaylist_DoubleClick(object sender, EventArgs e)
  106. {
  107. try
  108. {
  109. int idx = lbPlaylist.SelectedIndex;
  110. WmpMedia = Player.currentPlaylist.get_Item(idx);
  111. if (Player.currentMedia.name != WmpMedia.name)
  112. {
  113. Player.Ctlcontrols.playItem(WmpMedia);
  114. }
  115. }
  116. catch
  117. {
  118.  
  119. }
  120.  
  121. }
  122.  
  123. private void lbPlaylist_SelectedIndexChanged(object sender, EventArgs e)
  124. {
  125.  
  126. }
  127. }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement