private void frmTV_Load(object sender, EventArgs e) { try { synth.SetOutputToDefaultAudioDevice(); // Obtener los videos de la carpeta \Video string strFolder = Common.Utils.GetApplicationExecutingFolder() + @"\" + PathVideo + ""; string strSupportedExtensions = "*.wmv,*.mp4,*.avi"; // Solo Videos _lstBackGroundVideoFiles = Common.Utils.GetFolderFiles(strFolder, strSupportedExtensions); WMPLib.IWMPPlaylist PlayList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("Video"); foreach (var item in _lstBackGroundVideoFiles) { WMPLib.IWMPMedia zMP3File = axWindowsMediaPlayer1.newMedia(item); PlayList.appendItem(zMP3File); } axWindowsMediaPlayer1.currentPlaylist = PlayList; axWindowsMediaPlayer1.settings.setMode("loop", true); axWindowsMediaPlayer1.settings.volume = 10; //axWindowsMediaPlayer1.uiMode = "none"; timer1.Start(); timer1.Interval = TimerIntervale; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void PlayMedia(string pointUrl = null) { this.PlayBtn.Text = "停止"; WMPLib.IWMPPlaylist playlist = _player.playlistCollection.newPlaylist("myplaylist"); _player.PlayStateChange += new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(Player_PlayStateChange); _player.MediaError += new WMPLib._WMPOCXEvents_MediaErrorEventHandler(Player_MediaError); _player.CurrentItemChange += new WMPLib._WMPOCXEvents_CurrentItemChangeEventHandler(player_CurrentItemChange); playlist.clear(); if (string.IsNullOrWhiteSpace(pointUrl) == false) { media = _player.newMedia(pointUrl); playlist.appendItem(media); } var array = Shuffle <string>(_listUrl.ToArray()); foreach (string urlStr in array) { media = _player.newMedia(urlStr); playlist.appendItem(media); } _player.currentPlaylist = playlist; _timer.Start(); _player.controls.play(); }
/// <summary /// starts playing selected input url /// </summary> public void Play() { if(player.playState == WMPPlayState.wmppsPlaying) { curItem = player.controls.currentItem; curPos = player.controls.currentPosition; player.controls.pause(); } player.settings.volume = 100; //else { player.URL = "playlist.wpl"; try { if (curItem != null) { player.controls.stop(); player.controls.currentPosition = curPos; } player.controls.play(); } catch (Exception exception) { MessageBox.Show("Playlist error: " + exception.Message, "Ошибка воспроизведения"); } } }
public VideoFile(string filePath) { this.filePath = filePath; WindowsMediaPlayerClass wmp = new WindowsMediaPlayerClass(); WMPLib.IWMPMedia media = wmp.newMedia(filePath); TimeSpan videoLength = TimeSpan.FromSeconds((int)media.duration); this.endTime = videoLength; }
private void AddSongsToList(string path) { if (!IsExistInList(path)) { var songsInfo = new Songs(path); lstSongList.Items.Add(songsInfo); WMPLib.IWMPMedia media = MusicPlayer.newMedia(path); MusicPlayer.currentPlaylist.appendItem(media); } }
public void Pause() { if (player != null) { if (player.playState != WMPPlayState.wmppsPaused || player.playState != WMPPlayState.wmppsStopped) player.controls.pause(); curPos = player.controls.currentPosition; curItem = player.controls.currentItem; } }
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e) { axWindowsMediaPlayer1.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(wplayer_PlayStateChange); playList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("ExpectoPatronumVideos"); preMovie = axWindowsMediaPlayer1.newMedia(@"C:\Users\CLARISSA RAMOS\Documents\GitHub\wiiwandz\HarryParty\media\videos\arania_exumai_pre.mp4"); playList.appendItem(preMovie); loopMovie = axWindowsMediaPlayer1.newMedia(@"C:\Users\CLARISSA RAMOS\Documents\GitHub\wiiwandz\HarryParty\media\videos\arania_exumai_loop.mp4"); //playList.appendItem(loopMovie); postMovie = axWindowsMediaPlayer1.newMedia(@"C:\Users\CLARISSA RAMOS\Documents\GitHub\wiiwandz\HarryParty\media\videos\arania_exumai_post.mp4"); axWindowsMediaPlayer1.currentPlaylist = playList; }
/// <summary> /// Utiliza la libreria WMPLib para obtener los detalles de cada archivo para comparar el autor /// </summary> /// <param name="sourceFolder"></param> /// <param name="phFolder"></param> /// <param name="newDestination"></param> private static List <string> orderByAutor(string sourceFolder, string newDestination, SearchOption SearchOptionSelect) { List <string> canalesEncontrados = new List <string>(); // Obtiene todos los archivos e identifica el nombre del autor para ordenarlo List <string> AllFiles = Directory.GetFiles(sourceFolder, "*", SearchOptionSelect).Where(f => !f.EndsWith(".txt")).ToList(); if (AllFiles.Count > 0) { foreach (var fileSearch in AllFiles) { WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer(); WMPLib.IWMPMedia m = player.newMedia(fileSearch); var autor = m.getItemInfo("Author"); string pathString = System.IO.Path.Combine(newDestination, autor); string pathFile = string.Format(@"{0}", fileSearch); string fileName = Path.GetFileName(fileSearch); string destinationdirectory = System.IO.Path.Combine(string.Format(@"{0}", pathString), fileName); try { if (!Directory.Exists(pathString)) { System.IO.Directory.CreateDirectory(pathString); } //System.IO.File.Copy(pathFile, destinationdirectory); System.IO.File.Move(pathFile, destinationdirectory, true); //System.IO.File.Delete(pathFile); } catch (Exception ex) { Console.WriteLine(ex.Message); } canalesEncontrados.Add(autor); } } return(canalesEncontrados.Distinct().ToList()); }
//dodanie nazw piosenek do gramatyki systemu rozpoznawania, zczytujac nazwy piosenek z pliku, ktory najpierw zostaje stworzony private void addSongNamesTotheDictionary(Choices choices_, string LINK) { Process getSongNamesProcess = new Process(); Process clearFile = new Process(); try { clearFile.StartInfo.FileName = "cmd.exe"; clearFile.StartInfo.Arguments = "/c TYPE nul > " + filePath; clearFile.Start(); getSongNamesProcess.StartInfo.FileName = "cmd.exe"; getSongNamesProcess.StartInfo.Arguments = "/c dir /b " + LINK + " >> songNames.txt"; getSongNamesProcess.Start(); } catch { MessageBox.Show("The file couldn't have been created"); } WMPLib.IWMPControls3 controls = (WMPLib.IWMPControls3)wmplayer.Ctlcontrols; controls.play(); WMPLib.IWMPPlaylist playlist = wmplayer.playlistCollection.newPlaylist("myplaylist"); try { using (StreamReader sr = File.OpenText(filePath)) { string line = null; while ((line = sr.ReadLine()) != null) { media = wmplayer.newMedia(LINK + @"\" + line); line = line.Substring(0, line.Length - 4); listBox1.Items.Add(line); playlist.appendItem(media); choices_.Add("Katherine play " + line); } wmplayer.currentPlaylist = playlist; wmplayer.Ctlcontrols.stop(); } } catch { MessageBox.Show("STREAMREADER FAILED ;___;"); } }
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e) { axWindowsMediaPlayer1.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(wplayer_PlayStateChange); //axWindowsMediaPlayer1.URL = @"C:\Users\CLARISSA RAMOS\Documents\GitHub\wiiwandz\HarryParty\media\videos\arania_exumai_pre.mp4"; //axWindowsMediaPlayer1.settings.autoStart = false; //axWindowsMediaPlayer1.Ctlcontrols.play(); playList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("ExpectoPatronumVideos"); preMovie = axWindowsMediaPlayer1.newMedia(@"C:\Users\CLARISSA RAMOS\Documents\GitHub\wiiwandz\HarryParty\media\videos\expecto_patronum_pre.mp4"); playList.appendItem(preMovie); loopMovie = axWindowsMediaPlayer1.newMedia(@"C:\Users\CLARISSA RAMOS\Documents\GitHub\wiiwandz\HarryParty\media\videos\expecto_patronum_loop.mp4"); //playList.appendItem(loopMovie); postMovie = axWindowsMediaPlayer1.newMedia(@"C:\Users\CLARISSA RAMOS\Documents\GitHub\wiiwandz\HarryParty\media\videos\expecto_patronum_post.mp4"); axWindowsMediaPlayer1.currentPlaylist = playList; //WMPLib.IWMPMedia3 preFile = (WMPLib.IWMPMedia3)axWindowsMediaPlayer1.mediaCollection.getAll().get_Item(0); //axWindowsMediaPlayer1.currentMedia = preFile; }
public void PlayPlaylist(string path) { string[] playlist = File.ReadAllLines(path); player.currentPlaylist.clear(); foreach (string file in playlist) { WMPLib.IWMPMedia song = player.newMedia(file); player.currentPlaylist.appendItem(song); } player.controls.play(); Console.Clear(); while (true) { UserInputPlayList(); } }
private void Enfileira(string videoPath) { if (videoPath != null) { Console.WriteLine(videoPath); fila.Enfileira(videoPath); if (fila.GetVideos.Count == 1) { if (mediaPlayer.playState != WMPPlayState.wmppsPlaying && mediaPlayer.playState != WMPPlayState.wmppsTransitioning) { lock (fila) { string _fila = fila.Desenfileira(); Console.WriteLine("entrou: " + _fila); if (!String.IsNullOrEmpty(_fila)) { Console.WriteLine("entrou2: " + _fila); try { //mediaPlayer.URL = @"C:\Users\alann\Videos\" + _fila; WMPLib.IWMPMedia media = mediaPlayer.newMedia(@"C:\Users\alann\Videos\" + _fila); mediaPlayer.currentPlaylist.appendItem(media); mediaPlayer.Ctlcontrols.play(); // activates the play button //mediaPlayer.Ctlcontrols.play(); //mediaPlayer.URL = fullPathOfYourFirstMedia; //mediaPlayer.Ctlcontrols.play(); // activates the play button //mediaPlayer.Ctlcontrols.next(); // activates the next button //WMPLib.IWMPMedia media = mediaPlayer.newMedia(fullPathOfYourSecondMedia); //mediaPlayer.currentPlaylist.appendItem(media); } catch (Exception e) { } } } } } } }
private void PlayMedia(FileInfo file) { WMPLib.IWMPMedia m = null; pl = this.wmp.currentPlaylist; for (int i = 0; i < pl.count; i++) { if (pl.Item[i].sourceURL.Equals(file.FullName, StringComparison.OrdinalIgnoreCase)) { m = pl.Item[i]; break; } } if (m == null) { m = this.wmp.newMedia(file.FullName); pl.appendItem(m); } ; this.wmp.Ctlcontrols.playItem(m); }
private void MusicPlayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e) { switch (e.newState) { case 1: Taskbar.TaskbarManager.SetProgressState(Taskbar.TaskbarProgressBarState.Paused); //任务栏进度样式为Pause Taskbar.TaskbarManager.SetProgressValue(tkbMove.Value, tkbMove.Maximum); timer1.Stop(); Rest(); break; case 2: Taskbar.TaskbarManager.SetProgressState(Taskbar.TaskbarProgressBarState.Paused); Taskbar.TaskbarManager.SetProgressValue(tkbMove.Value, tkbMove.Maximum); timer1.Stop(); break; case 3: timer1.Start(); lblSongName.Text = playingMusic.FileName; this.Text = playingMusic.FileName; //任务栏文字 lblTitle.Text = playingMusic.FileName + " - MusicGarden"; //标题栏文字 pictureboxAlbumImage.Image = playingMusic.AlbumImage; TaskbarManager.Instance.TabbedThumbnail.SetThumbnailClip(this.Handle, new Rectangle(pictureboxAlbumImage.Location, pictureboxAlbumImage.Size)); tkbMove.Maximum = (int)MusicPlayer.currentMedia.duration; Taskbar.TaskbarManager.SetProgressState(Taskbar.TaskbarProgressBarState.Normal); Taskbar.TaskbarManager.SetProgressValue(tkbMove.Value, tkbMove.Maximum); break; } if (MusicPlayer.playState.ToString() == "wmppsMediaEnded") { WMPLib.IWMPMedia music = MusicPlayer.newMedia(GetPath()); ShowLrc(); MusicPlayer.currentPlaylist.appendItem(music); } }
private void mediaPlayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e) { if (e.newState == 8)//Media finished { ended = true; } if (e.newState != 8)//Stopped & ended { if (fila.GetVideos.Count > 0) { lock (fila) { //mediaPlayer.Ctlcontrols.stop(); //mediaPlayer.URL = @"C:\Users\alann\Videos\" + fila.Desenfileira(); //mediaPlayer.Ctlcontrols.play(); WMPLib.IWMPMedia media = mediaPlayer.newMedia(@"C:\Users\alann\Videos\" + fila.Desenfileira()); mediaPlayer.currentPlaylist.appendItem(media); mediaPlayer.Ctlcontrols.play(); // activates the play button } } ended = false; } }
private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { axWindowsMediaPlayer1.Ctlcontrols.stop(); TreeNode selnode = e.Node; int i = selnode.Index; string[] s = new string[list[i].Items.Count]; lb2.Items.Clear(); listView2.Items.Clear(); listView1.Items.Clear(); ds.Items.Clear(); for (int j = 0; j < list[i].Items.Count; j++) { s[j] = list[i].Items[j].ToString(); lb2.Items.Add(s[j]); listView2.Items.Add(Path.GetFileNameWithoutExtension(s[j])); } plItems = axWindowsMediaPlayer1.playlistCollection.getByName(myPlaylist); if (plItems.count == 0) { pl = axWindowsMediaPlayer1.playlistCollection.newPlaylist(myPlaylist); } else { pl = plItems.Item(0); } int q = 0; foreach (string file in s) { ListViewItem item = new ListViewItem(s[q]); ds.Items.Add(Path.GetFileNameWithoutExtension(item.ToString())); q++; m1 = axWindowsMediaPlayer1.newMedia(file); pl.appendItem(m1); } //choi nhac axWindowsMediaPlayer1.currentPlaylist = pl; axWindowsMediaPlayer1.Ctlcontrols.play(); axWindowsMediaPlayer1.playlistCollection.remove(pl); }
public void Stop() { curItem = null; curPos = 0; if (player != null) if (player.playState != WMPPlayState.wmppsStopped) player.controls.stop(); }
private void CreatePlayLis(OpenFileDialog open, ListView lv) { plItems = axWindowsMediaPlayer1.playlistCollection.getByName(myPlaylist); if (plItems.count == 0) pl = axWindowsMediaPlayer1.playlistCollection.newPlaylist(myPlaylist); else pl = plItems.Item(0); //them vao listview va thu vien WMP int i = 0; foreach (string file in open.FileNames) { ListViewItem item = new ListViewItem(open.FileNames[i]); lv.Items.Add(Path.GetFileNameWithoutExtension(item.ToString())); i++; m1 = axWindowsMediaPlayer1.newMedia(file); pl.appendItem(m1); } //choi nhac axWindowsMediaPlayer1.currentPlaylist = pl; axWindowsMediaPlayer1.Ctlcontrols.play(); axWindowsMediaPlayer1.playlistCollection.remove(pl); }
//najwazniejsza funkcja, odpowiedzialna za przypisanie komend do wykonywanych akcji private void engine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { if (e.Result.Confidence >= 0.9) { Console.Write("Reconized ~ " + e.Result.Text + " ~ with confidence " + e.Result.Confidence + '\n'); switch (e.Result.Text) { case "Katherine mute system": Process mute_process = new Process(); mute_process.StartInfo.FileName = nircmdPath; mute_process.StartInfo.Arguments = "mutesysvolume 1"; mute_process.Start(); Console.WriteLine("system muted"); break; case "Katherine unmute system": Process unmute_process = new Process(); unmute_process.StartInfo.FileName = nircmdPath; unmute_process.StartInfo.Arguments = "mutesysvolume 0"; unmute_process.Start(); Console.WriteLine("system unmuted"); break; case "Katherine system volume down": Process vDown = new Process(); vDown.StartInfo.FileName = nircmdPath; vDown.StartInfo.Arguments = "changesysvolume " + scaledVolume(-30).ToString(); vDown.Start(); break; case "Katherine system volume up": Process vUp = new Process(); vUp.StartInfo.FileName = nircmdPath; vUp.StartInfo.Arguments = "changesysvolume " + scaledVolume(30).ToString(); vUp.Start(); break; case "Katherine system volume down 20": Process vDown20 = new Process(); vDown20.StartInfo.FileName = nircmdPath; vDown20.StartInfo.Arguments = "changesysvolume " + scaledVolume(-20).ToString(); vDown20.Start(); break; case "Katherine system volume up 20": Process vUp20 = new Process(); vUp20.StartInfo.FileName = nircmdPath; vUp20.StartInfo.Arguments = "changesysvolume " + scaledVolume(20).ToString(); vUp20.Start(); break; case "Katherine stop music": changeState("stopped"); wmplayer.Ctlcontrols.stop(); addInfo2Log("Music stopped"); break; case "Katherine play next": if (wmplayer.playState != WMPLib.WMPPlayState.wmppsPlaying) { changeState("playing"); } wmplayer.Ctlcontrols.next(); wmplayer.Ctlcontrols.play(); addInfo2Log("Next song playing"); Console.WriteLine(wmplayer.currentMedia.getItemInfo("Title") + " playing"); break; case "Katherine play previous": if (wmplayer.playState != WMPLib.WMPPlayState.wmppsPlaying) { changeState("playing"); } wmplayer.Ctlcontrols.previous(); wmplayer.Ctlcontrols.play(); addInfo2Log("Previous song playing"); Console.WriteLine(wmplayer.currentMedia.getItemInfo("Title") + " playing"); break; case "Katherine pause": changeState("paused"); wmplayer.Ctlcontrols.pause(); addInfo2Log("Music paused"); break; case "Katherine play": changeState("playing"); wmplayer.Ctlcontrols.play(); if (wmplayer.playState != WMPLib.WMPPlayState.wmppsPlaying) { Console.WriteLine(wmplayer.currentMedia.getItemInfo("Title") + " playing"); } break; case "Katherine what is this song?": answerSongName(); break; case "Katherine loop this playlist": wmplayer.settings.setMode("loop", true); Console.WriteLine("playlist looped"); break; case "Katherine shuffle playlist": wmplayer.settings.setMode("shuffle", true); Console.WriteLine("random songs order made"); break; case "Katherine mute": wmplayer.settings.mute = true; Console.WriteLine("player muted"); break; case "Katherine unmute": wmplayer.settings.mute = false; Console.WriteLine("player unmuted"); break; case "Katherine remove this song": removeSong(); break; case "Katherine volume down": wmplayer.settings.volume -= 30; volProgressBar.Value = Int32.Parse(wmplayer.settings.volume.ToString()); addInfo2Log("Volume decreased"); break; case "Katherine volume up": wmplayer.settings.volume += 30; volProgressBar.Value = Int32.Parse(wmplayer.settings.volume.ToString()); addInfo2Log("Volume increased"); break; } for (int i = 0; i < listBox1.Items.Count; i++) { if (e.Result.Text == "Katherine play " + listBox1.Items[i].ToString()) { try { changeState("playing"); Console.WriteLine(listBox1.Items[i].ToString()); media = wmplayer.currentPlaylist.get_Item(i); wmplayer.Ctlcontrols.playItem(media); } catch { MessageBox.Show("song play error"); } } } } }
//chuc nag keo tha private void ds_DragDrop(object sender, DragEventArgs e) { try { ds.Items.Clear(); //tao playlist chua cac bai hat duoc chon plItems = axWindowsMediaPlayer1.playlistCollection.getByName(myPlaylist); pl = axWindowsMediaPlayer1.playlistCollection.newPlaylist(myPlaylist); //them vao listview va thu vien WMP string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false); FileInfo f; for (int i = 0; i < s.Length; i++) { f = new FileInfo(s[i]); ds.Items.Add(f.Name); ListViewItem item = new ListViewItem(s[i]); lb2.Items.Add(f.FullName); m1 = axWindowsMediaPlayer1.newMedia(s[i]); pl.appendItem(m1); } play.Hide(); pause.Show(); axWindowsMediaPlayer1.currentPlaylist = pl; axWindowsMediaPlayer1.Ctlcontrols.play(); axWindowsMediaPlayer1.playlistCollection.remove(pl); } catch (Exception) { //MessageBox.Show("Không Cho Phép Kéo Thả"); } }
private void shuffleoff_Click(object sender, EventArgs e) { if (ds.Items.Count > 0) { axWindowsMediaPlayer1.playlistCollection.remove(pl); } pl = axWindowsMediaPlayer1.playlistCollection.newPlaylist(myPlaylist); ListViewItem lvi; for (int i = 0; i < ds.Items.Count; i++) { vt = rd.Next(0, ds.Items.Count - 1); lvi = new ListViewItem(Path.GetFileNameWithoutExtension(lb2.Items[vt].ToString())); ds.Items[i] = lvi; m1 = axWindowsMediaPlayer1.newMedia(lb2.Items[vt].ToString()); pl.appendItem(m1); } axWindowsMediaPlayer1.currentPlaylist = pl; shuffle.Show(); shuffleoff.Hide(); }