/// <summary> /// Erstellt eine neue Instanz von WMPlayer /// </summary> public WMPlayer() { _wmplayer = new WMPLib.WindowsMediaPlayer(); //Für den Media Player _playstatus = PlayStatus.Stop; Volume = 100; //Damit das Volume auf 100 ist Mute = false; //Damit es nicht stummgeschalten ist }
private void playSong() { WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = "sound/alert.mp3"; wplayer.controls.play(); }
private void Port_Box_TextChanged(object sender, EventArgs e) { if (comboBox1.Text == "MN (固定IP)" && Port_Box.Text != "" && Slot_Box.Text != "" && OnuID_Box.Text != "") { Cvlan_Box.Text = ((((int.Parse(Slot_Box.Text) - 1) * 4 + int.Parse(Port_Box.Text)) - 1) * 32 + (int.Parse(OnuID_Box.Text) - 1) + 1000).ToString(); } if (comboBox1.Text == "MN (固定IP)") { if (Port_Box.Text == "" || Slot_Box.Text == "" || OnuID_Box.Text == "") { Cvlan_Box.Text = "尚未填入完整Port位"; } } if (Port_Box.Text != "") { if (int.Parse(Port_Box.Text) > 4) { WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = $@"{AppDomain.CurrentDomain.BaseDirectory}DATA/MIC02.mp3"; wplayer.controls.play(); MessageBox.Show("哇賽 你的OLT 超過4個Portㄝ"); } } }
// ====================================VIP按鈕==================================== private void VIP_button_Click(object sender, EventArgs e) { if (textBox1.Text == "zong") { MessageBox.Show("Right!!"); int Desktop = 0; Desktop = SystemParametersInfo(20, 1, $@"{AppDomain.CurrentDomain.BaseDirectory}DATA/PIC01.jpg"); } else if (textBox1.Text == "yuqin") { WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = $@"{AppDomain.CurrentDomain.BaseDirectory}DATA/MIC04.mp3"; wplayer.controls.play(); MessageBox.Show("恭喜開通:一鍵開通功能!"); auto_button.Visible = true; richTextBox2.Visible = true; } else { WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = $@"{AppDomain.CurrentDomain.BaseDirectory}DATA/MIC01.mp3"; wplayer.controls.play(); MessageBox.Show("密碼提示:每個同事的英文名字都可能有不同效果"); } }
public static void loadSound(string filename) { WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer(); player.URL = filename; player.controls.play(); }
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { //listView1.FocusedItem.SubItems[0].Name WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = @"AUDIO\\" + listView1.FocusedItem.SubItems[0].Name + ".mp3"; wplayer.controls.play(); }
public Player(CallbackMethodDelegate callbackPlay) { this.callbackPlay = callbackPlay; player = new WMPLib.WindowsMediaPlayer(); player.PlayStateChange += new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(Player_PlayStateChange); Volume(30); }
private void button2_Click(object sender, EventArgs e) { if (this.current != null) { this.current.controls.stop(); } List <string> files = new List <string>(); foreach (Control item in Controls) { if (item is Label) { if (((Label)item).Text.Split(".".ToCharArray()).Length > 1) { files.Add(((Label)item).Text); } } } files = random.Shuffle <string>(files); WMPLib.WindowsMediaPlayer s = new WMPLib.WindowsMediaPlayer(); this.playlist = files.ToArray(); this.current = s; timer2.Enabled = true; //Initializes file times this.playTime = 0; this.currLength = SoundInfo.GetSoundLength(this.playlist[0]) / 1000; timer1.Enabled = true; }
private void L_Click(object sender, EventArgs e) { timer2.Enabled = false; if (this.current != null) { this.current.controls.stop(); } string file = ((Control)sender).Text; try { WMPLib.WindowsMediaPlayer s = new WMPLib.WindowsMediaPlayer(); s.URL = file; s.controls.play(); timer1.Enabled = true; //sets the global song playing varaibles this.current = s; this.currLength = SoundInfo.GetSoundLength(file) / 1000; playTime = 0; } catch (Exception exc) { MessageBox.Show(exc.Message); } }
private void timer1_Tick(object sender, EventArgs e) { if (current == null) { return; } label2.Text = "currently playing:" + current.URL.Split("\\".ToCharArray())[current.URL.Split("\\".ToCharArray()).Length - 1].Split(".".ToCharArray())[0]; //increasing current play time playTime += 0.1f; progressBar1.Value = (int)((playTime / (float)currLength) * MAX_PROGRESS_BAR); //sets progress bar text to the matching values //progressLabel.Text = TimeFormat((int)playTime) + "/" + TimeFormat(currLength); progressLabel.Text = ((int)playTime).ToString() + "/" + currLength.ToString(); if (playTime > currLength) { current = null; currLength = 0; playTime = 0; timer1.Enabled = false; progressLabel.Text = ""; playIndex++; } }
public void playSpam(string path) { WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer(); player.URL = path; player.controls.play(); spamPlayer.Add(player); }
private void PlayFile(String url) { Player = new WMPLib.WindowsMediaPlayer(); Player.PlayStateChange += Player_PlayStateChange; Player.URL = url; Player.controls.play(); }
public void PlaySound(string file) { try { string format = GetAudioFormat(file); if (format == MP3) { WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = file; wplayer.controls.play(); } else if (format == WAV) { SoundPlayer player = new SoundPlayer(file); player.Play(); } else { log.Error("Cannot play sound, unkown file format."); } } catch (Exception ex) { log.Error("Failed to play success sound:", ex); } }
public static void PlayCustomSound(string audioFilePath, int volumePerc, int repeats) { if (audioFilePath.Length > 0 && System.IO.File.Exists(audioFilePath)) { if (CheckWMPInstalled()) { WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); if (volumePerc > -1) { wplayer.settings.volume = volumePerc; } wplayer.settings.autoStart = false; wplayer.URL = audioFilePath; wplayer.controls.play(); wplayer = null; if (repeats > 1) { for (int i = 1; i < repeats; i++) { System.Threading.Thread.Sleep(500); PlayCustomSound(audioFilePath, volumePerc, 1); } } } else { throw new Exception("Notification cannot be raised! It appears Windows Media Player is not installed on this computer!"); } } }
public Form1() { InitializeComponent(); wmp = new WMPLib.WindowsMediaPlayer(); browseBtn.Focus(); }
public void SetTxt(String str) { textBox1.Text += str + Environment.NewLine; WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer(); player.URL = "http://tts.baidu.com/text2audio?lan=zh&pid=101&ie=UTF-8&text=" + str + "&spd=9"; player.controls.play(); }//委托的操作,player并没有关闭
public StreamDeck(StreamDeckButton[] buttons) { if (Constants.ENABLE_BUTTON_CLICK) { this._buttonClickSound = new WMPLib.WindowsMediaPlayer(); this._buttonClickSound.URL = @"Assets\Sounds\button-click.mp3"; this._buttonClickSound.controls.stop(); } // only activate the timer if it's greater than zero if (Constants.BACK_TO_MAIN_TIMER_IN_SECONDS > 0) { this._backToMain = new System.Timers.Timer(); this._backToMain.Interval = (int)TimeSpan.FromSeconds(Constants.BACK_TO_MAIN_TIMER_IN_SECONDS).TotalMilliseconds; this._backToMain.Enabled = true; this._backToMain.Elapsed += new System.Timers.ElapsedEventHandler(BackToMain); } this._streamDeck = StreamDeckSharp.StreamDeck.OpenDevice(); this._streamDeckButtons = buttons; this._streamDeck.KeyStateChanged += this.ButtonClicked; this.DrawButtons(); }
private void MessageCallBack(IAsyncResult aResult) { TextBox.CheckForIllegalCrossThreadCalls = false; try { byte[] RecivedData = new byte[Class1.j]; RecivedData = (byte[])aResult.AsyncState; ASCIIEncoding aEncoding = new ASCIIEncoding(); string RecivedMessage = aEncoding.GetString(RecivedData); string decmessage = dencryptus(RecivedMessage, key.Text.ToString()); ListMessages.Items.Add(decmessage); string path = System.IO.Directory.GetCurrentDirectory() + @"\inchat.mp3"; WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = path; wplayer.controls.play(); buffer = new byte[1500]; mySocket.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref epRemote, new AsyncCallback(MessageCallBack), buffer); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public static void seslendirme(string sesyol) { WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer(); player.URL = sesyol; player.controls.play(); System.Threading.Thread.Sleep(1000); }
/// <summary> /// Creates a new instance of the WindowsMediaPlayer class and returns it. /// </summary> /// <param name="audioPath">The path of the audio file.</param> /// <returns>Instance of the WindowsMediaPlayer class </returns> public static WMPLib.WindowsMediaPlayer GetAudioPlayer(String audioPath) { WMPLib.WindowsMediaPlayer Player = new WMPLib.WindowsMediaPlayer(); Player.MediaError += (o) => { MessageBox.Show("Unable to play audio notification.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }; Player.URL = audioPath; return Player; }
private void Nextsong() { WMPLib.WindowsMediaPlayer wmp = new WMPLib.WindowsMediaPlayer(); //adds song from playlist to currently playling and creates the new playlist if (currentlyplayingBoolean == false) { currentlyplayingString = playlist[0]; wmp.URL = applicationPath + "/media/" + currentlyplayingString; currentlyplayingBoolean = true; //sets the boolean to true to inform the system that a song i currently being played PresentlyPlayTxtBox.Text = currentlyplayingString; //Adds the song first on the paylist to currently playing textbox and var PlayListBox.Items.RemoveAt(0); //Removes first item from playlist box // Now to remove the first item on the playlist and shift the elements up in the array int count = 0; //used to count string check = ""; //can be used to terminate loop when theres no more elements to shift up while (check != null) //loop until we come accross a null element in the next cell { playlist[count] = playlist[count + 1]; //copies the cell beneath playlist[count + 1] = null; //clears the cell beneath count++; //increment count check = playlist[count + 1]; //change checker to next element in the list } } }
public WindowsMediaPlayer(string fileName) { wmPlayer = new WMPLib.WindowsMediaPlayer(); FileName = fileName; wmPlayer.settings.autoStart = false; wmPlayer.URL = FileName; }
private void Audio(int x) { try { WMPLib.WindowsMediaPlayer AudioSet = new WMPLib.WindowsMediaPlayer(); switch (x) { case 1: AudioSet.URL = path + @"\dhanushka\mesg_ting.mp3"; AudioSet.controls.play(); Thread.Sleep(500); break; case 2: AudioSet.URL = path + @"\dhanushka\alerto.mp3"; AudioSet.controls.play(); Thread.Sleep(500); break; case 3: AudioSet.URL = path + @"\dhanushka\alert.mp3"; AudioSet.controls.play(); Thread.Sleep(500); break; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
void PlaySound(String sound) { WMPLib.WindowsMediaPlayer Player; WMPLib.WindowsMediaPlayer winmp = new WMPLib.WindowsMediaPlayer(); winmp.URL = sound; winmp.controls.play(); }
private void button4_Click(object sender, EventArgs e) { //wav //SoundPlayer simpleSound = new SoundPlayer("https://www.majalisna.com/multimedia/408/208575-1275207271.wav"); //simpleSound.Play(); // wav //or you can use embedded resource //SoundPlayer sndplayr = new // SoundPlayer(Resources._1); //sndplayr.Play(); //mp3 //WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); //wplayer.URL = "114.mp3"; //wplayer.controls.play(); //or you can use online url // mp3 WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = "https://server8.mp3quran.net/ahmad_huth/001.mp3"; wplayer.controls.play(); }
private void button1_Click(object sender, EventArgs e) { WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer(); player.URL = project_path + "\\audio\\" + word_searched + ".mp3"; player.controls.play(); }
public frmYouWin() { InitializeComponent(); WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer(); player.URL = "sound.mp3"; player.controls.play(); }
private async void frmMain_Load(object sender, EventArgs e) { // setup notification sounds this._notificationPlayer = new WMPLib.WindowsMediaPlayer(); this._notificationPlayer.URL = @"Assets\Sounds\notification.mp3"; this._notificationPlayer.controls.stop(); // load up the buttons this._streamDeckButtons = Settings.LoadButtons(); // initialize the stream deck _streamDeck = new StreamDeck(this._streamDeckButtons); // create the notification object this._notification = new Notifications(); // check to see if we have permission to access the notifications if (!(await this._notification.RequestAccess())) { throw new Exception("Unable to get notification access from user"); } // setup the timer this._notificationCheckTimer = new Timer(); this._notificationCheckTimer.Interval = (int)TimeSpan.FromSeconds(Constants.CHECK_TIME_IN_SECONDS).TotalMilliseconds; this._notificationCheckTimer.Tick += new EventHandler(CheckNotification); this._notificationCheckTimer.Start(); // timer will execute every minute, so let's check notifications right on start up this.CheckNotification(null, null); }
public WordTestWindow() { InitializeComponent(); YahooPlayer = new WMPLib.WindowsMediaPlayer(); GooglePlayer = new WMPLib.WindowsMediaPlayer(); setTest(); }
public Veil() { InitializeComponent(); WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = @"C:\Users\Theodred\Desktop\The Veil\Resources\soundtrack.mp3"; wplayer.controls.play(); this.BackColor = Color.Black; this.Bounds = Screen.PrimaryScreen.Bounds; this.FormBorderStyle = FormBorderStyle.None; this.WindowState = FormWindowState.Maximized; label_Welcome.ForeColor = Color.White; label_Welcome.Location = new Point(x / 2 - label_Welcome.Size.Width / 2, 50); button_Start.Location = new Point(1 * x / 3 - 30 - button_Start.Size.Width, y - 100); //button_HowTo.Location = new Point(2 * x / 3 - 100 - button_HowTo.Size.Width, y - 100); button_AboutTheVeil.Location = new Point(3 * x / 3 - 100 - button_AboutTheVeil.Size.Width, y - 100); button_Start.BackColor = Color.Black; button_Start.ForeColor = Color.White; // button_HowTo.BackColor = Color.Black; //button_HowTo.ForeColor = Color.Red; button_AboutTheVeil.BackColor = Color.Black; button_AboutTheVeil.ForeColor = Color.White; panel_Welcome.BackColor = Color.Black; panel_Welcome.Location = new Point(label_Welcome.Location.X - 50, label_Welcome.Location.Y + 200); panel_Welcome.Size = new Size(label_Welcome.Location.X + label_Welcome.Size.Width - 100, button_AboutTheVeil.Location.Y - label_Welcome.Location.Y - 250); this.Focus(); }
void SeThreadMain() { for (int i = 0; i < ConfigReader.Instance.MaxSENum; i++) { WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer(); if (player != null) { player.settings.autoStart = true; sePlayers.Add(player); } } while (true) { seMutex.WaitOne(); List <string> playQueue = seQueue; seQueue = new List <string>(); seMutex.ReleaseMutex(); foreach (string file in playQueue) { PlayAudioInThread(file); } System.Threading.Thread.Sleep(50); } }
public void Play(int vol) { WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = trackPath; wplayer.settings.volume = vol; wplayer.controls.play(); }
public frmYouWin2(ref WMPLib.WindowsMediaPlayer player, bool mute, bool levelTwo, bool levelThree) { InitializeComponent(); // set variables equal to parameters level2 = levelTwo; level3 = levelThree; muteForm = mute; youWin2Player = player; if (muteForm == false) { // play the music winPlayer.URL = "YouWin.mp3"; winPlayer.controls.play(); } else { // stop the music winPlayer.controls.stop(); } // set the level2 variable equal to true level2 = true; // set the level3 variable equal to true level3 = true; }
private void playSound(string filename) { this.wmediaplayer = new WMPLib.WindowsMediaPlayer(); this.wmediaplayer.URL = filename; this.wmediaplayer.settings.volume = 100; this.wmediaplayer.controls.play(); }
public MainForm() { InitializeComponent(); soundFileDialog.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyMusic); challengeFileDialog.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); wmPlayer = new WMPLib.WindowsMediaPlayer(); defaultPlaybackDevice = new CoreAudioController().DefaultPlaybackDevice; }
public static void Play() { WMPLib.WindowsMediaPlayer pssPss = new WMPLib.WindowsMediaPlayer(); (pssPss.settings as WMPLib.IWMPSettings).setMode("loop", true); string filePath = Path.GetFullPath("daveDeath.wav"); pssPss.URL = filePath; // pssPss.Play }
private void Speak_cmd() { string sound_url = iSpeechAPI.Synthesis(LearningItem.CurrentSub.Text); WMPLib.WindowsMediaPlayer wmp = new WMPLib.WindowsMediaPlayer(); wmp.URL = sound_url; wmp.settings.volume = LearningItem.SpeechVolume; wmp.controls.play(); }
public Accueil() { InitializeComponent(); wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = "H:/Bureau/Harmonition - Accueil/Harmonition - Accueil/FichiersAudio/ValleeGerudo.mp3"; wplayer.controls.play(); }
public Form1() { InitializeComponent(); myOps = new Options(); mfiles = new List<mFile>(); files = new List<string>(); a = new WMPLib.WindowsMediaPlayer(); a.OpenStateChange += new WMPLib._WMPOCXEvents_OpenStateChangeEventHandler(a_OpenStateChange); }
public MediaPlyr(string file) { InitializeComponent(); this.Paint += new PaintEventHandler(MediaPlyr_Paint); #if !MONO mPlayer = new WMPLib.WindowsMediaPlayer(); mPlayer.URL = file; #endif mName = Path.GetFileName(file); }
public static void test2() { WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer(); WMPLib.IWMPMedia media = player.newMedia("ftp://90.184.75.15/OpenShare/Music/Morten/Deadmau5/Random Album Title/07 I Remember.mp3"); player.NewStream += new WMPLib._WMPOCXEvents_NewStreamEventHandler(player_NewStream); player.controls.playItem(media); }
public static void PlaySound(string soundfile) { WMPLib.WindowsMediaPlayer Player; Player = new WMPLib.WindowsMediaPlayer(); Player.PlayStateChange += new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(Player_PlayStateChange); Player.URL = soundfile; Player.controls.play(); }
//contructor public CurrentSongViewModel(PlayerEngineModel playerModel) { _player = playerModel.MediaPlayer; _controls = _player.controls; IsPlaying = false; HasPlayed = false; PlayPauseCommand = new PlayPauseCommand(this); StopCommand = new StopCommand(this); }
public MenuState() { Initialize(); string da = Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase); mplayer = new WMPLib.WindowsMediaPlayer(); Directory.GetCurrentDirectory(); mplayer.URL = Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase) + @"\Content\songs\menu.mp3"; mplayer.settings.setMode("loop", false); mplayer.controls.play(); stopMenu = false; }
/// <summary> /// Construct the Music Player /// </summary> public MusicPlayer() { artists = new List<Artist>(); songs = new List<Song>(); playlists = new List<Playlist>(); wplayer = new WMPLib.WindowsMediaPlayer(); currentlyPlaying = null; currentlyPlayingList = null; }
public void Play(string path) { player.controls.stop(); player.close(); player = new WMPLib.WindowsMediaPlayer(); player.PlayStateChange += new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(Player_PlayStateChange); player.URL = path; player.controls.play(); }
private void definesound() { WindowsMediaPlayer1 = new WMPLib.WindowsMediaPlayer(); WindowsMediaPlayer2 = new WMPLib.WindowsMediaPlayer(); WindowsMediaPlayer3 = new WMPLib.WindowsMediaPlayer(); WindowsMediaPlayer4 = new WMPLib.WindowsMediaPlayer(); WindowsMediaPlayer5 = new WMPLib.WindowsMediaPlayer(); WindowsMediaPlayer6 = new WMPLib.WindowsMediaPlayer(); WindowsMediaPlayer7 = new WMPLib.WindowsMediaPlayer(); WindowsMediaPlayer8 = new WMPLib.WindowsMediaPlayer(); }
private void MainForm_Load(object sender, EventArgs e) { // create media player object m_pMediaPlayer = new WMPLib.WindowsMediaPlayerClass(); // get list of albums WMPLib.IWMPStringCollection lAlbums = m_pMediaPlayer.mediaCollection.getAttributeStringCollection("WM/AlbumTitle", "audio"); lsbAlbums.BeginUpdate(); for (int i = 0, length = lAlbums.count; i < length; i++) { lsbAlbums.Items.Add(lAlbums.Item(i)); } lsbAlbums.EndUpdate(); }
public static void test1() { WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer(); player.settings.autoStart = false; player.URL = @"C:\Users\Morten Hulvej\Desktop\07 I Remember.mp3"; player.controls.play(); for (int i = 10; i > 0; i--) { Console.WriteLine("Going to sleep for " + i + " seconds.."); System.Threading.Thread.Sleep(1000); } }
public static bool StopPlayingSound() { try { if (windows_media_player != null) { windows_media_player.controls.stop(); } windows_media_player = null; return true; } catch (Exception) { return false; } }
public static bool PlaySound() { try { if (windows_media_player == null) { windows_media_player = new WMPLib.WindowsMediaPlayer(); windows_media_player.URL = ALARM_SOUND; windows_media_player.settings.setMode(WMP_MODE, true); windows_media_player.controls.play(); return true; } } catch (Exception) { } return false; }
/// <summary> /// PlayRight method that takes boolean if mute option is enabled, /// and plays audio file if it is not. /// </summary> /// <param name="playing">boolean true/false</param> /// <returns>boolean true/false just for unit testing</returns> public bool PlayRight(bool playing) { string directoryName = Path.GetDirectoryName(Directory.GetCurrentDirectory()); directoryName = Path.GetDirectoryName(directoryName); directoryName = Path.GetDirectoryName(directoryName); directoryName = directoryName + "\\set_sounds\\right\\"; var rand = new Random(); var soundFiles = Directory.GetFiles(directoryName, "*wav"); var playSound = soundFiles[rand.Next(0, soundFiles.Length)]; var player = new WMPLib.WindowsMediaPlayer(); if (playing == true) { player.URL = playSound; return true; } return false; }
public TetrisForm() { InitializeComponent(); //stops panel flickering on redraw typeof(Panel).InvokeMember("DoubleBuffered", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, tetrisPanel, new object[] { true }); typeof(Panel).InvokeMember("DoubleBuffered", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, previewShapePanel, new object[] { true }); #region Variable_Initialization defaultBrush = new SolidBrush(Color.Blue); defaultPen = new Pen(Color.LimeGreen, 1); types = new char[] { 'L', 'J', 'S', 'Z', 'T', 'O', 'I' }; grid = new bool[ROWS, COLS]; fillBrushes = new Brush[ROWS, COLS]; borderPens = new Pen[ROWS, COLS]; points = 0; backgroundThemePlayer = new WMPLib.WindowsMediaPlayer(); backgroundThemePlayer.URL = BACKGROUND_THEME_URL; backgroundThemePlayer.settings.setMode("Loop", true); backgroundThemePlayer.controls.stop(); gamePlaying = false; futureShapes = new Queue<Tetromino>(SHAPES_TO_STORE); level = 0; rows = 0; #endregion StyleGUI(); //InitializeTetrisPanel(); SetupNewGame(); }
public void perform(IntPtr winPointer) { SetForegroundWindow(winPointer); ShowWindow(winPointer, 5); foreach (Actions a in actionList) { a.perform(); } if (answering && answeringString != null) { try { SpeechSynthesizer synth = new SpeechSynthesizer(); if (synth != null) { synth.SpeakAsync(answeringString); } } catch { } } if (answeringSound && answeringSoundPath != null) { if (answeringSoundPath.IndexOf(".wav") == answeringSoundPath.Length - 4) { System.Media.SoundPlayer player = new System.Media.SoundPlayer(); player.SoundLocation = answeringSoundPath; player.Play(); } else if (answeringSoundPath.IndexOf(".mp3") == answeringSoundPath.Length - 4) { WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = answeringSoundPath; wplayer.controls.play(); } } }
public SongPlayer() { WPlayer = new WMPLib.WindowsMediaPlayer(); }
public musicCmd(int i) { which_command = i; if (!init_run) { init_run = true; loadTemplate(); if (Player == null) Player = new WMPLib.WindowsMediaPlayer(); } }
static void WalkDirectoryTree(System.IO.DirectoryInfo root) { System.IO.FileInfo[] files = null; System.IO.DirectoryInfo[] subDirs = null; WMPLib.WindowsMediaPlayer w = new WMPLib.WindowsMediaPlayer(); try { files = root.GetFiles("*.*"); } // This is thrown if even one of the files requires permissions greater // than the application provides. catch (UnauthorizedAccessException e) { log.Add(e.Message); } catch (System.IO.DirectoryNotFoundException e) { Console.WriteLine(e.Message); } if (files != null) { foreach (System.IO.FileInfo fi in files) { if (fi.Extension.ToLower() == ".mp3") { Console.WriteLine(fi.FullName); WMPLib.IWMPMedia m = w.newMedia(fi.FullName); if (m != null || m.duration != null) { if (m.duration >= dblMinDuration) { sourceMp3Files.Add(fi); } } } } // Now find all the subdirectories under this directory. subDirs = root.GetDirectories(); foreach (System.IO.DirectoryInfo dirInfo in subDirs) { // Resursive call for each subdirectory. WalkDirectoryTree(dirInfo); } } w.close(); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); OpenFileDialog open = new OpenFileDialog(); if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { f = openFileDialog1.SafeFileNames; p = openFileDialog1.FileNames; for (int i = 0; i < f.Length; i++) { listBox1.Items.Add(f[i]); } /* foreach (string d in open.FileName) { listBox1.Items.Add(d); } */ } }
const string VideoFile = @"tohou.mp4"; // Bad apple!! original video (03:39 length) #endregion Fields #region Methods static void Main(string[] args) { var files = Directory.EnumerateFiles(ImagePath).ToList(); var images = files.Select(File.ReadAllBytes).ToArray(); WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer(); player.settings.autoStart = false; player.settings.playCount = 1000; player.URL = VideoFile; Thread.Sleep(1000); // let wmp to finish all the loading shit var com = new System.IO.Ports.SerialPort(PortName, 115200, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One); com.Open(); int currentImage = 0; bool isPlaying = false; while (currentImage < images.Length) { com.ReadByte(); if (!isPlaying) { player.controls.play(); isPlaying = true; } var currentPosition = player.controls.currentPosition; currentImage = (int)(FPS * currentPosition); com.Write(images[Math.Min(currentImage, images.Length - 1)], 0, 504); } com.Close(); }