예제 #1
0
        private void removeButton_Click(object sender, EventArgs e)
        {
            //Delete the selected row in the dataGridView.
            try
            {
                dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[0].Index);

                //Update the current playlist by reading all the files on the dataGridView.
                allFilenames = getSongsInPlaylist("Name"); //get all the name files shown on the dataGridView.
                allPaths     = getSongsInPlaylist("Path"); //get all the paths of the songs shown on the dataGridView.


                //Create a Media playlist with all the items in the listBox.
                List <string> listPaths = dataGridView1.Rows.OfType <DataGridViewRow>().Where(x => x.Cells[1].Value != null).Select(x => x.Cells[1].Value.ToString()).ToList(); //get all the paths of the dataGridView.
                foreach (var item in listPaths)
                {
                    listBox5.Items.Add(item); //Add all the paths of the dataGridView in a listBox.
                }

                ListBox.ObjectCollection list = listBox5.Items;

                WMPLib.IWMPPlaylist playlist = axWindowsMediaPlayer1.playlistCollection.newPlaylist("myplaylist");
                WMPLib.IWMPMedia    media;
                foreach (object item in listPaths)
                {
                    media = axWindowsMediaPlayer1.newMedia((string)item);
                    playlist.appendItem(media);
                }
                axWindowsMediaPlayer1.currentPlaylist = playlist;
                axWindowsMediaPlayer1.Ctlcontrols.play(); //Start playing the songs in the playlist
            }
            catch (Exception) { }
        }
        private void playAll()
        {
            WMPLib.IWMPPlaylist playList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("myPlayList");
            WMPLib.IWMPMedia    media;


            try
            {
                for (int i = 0; i < listView1.Items.Count; i++)
                {
                    int ii = 1;

                    // creat media instance from the current file location
                    media = axWindowsMediaPlayer1.newMedia(listView1.Items[i].SubItems[ii].Text);

                    // add the media to playlist
                    playList.appendItem(media);

                    axWindowsMediaPlayer1.currentPlaylist = playList;
                    axWindowsMediaPlayer1.Ctlcontrols.play();
                    axWindowsMediaPlayer1.PlayStateChange += (s, e) =>
                    {
                        if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPlaying)
                        {
                            this.mediaStatus.Text = axWindowsMediaPlayer1.currentMedia.name + " is Playing ...";
                        }
                    };
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Can't Play the Media", "Error");
            }
        }
예제 #3
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            open.Multiselect = true;
            open.Filter      = "MP3|*.mp3";
            lst_nhac.Items.Clear();

            if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // axWindowsMediaPlayer1.URL = open.FileName;
                WMPLib.IWMPPlaylist playlist = axWindowsMediaPlayer1.newPlaylist("my playlist", string.Empty);

                foreach (string file in open.FileNames)
                {
                    WMPLib.IWMPMedia Mmedia = axWindowsMediaPlayer1.newMedia(file);
                    playlist.appendItem(Mmedia);
                    lst_nhac.Items.Add(file);
                }
                axWindowsMediaPlayer1.currentPlaylist = playlist;
                axWindowsMediaPlayer1.Ctlcontrols.play();
                axWindowsMediaPlayer1.settings.autoStart = true;
                axWindowsMediaPlayer1.settings.setMode("loop", true);
            }
        }
예제 #4
0
        private void dataGridView1_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e)
        {
            frm.Hide();
            frm.label1.Text = " ";

            frm.label1.Text = dataGridView1.CurrentRow.Cells["nombre"].Value.ToString();
            frm.axWindowsMediaPlayer1.URL = dataGridView1.CurrentRow.Cells["direccion"].Value.ToString();

            WMPLib.IWMPPlaylist playlist = frm.axWindowsMediaPlayer1.playlistCollection.newPlaylist("myplaylist");
            WMPLib.IWMPMedia    media;

            media = frm.axWindowsMediaPlayer1.newMedia(dataGridView1.CurrentRow.Cells["direccion"].Value.ToString());
            playlist.appendItem(media);

            frm.axWindowsMediaPlayer1.currentPlaylist = playlist;
            listamp3.RemoveRange(0, listamp3.Count);
            string dat = dataGridView1.CurrentRow.Cells["direccion"].Value.ToString();

            cargarima(dat);
            tagcan(dat);
            frm.dataGridView1.DataSource = null;
            frm.dataGridView1.Refresh();
            frm.dataGridView1.DataSource = listamp3;
            frm.dataGridView1.Refresh();
            frm.Show();
        }
예제 #5
0
파일: Form1.cs 프로젝트: 8Tesla8/mp3-player
        private void Open_Click(object sender, EventArgs e)
        {
            if (!firstRunWas) //create play list songs
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    //создание плейлиста
                    playlist = MediaPlayer.playlistCollection.newPlaylist("myPlayList");

                    AddSongs();

                    MediaPlayer.currentPlaylist = playlist;
                    MediaPlayer.Ctlcontrols.play();

                    firstRunWas = true;
                }
            }
            else //add song to play list
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    AddSongs();
                }
            }
        }
예제 #6
0
        public MainForm(String[] file)
        {
            InitializeComponent();
            playlist = MediaPlayerControl.playlistCollection.newPlaylist("MyPlayList");
            MediaPlayerControl.currentPlaylist = playlist;

            NPlist = null;

            MyPlaylists    = playlists.getInstance();
            MyPlaylistData = PlaylistData.getInstance();
            if (MyPlaylists.getPlaylistNames() != null)
            {
                foreach (String filename in MyPlaylists.getPlaylistNames())
                {
                    PLlistBox.Items.Add(filename);
                }
            }
            if (file.Length > 0)
            {
                NPlist = file;
                foreach (String listItem in file)
                {
                    string value = listItem.Substring(listItem.LastIndexOf("\\") + 1);
                    value = "    " + value;
                    NPlistbox.Items.Add(value);
                    media = MediaPlayerControl.newMedia(listItem);
                    playlist.appendItem(media);
                }
                MediaPlayerControl.Ctlcontrols.play();
                NPlistbox.SelectedIndex = 0;
            }
        }
예제 #7
0
        public void UpdateDataGrid()
        {
            //List<string> songs = new List<string>();
            //foreach(DataGridViewRow dataRow in this.Playlist_datagrid.Rows)
            //{
            //    songs.Add(dataRow.Cells[1].Value.ToString());
            //}

            //songs = songs.Distinct().ToList();
            if (this.Playlist_datagrid.Rows.Count != 0)
            {
                Playlist_datagrid.Rows.Clear();
            }
            playlist = axWindowsPlayer.playlistCollection.newPlaylist("myplaylist");
            WMPLib.IWMPMedia media;
            int i = 1;

            foreach (string song in song_url)
            {
                int n = this.Playlist_datagrid.Rows.Add();
                this.Playlist_datagrid.Rows[n].Cells[0].Value = i++;
                this.Playlist_datagrid.Rows[n].Cells[1].Value = Path.GetFileName(song);
                media = axWindowsPlayer.newMedia(song);
                playlist.appendItem(media);
            }

            axWindowsPlayer.currentPlaylist = playlist;
        }
예제 #8
0
        public FormDiffusion()
        {
            InitializeComponent();
            initialyzeKinect();
            //initialisation des composants du media player
            WMPLib.IWMPPlaylist playlist = mediaPlayer.newPlaylist("myPlaylist", string.Empty);
            string[]            lines    = System.IO.File.ReadAllLines(@"playlist.txt");

            foreach (string path in lines)
            {
                WMPLib.IWMPMedia temp = mediaPlayer.newMedia(path);
                playlist.appendItem(temp);
            }

            mediaPlayer.currentPlaylist      = playlist;
            mediaPlayer.settings.autoStart   = true;
            _gestureRight.GestureRecognized += GestureRight_GestureRecognized;
            _gestureLeft.GestureRecognized  += GestureLeft_GestureRecognized;
            lecteur = new SoundPlayer(@"C:\Users\Kazadri\Source\Repos\REDX\ClientDiffusion\bin\Release\musique.wav");

            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.Height          = 1032;
            this.Width           = 1632;
            lecteur.Play();
            musicIsPlaying = true;
        }
예제 #9
0
        private void btnShuf_Click(object sender, EventArgs e)
        {
            ListView.ListViewItemCollection list = listView1.Items;
            Random r = new Random();
            int    n = list.Count;

            while (n > 1)
            {
                n--;
                int          k  = r.Next(n + 1);
                ListViewItem v1 = (ListViewItem)list[k];
                ListViewItem v2 = (ListViewItem)list[n];
                list[k] = new ListViewItem();
                list[n] = new ListViewItem();
                list[k] = v2;
                list[n] = v1;
            }
            WMPLib.IWMPPlaylist playlist = mplayer.playlistCollection.newPlaylist("My Playlist");
            WMPLib.IWMPMedia    media;
            for (int i = 0; i < listView1.Items.Count; i++)
            {
                int j = 1;
                media = mplayer.newMedia(listView1.Items[i].SubItems[j].Text);
                playlist.appendItem(media);
                j++;

                mplayer.currentPlaylist = playlist;
                mplayer.Ctlcontrols.play();
                tmrLabel.Start();
                tmrProg.Start();
            }
        }
예제 #10
0
        public Form2()
        {
            InitializeComponent();
            f1 = new Form1();
            trackBar1 = new TrackBar();
            Controls.Add(trackBar1);
            groupBox3.Controls.Add(trackBar1);
            loca = new Point(comboBox1.Location.X, comboBox1.Location.Y);
            trackBar1.Location = loca;
            trackBar1.Size = new Size(trackBar1.Size.Width + 50, trackBar1.Size.Height - 50);
            trackBar1.TickFrequency = 10;
            trackBar1.LargeChange = 3;
            trackBar1.SmallChange = 2;
            trackBar1.Maximum = 100;
            trackBar1.Minimum = 0;
            trackBar1.TickStyle = TickStyle.BottomRight;
            this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);

            string tr = comboBox1.Text.Trim('%');
            f1.Opacity = double.Parse(tr) / 100.0;

                pl = f1.axWindowsMediaPlayer1.playlistCollection.newPlaylist("list1");//axwindowsMediaPlayer.playlistCollection.newPlaylist(myPlaylist);
            f1.axWindowsMediaPlayer1.currentPlaylist = pl;
            itemm = new List<WMPLib.IWMPMedia>();
            f1.Show();
        }
예제 #11
0
        private void StartVideo_Click(object sender, EventArgs e)
        {
            if (JeZakliknuetVideo())
            {
                if (z == null)
                {
                    z = new Zobrazovac();
                }
                AxWMPLib.AxWindowsMediaPlayer prehravac = z.WMP();
                WMPLib.IWMPPlaylist           playlist  = prehravac.playlistCollection.newPlaylist("myplaylist");
                WMPLib.IWMPMedia media;
                for (int i = 0; i < pocetVidei; i++)
                {
                    if (cLBZoznamReklam.GetItemCheckState(i) == CheckState.Checked)
                    {
                        string s = "..\\..\\Reklamy\\" + cLBZoznamReklam.Items[i].ToString();
                        //media = prehravac.newMedia(s);
                        media = prehravac.newMedia(cLBZoznamReklam.Items[i].ToString());
                        playlist.appendItem(media);
                    }
                }

                z.Show();
                prehravac.currentPlaylist = playlist;
                prehravac.Ctlcontrols.play();
                pauseVideo.Text        = "Pause";
                prehravac.stretchToFit = true;
            }
            else
            {
                MessageBox.Show("Nevybral si žiadne video");
            }
        }
예제 #12
0
        private void ReMusicPlayer_EnabledChanged(object sender, EventArgs e)
        {
            if (Enabled)
            {
                WMPLib.IWMPPlaylist _List = axWindowsMediaPlayer1.playlistCollection.newPlaylist("CurrentList");

                foreach (var f in Directory.GetFiles(_PlayerDirectory, "*.mp3"))
                {
                    var _media = axWindowsMediaPlayer1.newMedia(f);
                    if (_media == null)
                    {
                        break;
                    }
                    _List.appendItem(_media);
                }
                if (_List == null)
                {
                    return;
                }
                axWindowsMediaPlayer1.currentPlaylist = _List;
                //play
                axWindowsMediaPlayer1.Ctlenabled = true;
                axWindowsMediaPlayer1.Ctlcontrols.play();
            }
            else
            {
                axWindowsMediaPlayer1.Ctlcontrols.pause();
            }
        }
예제 #13
0
파일: Main.cs 프로젝트: xinhvatra/app
        public static void sound()
        {
            while (true)
            {
                if (clients.Count > 0)
                {
                    try
                    {
                        foreach (KeyValuePair <int, int> entry in clients)
                        {
                            int    num   = entry.Key;
                            int    ra    = entry.Value;
                            string donvi = num.ToString().Substring(3, 1);
                            string chuc  = num.ToString().Substring(2, 1);
                            string tram  = num.ToString().Substring(1, 1);
                            string nghin = num.ToString().Substring(0, 1);

                            WMPLib.WindowsMediaPlayer mp = new WMPLib.WindowsMediaPlayer();
                            WMPLib.IWMPPlaylist       playlist = mp.playlistCollection.newPlaylist("customerCall");
                            WMPLib.IWMPMedia          media, media1, media2, media3, media4, media5, media6;

                            string moi = Directory.GetCurrentDirectory() + "\\Resources\\moi.mp3";
                            media = mp.newMedia(moi);

                            string sokhachnghin = Directory.GetCurrentDirectory() + "\\Resources\\" + nghin + ".mp3";
                            media1 = mp.newMedia(sokhachnghin);

                            string sokhachtram = Directory.GetCurrentDirectory() + "\\Resources\\" + tram + ".mp3";
                            media2 = mp.newMedia(sokhachtram);

                            string sokhachchuc = Directory.GetCurrentDirectory() + "\\Resources\\" + chuc + ".mp3";
                            media3 = mp.newMedia(sokhachchuc);

                            string sokhachdonvi = Directory.GetCurrentDirectory() + "\\Resources\\" + donvi + ".mp3";
                            media4 = mp.newMedia(sokhachdonvi);

                            string vaocua = Directory.GetCurrentDirectory() + "\\Resources\\cuaso.mp3";
                            media5 = mp.newMedia(vaocua);

                            string socua = Directory.GetCurrentDirectory() + "\\Resources\\" + ra + ".mp3";
                            media6 = mp.newMedia(socua);

                            playlist.appendItem(media);
                            playlist.appendItem(media1);
                            playlist.appendItem(media2);
                            playlist.appendItem(media3);
                            playlist.appendItem(media4);
                            playlist.appendItem(media5);
                            playlist.appendItem(media6);
                            mp.currentPlaylist = playlist;
                            mp.controls.play();
                            clients.Remove(num);
                            Thread.Sleep(7000);                             //sleep 10s đợi phát âm thanh gọi khách trước xong.
                        }
                    }
                    catch { }
                }
            }
        }
예제 #14
0
        public Controller()
        {
            InitializeComponent();

            Players.Add(0.ToString(), new Form1());

            dd = Players[Selected].axWindowsMediaPlayer1.playlistCollection.newPlaylist("PlayList");
        }
 public MainContentArea(string topicId, Menu menu)
 {
     InitializeComponent();
     _currentId = topicId;
     _menu      = menu;
     WMPLib.IWMPPlaylist p2 = axWindowsMediaPlayer.playlistCollection.newPlaylist("Playlist 1");
     CreatePlaylist(_currentId, p2);
 }
예제 #16
0
        public void LoadMusic(string GetMusic)
        {
            try
            {
                listBox1.Items.Clear();
                Namemusic.Clear();
                urlmusic.Clear();
                var doc = new XmlDocument();
                doc.Load(new XmlTextReader(GetMusic));
                var audioTags = doc.SelectNodes("//audio");
                PlayList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("vkPlayList");
                int id = 0;
                foreach (XmlNode audioTag in audioTags)
                {
                    string artist = "";
                    string title  = "";
                    string url    = "";
                    if (audioTag["artist"] != null)
                    {
                        artist = audioTag["artist"].InnerText;
                    }
                    if (audioTag["title"] != null)
                    {
                        title = audioTag["title"].InnerText;
                    }
                    if (audioTag["url"] != null)
                    {
                        url = audioTag["url"].InnerText; url = url.Split('?')[0];
                    }
                    if (url != "")
                    {
                        Media = axWindowsMediaPlayer1.newMedia(url);
                        if (Media.isReadOnlyItem("title") == false)
                        {
                            Media.setItemInfo("title", title);
                        }
                        if (Media.isReadOnlyItem("artist") == false)
                        {
                            Media.setItemInfo("artist", artist);
                        }
                        if (Media.isReadOnlyItem("Id") == false)
                        {
                            Media.setItemInfo("Id", id.ToString());
                        }
                        PlayList.appendItem(Media);
                        listBox1.Items.Add(artist + " – " + title);
                        urlmusic.Add(url);
                        Namemusic.Add(artist + " – " + title);
                        id++;
                    }
                }
                axWindowsMediaPlayer1.currentPlaylist = PlayList;
                metroLabel2.Text = "Load " + listBox1.Items.Count.ToString() + " items.";
            }

            catch { MessageBox.Show("Ошибка загрузки (LoadMusic ERROR)"); }
        }
예제 #17
0
        private void playFirstSongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (treeViewPlaylists.SelectedNode == null)
            {
                MessageBox.Show("No playlist selected!");
            }
            else//set a playlist into playing starting from the FIRST in the list
            {
                foreach (LinkedList <string> llist in allPlaylists)
                {
                    //get selected playlist to play
                    //check if selection is child or parent
                    if (treeViewPlaylists.SelectedNode.Level == 1) //some testing for this sshows me that 0 is parent and children increment from there
                    {
                        //this is child so compare parent to DLL

                        String find = "";//empty declaration
                        try
                        {
                            find = find + llist.Find(llist.First()).Value;
                            if (treeViewPlaylists.SelectedNode.Parent.Text.CompareTo(find) == 0)
                            {
                                currentplaylist = axWindowsMediaPlayer1.playlistCollection.newPlaylist(treeViewPlaylists.SelectedNode.Parent.Text);
                                foreach (string song in llist)//everything in linked list to current playlist
                                {
                                    audiofile = axWindowsMediaPlayer1.newMedia(networkpath + "\\" + song);
                                    currentplaylist.appendItem(audiofile);
                                }

                                axWindowsMediaPlayer1.currentPlaylist = currentplaylist;
                            }
                        }
                        catch { }
                    }
                    else //is parent
                    {
                        String find = "";//empty declaration
                        try
                        {
                            find = find + llist.Find(llist.First()).Value;
                            if (treeViewPlaylists.SelectedNode.Text.CompareTo(find) == 0)
                            {
                                currentplaylist = axWindowsMediaPlayer1.playlistCollection.newPlaylist(treeViewPlaylists.SelectedNode.Text);
                                foreach (string song in llist)
                                {
                                    audiofile = axWindowsMediaPlayer1.newMedia(networkpath + "\\" + song);
                                    currentplaylist.appendItem(audiofile);
                                }

                                axWindowsMediaPlayer1.currentPlaylist = currentplaylist;
                            }
                        }
                        catch { }
                    }
                }
            }
        }
예제 #18
0
        public PlayList(WMPLib.IWMPPlaylist p, AxWMPLib.AxWindowsMediaPlayer mp)
        {
            InitializeComponent();

            this.p  = p;
            this.mp = mp;

            ChangePL += idd;
        }
예제 #19
0
 public Form1()
 {
     InitializeComponent();
     playlist = axWindowsMediaPlayer1.playlistCollection.newPlaylist("Radio");
     axWindowsMediaPlayer1.settings.autoStart = false;
     axWindowsMediaPlayer1.settings.setMode("shuffle", true);
     axWindowsMediaPlayer1.settings.setMode("loop", true);
     axWindowsMediaPlayer1.settings.volume = 50;
     Ser_Load();
 }
예제 #20
0
파일: Form1.cs 프로젝트: bangush/csharp
        public static List <WMPLib.IWMPMedia> Where(this WMPLib.IWMPPlaylist source, Func <WMPLib.IWMPMedia, bool> predicate)
        {
            List <WMPLib.IWMPMedia> list = new List <WMPLib.IWMPMedia>();

            for (int i = 0; i < source.count; i++)
            {
                list.Add(source.get_Item(i));
            }
            return(list.Where(predicate).ToList());
        }
예제 #21
0
 public MusicForm()
 {
     InitializeComponent();
     WMPLib.IWMPPlaylist playlist = axWindowsMediaPlayer1.playlistCollection.newPlaylist("myplaylist");
     WMPLib.IWMPMedia    media;
     media = axWindowsMediaPlayer1.newMedia(@"https://vpprojectcasino.000webhostapp.com/music/pokerMusic.mp3");
     playlist.appendItem(media);
     axWindowsMediaPlayer1.currentPlaylist = playlist;
     controls = (WMPLib.IWMPControls3)axWindowsMediaPlayer1.Ctlcontrols;
 }
예제 #22
0
 public void createPlaylist()
 {
     WMPLib.IWMPPlaylist playlist = axWindowsMediaPlayer1.playlistCollection.newPlaylist(Global.playlistName);
     WMPLib.IWMPMedia    media;
     for (int i = 0; i < Global.mediaFiles.Count; i++)
     {
         media = axWindowsMediaPlayer1.newMedia(findPath(Global.mediaFiles[i]));
         playlist.appendItem(media);
     }
     axWindowsMediaPlayer1.currentPlaylist = playlist;
 }
예제 #23
0
 private void LoadTrackList()
 {
     playlist = MediaPlayer.playlistCollection.newPlaylist("fromVK");
     foreach (var audio in audioList)
     {
         media = MediaPlayer.newMedia(audio.url);
         playlist.appendItem(media);
         TrackListBox.Items.Add(audio.artist + " - " + audio.title);
     }
     MediaPlayer.currentPlaylist = playlist;
     MediaPlayer.Ctlcontrols.stop();
 }
예제 #24
0
파일: Form1.cs 프로젝트: 8Tesla8/mp3-player
        private void Clear_Click(object sender, EventArgs e)
        {
            if (List.Items.Count > 0) // очистка ListBox
            {
                List.Items.Clear();

                WMPLib.IWMPPlaylist delPlayList = MediaPlayer.playlistCollection.newPlaylist("DeletePlayList");
                MediaPlayer.currentPlaylist = delPlayList;

                firstRunWas = false;
            }
        }
 public ScreenSaverForm(IntPtr PreviewWndHandle)
 {
     InitializeComponent();
     playlist = axWindowsMediaPlayer1.newPlaylist("VideoScreenSaver", string.Empty);
     loadMovies();
     SetParent(this.Handle, PreviewWndHandle);
     SetWindowLong(this.Handle, -16, new IntPtr(GetWindowLong(this.Handle, -16) | 0x40000000));
     Rectangle ParentRect;
     GetClientRect(PreviewWndHandle, out ParentRect);
     Size = ParentRect.Size;
     Location = new Point(0, 0);
     previewMode = true;
 }
 public ScreenSaverForm(Rectangle Bounds, bool video)
 {
     InitializeComponent();
     if (video == true)
     {
         playlist = axWindowsMediaPlayer1.newPlaylist("VideoScreenSaver", string.Empty);
         loadMovies();
     }
     if (video == false) axWindowsMediaPlayer1.Visible = false;
     this.Bounds = Bounds;
     Cursor.Hide();
     TopMost = true;
 }
예제 #27
0
        private void addButton_Click(object sender, EventArgs e)
        {
            //Select the items to add to the dataGridView.
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Multiselect = true;
            openFileDialog1.Filter      = "Mp3 Files|*.mp3|Avi Files| *.avi | Wav Files | *.wav";

            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                filesNames = openFileDialog1.SafeFileNames;
                paths      = openFileDialog1.FileNames;


                for (int i = 0; i < paths.Length; i++)
                {
                    //Dislay the playlist on a DataGridView. The first column holds the filenames and the second the file paths.
                    try
                    {
                        fillDataTable(filesNames[i], paths[i]);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            allFilenames = getSongsInPlaylist("Name"); //get all the name files shown on the dataGridView.
            allPaths     = getSongsInPlaylist("Path"); //get all the paths of the songs shown on the dataGridView.

            //Create a Media playlist with all the items in the dataGridView.
            List <string> listPaths = dataGridView1.Rows.OfType <DataGridViewRow>().Where(x => x.Cells[1].Value != null).Select(x => x.Cells[1].Value.ToString()).ToList(); //get all the paths of the dataGridView.

            foreach (var item in listPaths)
            {
                listBox5.Items.Add(item); //Add all the paths in a listBox.
            }


            ListBox.ObjectCollection list = listBox5.Items;

            WMPLib.IWMPPlaylist playlist = axWindowsMediaPlayer1.playlistCollection.newPlaylist("myplaylist");
            WMPLib.IWMPMedia    media;
            foreach (object item in listPaths)
            {
                media = axWindowsMediaPlayer1.newMedia((string)item);
                playlist.appendItem(media);
            }
            axWindowsMediaPlayer1.currentPlaylist = playlist;
            axWindowsMediaPlayer1.Ctlcontrols.play(); //Start playing the songs in the playlist
        }
예제 #28
0
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (playList.Items.Count > 0)
            {
                string[] songsArray = playList.Items.OfType <string>().ToArray();

                playlist = Player.playlistCollection.newPlaylist(namePlaylist.Text);

                foreach (string song in songsArray)
                {
                    playlist.appendItem(Player.newMedia(song));
                }
            }
        }
예제 #29
0
 private void CreateNewPlaylist()
 {
     WMPLib.IWMPPlaylist playlist = axWindowsMediaPlayer1.playlistCollection.newPlaylist("NU_Playlist");
     WMPLib.IWMPMedia    media;
     if (open.ShowDialog() == DialogResult.OK)
     {
         FileName = open.FileNames;
         foreach (string file in FileName)
         {
             media = axWindowsMediaPlayer1.newMedia(file);
             playlist.appendItem(media);
         }
         axWindowsMediaPlayer1.currentPlaylist = playlist;
     }
 }
예제 #30
0
        private void Update_PlayList(string s)
        {
            playList = mediaPlayer.playlistCollection.newPlaylist(s);

            for (int i = 0; i < audioListCurrent.Count; ++i)
            {
                media = mediaPlayer.newMedia(audioListCurrent[i].url);
                playList.appendItem(media);

                songsList.Items.Add(audioListCurrent[i].artist + " - " + audioListCurrent[i].title);
            }
            mediaPlayer.currentPlaylist = playList;
            mediaPlayer.Ctlcontrols.stop();
            mediaPlayer.playlistCollection.remove(playList);
        }
예제 #31
0
 private void Form2_Load(object sender, EventArgs e)
 {
     WMPLib.IWMPPlaylist playlist = axWindowsMediaPlayer1.playlistCollection.newPlaylist("myplaylist");
     WMPLib.IWMPMedia    media;
     if (FileList.Count != 0)
     {
         foreach (string file in FileList)
         {
             media = axWindowsMediaPlayer1.newMedia(file);
             playlist.appendItem(media);
         }
     }
     axWindowsMediaPlayer1.currentPlaylist = playlist;
     axWindowsMediaPlayer1.Ctlcontrols.play();
 }
예제 #32
0
 private void playSongToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (listBoxSongs.SelectedItem == null)
     {
         MessageBox.Show("No Songs Selected!");
     }
     else
     {
         string song = listBoxSongs.SelectedItem.ToString();
         currentplaylist = axWindowsMediaPlayer1.playlistCollection.newPlaylist("Not in a playlist"); //only playing song
         audiofile       = axWindowsMediaPlayer1.newMedia(networkpath + "\\" + song);
         currentplaylist.appendItem(audiofile);
         axWindowsMediaPlayer1.currentPlaylist = currentplaylist;
     }
 }
 private void button2_Click(object sender, EventArgs e)                                                     //Play all button
 {
     if (listView1 != null)                                                                                 //there must be at least 1 song
     {
         WMPLib.IWMPPlaylist playlist = axWindowsMediaPlayer1.playlistCollection.newPlaylist("myplaylist"); //i create a playlist item
         WMPLib.IWMPMedia    media;                                                                         //and a media item
         for (int i = 0; i < listView1.Items.Count; i++)                                                    //for all the songs
         {
             media = axWindowsMediaPlayer1.newMedia(listView1.Items[i].SubItems[1].Text);                   //we get the 2nd subitem of each row which is the full path
             playlist.appendItem(media);                                                                    //we create the playlist by adding all the paths
         }
         axWindowsMediaPlayer1.currentPlaylist = playlist;                                                  //we initialize the playlist with the one we just created
         axWindowsMediaPlayer1.Ctlcontrols.play();                                                          //we play the playlist
     }
 }
예제 #34
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            this.Invoke((MethodInvoker)delegate
                {
                    try
                    {
                        ListWithURLs = axWindowsMediaPlayer1.playlistCollection.newPlaylist("vkPlayList");

                    SearchEngine engine = new SearchEngine(textBox1.Text);
                    engine.Search();
                    listBox2.Items.Add(engine.GetFiles());

                    axWindowsMediaPlayer1.currentPlaylist = ListWithURLs;
                    axWindowsMediaPlayer1.Ctlcontrols.stop();
                    }
                    catch { }

                });
        }
예제 #35
0
파일: Music.cs 프로젝트: zadiran/VK.Player
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            while (!App.Default.auth)
            {
                Thread.Sleep(500);
            }
            
            WebRequest req = WebRequest.Create("https://api.vk.com/method/audio.get?owner_id=" + App.Default.id + "&need_user=0&access_token=" + App.Default.token);
            WebResponse res = req.GetResponse();
            var dataStream = res.GetResponseStream();
            var reader = new StreamReader(dataStream);
            var resString = reader.ReadToEnd();
            reader.Close();
            res.Close();
            resString = HttpUtility.HtmlDecode(resString);

            var token = JToken.Parse(resString);
            audioList = token["response"].Children().Skip(1).Select(x => x.ToObject<Audio>()).ToList();

            this.Invoke((MethodInvoker)delegate
            {
                PlayList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("vkPlayList");

                foreach (var item in audioList)
                {
                    var displayedTitle = item.artist + " - " + item.title;
                    var displayedTitleShort = new string(displayedTitle.Length > 50 ? displayedTitle.Take(50).Concat(new[] { '.', '.', '.' }).ToArray() : displayedTitle.ToArray());

                    var playListItem = axWindowsMediaPlayer1.newMedia(item.url);
                    playListItem.setItemInfo("DisplayedTitle", displayedTitleShort);
                    PlayList.appendItem(playListItem);

                    listBox1.Items.Add(displayedTitle);
                }
                axWindowsMediaPlayer1.currentPlaylist = PlayList;
                axWindowsMediaPlayer1.Ctlcontrols.stop();
            });
        }
        private void backgroundWorker1_DoWork_1(object sender, DoWorkEventArgs e)
        {
            while (!VKLogIn.auth) { Thread.Sleep(500); }

            WebRequest request = WebRequest.Create("https://api.vk.com/method/audio.get?owner_id=" + VKLogIn.vkuserid + "&need_user=0&access_token=" + VKLogIn.acc_token);

            WebResponse response = request.GetResponse();

            Stream dataStream = response.GetResponseStream();

            StreamReader reader = new StreamReader(dataStream);

            string responseFromServer = reader.ReadToEnd();

            reader.Close();

            response.Close();

            responseFromServer = System.Web.HttpUtility.HtmlDecode(responseFromServer);

            JToken token = JToken.Parse(responseFromServer);
            audioList = token["response"].Children().Skip(1).Select(c => c.ToObject<Audio>()).ToList();

            this.Invoke((MethodInvoker)delegate
            {

                PlayList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("vkPlayList");

                for (int i = 0; i < audioList.Count(); i++)
                {
                    Media = axWindowsMediaPlayer1.newMedia(audioList[i].url);
                    PlayList.appendItem(Media);
                    listBox1.Items.Add(audioList[i].artist + " - " + audioList[i].title);
                }
                axWindowsMediaPlayer1.currentPlaylist = PlayList;
                axWindowsMediaPlayer1.Ctlcontrols.stop();
                comboBox1.Enabled = true;
                button1.Text = "Refresh";
                tabControl1.SelectedIndex = 0;
                button4.Visible = true;
                listBox1.Enabled = true;
            });
        }
예제 #37
0
        /// <summary>
        /// Executes the specified param.
        /// </summary>
        /// <param name="param">The param.</param>
        /// <param name="result">The result.</param>
        /// <returns></returns>
        public OpResult Execute(string param)
        {
            OpResult opResult = new OpResult();
            bool bFirst = !queue;
            bool bByIndex = false;
            int idx = 0;

            opResult.StatusCode = OpStatusCode.Ok;
            try
            {
                if (Player == null) Player = new WMPLib.WindowsMediaPlayer();

                if (param.IndexOf("-help") >= 0)
                {
                    opResult = showHelp(opResult);
                    return opResult;
                }

                DateTime startTime = DateTime.Now;

                // Use custom format?
                Match custom_match = custom_regex.Match(param);
                if (custom_match.Success)
                {
                    showWhat = System.Convert.ToInt32(custom_match.Groups["index"].Value, 10);
                    param = custom_match.Groups["remainder"].Value;
                }

                Match match = index_regex.Match(param);
                if (match.Success)
                {
                    idx = System.Convert.ToInt32(match.Groups["index"].Value, 10);
                    bByIndex = true;
                    param = "";
                }
                else
                {
                    idx = 0;
                    param = param.ToLower();
                }

                if (showWhat == 0)
                {
                    opResult = listArtistsOnly(opResult, param);
                    TimeSpan duration = DateTime.Now - startTime;
                    opResult.AppendFormat("elapsed_time={0}", duration.TotalSeconds);
                    return opResult;
                }
                if (param.Length > 0) mediaPlaylist = byArtist(param);
                else mediaPlaylist = Player.mediaCollection.getByAttribute("MediaType", "Audio");

                bool bArtistMatch = false;
                the_state.init();

                int iCount = mediaPlaylist.count;

                string keyArtist = "";
                string keyAlbum = "";

                // Header:
                templateOut(String.Format("{0}H", showWhat), opResult, 0, -1);

                for (int x = idx; x < iCount; x++)
                {
                    media = mediaPlaylist.get_Item(x);
                    the_state.nextArtist = media.getItemInfo("WM/AlbumArtist");
                    if (the_state.nextArtist == "") the_state.nextArtist = media.getItemInfo("Author");
                    the_state.nextAlbum = media.getItemInfo("WM/AlbumTitle");
                    if (bByIndex && x == idx)
                    {
                        keyArtist = the_state.nextArtist;
                        keyAlbum = the_state.nextAlbum;
                    }
                    else
                    {
                        if (showBy == by_track && keyArtist.Length > 0 && x != idx) break;
                        if (showBy == by_artist && keyArtist.Length > 0 && the_state.nextArtist != keyArtist) break;
                        if (showBy == by_album && keyArtist.Length > 0 && (the_state.nextAlbum != keyAlbum || the_state.nextArtist != keyArtist)) break;
                    }

                    if (the_state.nextArtist != the_state.artist)   // New artist?
                    {
                        if (bArtistMatch) // Did last artist match?
                        {
                            // Close album:
                            if (the_state.album.Length > 0)
                            {
                                if (!templateOut(String.Format("{0}.{1}-", showWhat, show_albums), opResult, x, -1) && ((showWhat & show_albums) != 0) && the_state.albumTrackCount > 0)
                                    opResult.AppendFormat("    Album_song_count: {0}", the_state.albumTrackCount);
                            }
                            the_state.resetAlbum();
                            // Close artist"
                            if (!templateOut(String.Format("{0}.{1}-", showWhat, show_artists), opResult, x, -1))
                            {
                                if (the_state.artistAlbumCount > 0) opResult.AppendFormat("  Artist_album_count: {0}", the_state.artistAlbumCount);
                                if (the_state.artistTrackCount > 0) opResult.AppendFormat("  Artist_song_count: {0}", the_state.artistTrackCount);
                            }
                            the_state.resetArtist();
                        }
                        if (the_state.nextArtist.ToLower().StartsWith(param))
                        {
                            bArtistMatch = true;
                            the_state.artistCount += 1;

                            the_state.artistIndex = x;

                            if (keyArtist.Length <= 0)
                            {
                                keyArtist = the_state.nextArtist;
                                keyAlbum = the_state.nextAlbum;
                            }
                        }
                        else bArtistMatch = false;
                        the_state.artist = the_state.nextArtist;
                        if (bArtistMatch)
                        {
                            // Open Artist
                            if (!templateOut(String.Format("{0}.{1}+", showWhat, show_artists), opResult, x, -1) && ((showWhat & show_artists) != 0))
                                opResult.AppendFormat("Artist:<{0}> \"{1}\"", x, the_state.artist);
                        }
                    }
                    if (bArtistMatch)
                    {
                        the_state.artistTrackCount += 1;
                        the_state.trackCount += 1;
                        if (the_state.nextAlbum != the_state.album)
                        {
                            if (the_state.album.Length > 0)
                            {
                                // Close album
                                if (!templateOut(String.Format("{0}.{1}-", showWhat, show_albums), opResult, x, -1) && ((showWhat & show_albums) != 0) && the_state.albumTrackCount > 0)
                                    opResult.AppendFormat("    Album_song_count: {0}", the_state.albumTrackCount);
                            }
                            the_state.resetAlbum();
                            the_state.album = the_state.nextAlbum;
                            if (the_state.nextAlbum.Length > 0)
                            {
                                the_state.albumIndex = x;
                                the_state.albumCount += 1;
                                the_state.artistAlbumCount += 1;
                                the_state.albumList_add(the_state.nextAlbum);
                                the_state.albumYear = media.getItemInfo("WM/Year");
                                the_state.albumGenre = media.getItemInfo("WM/Genre");
                                the_state.findAlbumCover(media.sourceURL);
                                // Open album
                                if (!templateOut(String.Format("{0}.{1}+", showWhat, show_albums), opResult, x, -1) && ((showWhat & show_albums) != 0))
                                    opResult.AppendFormat("  Album:<{0}> \"{1}\"", x, the_state.nextAlbum);
                            }
                        }
                        the_state.album = the_state.nextAlbum;
                        the_state.albumTrackCount += 1;
                        the_state.song = media.getItemInfo("Title");
                        the_state.songLocation = media.sourceURL;
                        the_state.songTrackNumber = media.getItemInfo("WM/TrackNumber");
                        the_state.songLength = media.durationString;
                        if (the_state.albumYear == "" || the_state.albumYear.Length < 4) the_state.albumYear = media.getItemInfo("WM/OriginalReleaseYear");
                        the_state.albumGenre_add(media.getItemInfo("WM/Genre"));
                        the_state.findAlbumCover(the_state.songLocation);

                        // Open / close song
                        if (!templateOut(String.Format("{0}.{1}-", showWhat, show_songs), opResult, x, -1) && ((showWhat & show_songs) != 0) && the_state.song.Length > 0)
                            opResult.AppendFormat("    Song:<{0}> \"{1}\" ({2})", x, the_state.song, the_state.songLength);
                        templateOut(String.Format("{0}.{1}+", showWhat, show_songs), opResult, x, -1);

                        // Play / queue song?
                        if (play)
                        {
                            PlayMediaCmd pmc;
                            pmc = new PlayMediaCmd(MediaType.Audio, !bFirst);
                            bFirst = false;
                            opResult = pmc.Execute(media.sourceURL);
                        }
                    }
                }
                if (play) opResult.AppendFormat("Queued {0} songs to play", the_state.trackCount);
                else
                {
                    // Close album:
                    if (the_state.album.Length > 0)
                    {
                        if (!templateOut(String.Format("{0}.{1}-", showWhat, show_albums), opResult, the_state.trackCount, -1) && ((showWhat & show_albums) != 0) && the_state.albumTrackCount > 0)
                            opResult.AppendFormat("    Album_song_count: {0}", the_state.albumTrackCount);
                    }
                    the_state.resetAlbum();
                    // Close artist:
                    if (!templateOut(String.Format("{0}.{1}-", showWhat, show_artists), opResult, the_state.trackCount, -1))
                    {
                        if (the_state.artistAlbumCount > 0) opResult.AppendFormat("  Artist_album_count: {0}", the_state.artistAlbumCount);
                        if (the_state.artistTrackCount > 0) opResult.AppendFormat("  Artist_song_count: {0}", the_state.artistTrackCount);
                    }
                    the_state.resetArtist();
                }
                // Footer:
                TimeSpan elapsed_duration = DateTime.Now - startTime;
                if (!templateOut(String.Format("{0}F", showWhat), opResult, the_state.trackCount, elapsed_duration.TotalSeconds))
                {
                    if (the_state.artistCount > 0) opResult.AppendFormat("Artist_count: {0}", the_state.artistCount);
                    if (the_state.albumCount > 0) opResult.AppendFormat("Album_count: {0}", the_state.albumCount);
                    if (the_state.trackCount > 0) opResult.AppendFormat("Song_count: {0}", the_state.trackCount);
                    opResult.AppendFormat("elapsed_time={0}", elapsed_duration.TotalSeconds);
                }

            }
            catch (Exception ex)
            {
                opResult.StatusCode = OpStatusCode.Exception;
                opResult.StatusText = ex.Message;
            }
            return opResult;
        }
예제 #38
0
파일: FormModel.cs 프로젝트: kustOFF/PROGA
        //сканируем auth
        private void F2()
        {
            while(SetAuth.Default.auth==false) { }

            string method = "audio.get.xml";
            string parametrs = "owner_id";

            string owner = SetAuth.Default.id;

            string token = SetAuth.Default.token;

            string resp = GET_http("https://api.vk.com/method/" +method+"?"+parametrs+"=" +owner+"&v=5.37&access_token=" + token);
            //MessageBox.Show(resp);
            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(resp);
            HtmlNodeCollection Node = doc.DocumentNode.SelectNodes("//title");
            HtmlNodeCollection Node1 = doc.DocumentNode.SelectNodes("//artist");
            HtmlNodeCollection Node2 = doc.DocumentNode.SelectNodes("//url");

            try
            {
                Audio = new string[Node.Count]; // artist + title
                title = new string[Node.Count];
                artist = new string[Node1.Count];
                URL = new string[Node2.Count];
                UrlDownload = new string[Node.Count];

                int il = 0;
                int il1 = 0;
                int il2 = 0;

                PlayList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("Vkontaktik PlayList");

                this.Invoke((MethodInvoker)delegate ()
                {
                    //Достаем title
                    foreach (HtmlNode Data_Node in Node)
                    {
                        title[il] = Data_Node.InnerHtml;
                        il++;
                    }

                    //Достаем artist
                    foreach (HtmlNode Data_Node1 in Node1)
                    {
                        artist[il1] = Data_Node1.InnerHtml;
                        il1++;
                    }

                    foreach (HtmlNode Data_Node2 in Node2)
                    {
                        URL[il2] = Data_Node2.InnerHtml;                  //Достаем URL
                        Media = axWindowsMediaPlayer1.newMedia(URL[il2]); //Записываем URL в media
                        PlayList.appendItem(Media);                       // Добавляем media в playlist

                        UrlDownload[il2] = URL[il2].Split('?')[0];        // Режим Url для загрузки
                        Audio[il2] = artist[il2] + " - " + title[il2];    // склеиваем название

                        il2++;
                    }

                    listBox1.Items.Clear();
                    listBox1.Items.AddRange(Audio);

                    axWindowsMediaPlayer1.currentPlaylist = PlayList;
                    axWindowsMediaPlayer1.Ctlcontrols.stop();

                    timer2.Start();

                    listBox1.SelectedIndex = 0;
                });

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
예제 #39
0
        private void LoadMyMusic()
        {
            Thread.Sleep(TimeSpan.FromSeconds(2));

            this.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                (ThreadStart)delegate ()
                {
                    MyMusicEngine engineMyMusic = new MyMusicEngine();
                    engineMyMusic.MyMusicLoad();
                    _MyMusicResult = engineMyMusic.MyMusicLoadGetFiles();
                    _MyMusicResultUrls = engineMyMusic.MyMusicGetUrls();

                    MyMusicListWithURLs = activeXMediaPlayerMyMusic.playlistCollection.newPlaylist("MyMusicPlayList");

                    for (int i = 0; i < _MyMusicResultUrls.Count(); i++)
                    {

                        MyMusicURL = activeXMediaPlayerMyMusic.newMedia(_MyMusicResultUrls[i]);
                        MyMusicListWithURLs.appendItem(MyMusicURL);

                    }
                    activeXMediaPlayerMyMusic.currentPlaylist = MyMusicListWithURLs;
                    activeXMediaPlayerMyMusic.Ctlcontrols.stop();

                    ListBoxMyMusic.ItemsSource = engineMyMusic.MyMusicLoadGetFiles();

                }
            );
        }
예제 #40
0
        /// <summary>
        /// Executes the specified param.
        /// </summary>
        /// <param name="param">The param.</param>
        /// <param name="result">The result.</param>
        /// <returns></returns>
        public OpResult Execute(string param)
        {
            reset_globals();

            debug_last_action = "Execute: Start";

            HashSet<int> results = new HashSet<int>();

            DateTime startTime = DateTime.Now;

            OpResult opResult = new OpResult();
            opResult.StatusCode = OpStatusCode.Ok;

            string template = "";

            page_limit = 0xFFFF;
            page_start = 0;

            bool bFilter = false;
            string clean_filter_params = "";
            string clean_paging_params = "";

            try
            {
                if (param.IndexOf("-help") >= 0)
                {
                    opResult = showHelp(opResult);
                    return opResult;
                }
                if (action == CLEAR_CACHE)
                {
                    opResult = clear_cache();
                    launch_generate_tags_list();
                    return opResult;
                }
                if (Player == null) Player = new WMPLib.WindowsMediaPlayer();
                photo_media_play_list = Player.mediaCollection.getByAttribute("MediaType", "Photo");

                debug_last_action = "Execution: Parsing params";
                // "Paging"?
                if (param.Contains("page-limit:"))
                {
                    page_limit = parse_int(param.Substring(param.IndexOf("page-limit:") + "page-limit:".Length));
                    clean_paging_params += "page-limit:" + page_limit + " ";
                }
                if (param.Contains("page-start:"))
                {
                    page_start = parse_int(param.Substring(param.IndexOf("page-start:") + "page-start:".Length));
                    clean_paging_params += "page-start:" + page_start + " ";
                }

                // Use Custom Template?
                if (param.Contains("template:"))
                {
                    template = param.Substring(param.IndexOf("template:") + "template:".Length);
                    if (template.IndexOf(" ") >= 0) template = template.Substring(0, template.IndexOf(" "));
                    clean_paging_params += "template:" + template + " ";
                }

                // Check if any filters are used
                if (param.Contains("is-tagged:"))
                {
                    bFilter = true;
                    string tag_string = param.Substring(param.IndexOf("is-tagged:") + "is-tagged:".Length);
                    if (tag_string.IndexOf(" ") >= 0) tag_string = tag_string.Substring(0, tag_string.IndexOf(" "));
                    List<string> tag_list = new List<string>(tag_string.Split(';'));
                    tag_list.Sort();
                    clean_filter_params += "is-tagged:" + String.Join(";", tag_list.ToArray()) + " ";
                }
                if (param.Contains("not-tagged:"))
                {
                    bFilter = true;
                    string tag_string = param.Substring(param.IndexOf("not-tagged:") + "not-tagged:".Length);
                    if (tag_string.IndexOf(" ") >= 0) tag_string = tag_string.Substring(0, tag_string.IndexOf(" "));
                    List<string> tag_list = new List<string>(tag_string.Split(';'));
                    tag_list.Sort();
                    clean_filter_params += "not-tagged:" + String.Join(";", tag_list.ToArray()) + " ";
                }
                if (param.Contains("start-date:"))
                {
                    bFilter = true;
                    string date_string = param.Substring(param.IndexOf("start-date:") + "start-date:".Length);
                    DateTime date;
                    if (date_string.IndexOf(" ") >= 0) date_string = date_string.Substring(0, date_string.IndexOf(" "));
                    string[] date_elements = date_string.Split('-');
                    if (date_elements.Length >= 3)
                    {
                        date = new DateTime(Int32.Parse(date_elements[2]),
                            Int32.Parse(date_elements[0]), Int32.Parse(date_elements[1]));
                        date_string = date.ToShortDateString();
                        date_string = date_string.Replace("/", "-");
                        clean_filter_params += "start-date:" + date_string + " ";
                    }
                }
                if (param.Contains("end-date:"))
                {
                    bFilter = true;
                    string date_string = param.Substring(param.IndexOf("end-date:") + "end-date:".Length);
                    DateTime date;
                    if (date_string.IndexOf(" ") >= 0) date_string = date_string.Substring(0, date_string.IndexOf(" "));
                    string[] date_elements = date_string.Split('-');
                    if (date_elements.Length >= 3)
                    {
                        date = new DateTime(Int32.Parse(date_elements[2]),
                            Int32.Parse(date_elements[0]), Int32.Parse(date_elements[1]));
                        date_string = date.ToShortDateString();
                        date_string = date_string.Replace("/", "-");
                        clean_filter_params += "end-date:" + date_string + " ";
                    }
                }

                // Results specified? OVERRIDES OTHER FILTERS!
                if (param.Contains("ids:"))
                {
                    results = parse_ids(param.Substring(param.IndexOf("ids:") + "ids:".Length));
                    clean_filter_params = "ids:" + results.GetHashCode();
                }

                // Validate caches:
                validate_cache();
                // look for page cache - use filter + paging params, return if found
                if (action != PLAY_PHOTOS && action != QUEUE_PHOTOS && action != SERV_PHOTO && action != SHOW_STATS) //Check cache
                {
                    try
                    {
                        OpResult or = new OpResult();
                        or.StatusCode = OpStatusCode.Ok;
                        or = deserialize_rendered_page(or, action + "_" + clean_filter_params + clean_paging_params);
                        if (or != null) return or;
                    }
                    catch (Exception) { ; }
                }

                switch (action)
                {
                    case SHOW_STATS:
                    case LIST_TAGS:
                        //int pic_count = photo_media_play_list.count;
                        if (bFilter)    // Generate subset of tags based on images
                        {
                            if (results.Count == 0) results = get_list(results, clean_filter_params);
                            //pic_count = results.Count;
                            opResult = list_tags(opResult, template, generate_filtered_tags_list(results));
                        }
                        else            // Full set of tags
                            opResult = list_tags(opResult, template);
                        if (action == SHOW_STATS) opResult = show_stats(template, results);
                        break;
                    case LIST_PHOTOS:
                    case PLAY_PHOTOS:
                    case QUEUE_PHOTOS:
                    case SERV_PHOTO:
                        if (results.Count == 0)
                        {
                            results = get_list(results, clean_filter_params);
                        }

                        // Output results
                        if (action == SERV_PHOTO)
                        {
                            int size_x = 0;
                            int size_y = 0;
                            int size_short = 0;
                            int size_long = 0;

                            debug_last_action = "Execute: Serv Start";
                            if (param.Contains("size-x:"))
                            {
                                string tmp_size = param.Substring(param.IndexOf("size-x:") + "size-x:".Length);
                                if (tmp_size.IndexOf(" ") >= 0) tmp_size = tmp_size.Substring(0, tmp_size.IndexOf(" "));
                                size_x = Convert.ToInt32(tmp_size);
                            }
                            if (param.Contains("size-y:"))
                            {
                                string tmp_size = param.Substring(param.IndexOf("size-y:") + "size-y:".Length);
                                if (tmp_size.IndexOf(" ") >= 0) tmp_size = tmp_size.Substring(0, tmp_size.IndexOf(" "));
                                size_y = Convert.ToInt32(tmp_size);
                            }
                            if (param.Contains("size-short:"))
                            {
                                string tmp_size = param.Substring(param.IndexOf("size-short:") + "size-short:".Length);
                                if (tmp_size.IndexOf(" ") >= 0) tmp_size = tmp_size.Substring(0, tmp_size.IndexOf(" "));
                                size_short = Convert.ToInt32(tmp_size);
                            }
                            if (param.Contains("size-long:"))
                            {
                                string tmp_size = param.Substring(param.IndexOf("size-long:") + "size-long:".Length);
                                if (tmp_size.IndexOf(" ") >= 0) tmp_size = tmp_size.Substring(0, tmp_size.IndexOf(" "));
                                size_long = Convert.ToInt32(tmp_size);
                            }
                            // Return one photo (may be only one)
                            int random_index = -1;
                            int image_index = 0;
                            if (param.Contains("random")) random_index = new Random().Next(results.Count);
                            int result_count = 0;
                            foreach (int i in results)
                            {
                                if (random_index < 0 && result_count >= page_start && result_count < page_start + page_limit)
                                {
                                    image_index = i;
                                    break;
                                }
                                else if (random_index >= 0 && random_index <= result_count)
                                {
                                    image_index = i;
                                    break;
                                }
                                result_count++;
                            }
                            last_img_served = image_index;
                            opResult = getPhoto(photo_media_play_list.get_Item(image_index), size_x, size_y, size_short, size_long);
                            debug_last_action = "Execute: Serv End";
                        }
                        else
                        {
                            string template_result = (action == LIST_PHOTOS) ? getTemplate(template, DEFAULT_RESULT) : getTemplate(template, DEFAULT_PLAY_RESULT);
                            template_result = file_includer(template_result);

                            debug_last_action = "Execute: List: Header";
                            string s_head = (action == LIST_PHOTOS) ? getTemplate(template + "+", DEFAULT_HEAD):getTemplate(template + "+", DEFAULT_PLAY_HEAD);
                            s_head = file_includer(s_head);
                            s_head = do_conditional_replace(s_head, "results_count", String.Format("{0}", results.Count));
                            opResult.AppendFormat("{0}", s_head);

                            debug_last_action = "Execute: List: Items";

                            if (action == PLAY_PHOTOS)
                            {
                                clear_slide_show();
                            }

                            int result_count = 0;
                            string in_file = "";
                            string out_file = "";
                            foreach (int i in results)
                            {
                                if (action == PLAY_PHOTOS || action == QUEUE_PHOTOS)
                                {
                                    //Create dir if needed:
                                    if (!Directory.Exists(SLIDE_SHOW_DIR)) create_dirs();
                                    // Add photo to slideshow directory
                                    in_file = photo_media_play_list.get_Item(i).getItemInfo("SourceURL");
                                    out_file = SLIDE_SHOW_DIR + "\\" + make_cache_fn(in_file, 100);
                                    File.Copy(in_file, out_file, true);
                                }
                                else if (result_count >= page_start && result_count < page_start + page_limit)
                                {
                                    string s = "";
                                    s = replacer(template_result, photo_media_play_list.get_Item(i), i);
                                    opResult.AppendFormat("{0}", s);
                                }
                                result_count++;
                            }
                            if (action == PLAY_PHOTOS || action == QUEUE_PHOTOS)
                            {
                                // Start playing:
                                Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment.NavigateToPage(Microsoft.MediaCenter.PageId.Slideshow, SLIDE_SHOW_DIR);
                                //Old: Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment.NavigateToPage(Microsoft.MediaCenter.PageId.MyPictures, SLIDE_SHOW_DIR);
                            }
                            debug_last_action = "Execute: List: Footer";
                            TimeSpan duration = DateTime.Now - startTime;
                            string s_foot = (action == LIST_PHOTOS) ? getTemplate(template + "-", DEFAULT_FOOT):getTemplate(template + "-", DEFAULT_PLAY_FOOT);
                            s_foot = file_includer(s_foot);
                            s_foot = do_conditional_replace(s_foot, "elapsed_time", String.Format("{0}", duration.TotalSeconds));
                            s_foot = do_conditional_replace(s_foot, "results_count", String.Format("{0}", results.Count));
                            opResult.AppendFormat("{0}", s_foot);
                        }

                        break;
                }
            }
            catch (Exception ex)
            {
                opResult = new OpResult();
                opResult.StatusCode = OpStatusCode.Exception;
                opResult.StatusText = ex.Message;
                opResult.AppendFormat("{0}", debug_last_action);
                opResult.AppendFormat("{0}", ex.Message);
            }

            if (action == LIST_TAGS)
            {
                debug_last_action = "Execute: List: Footer";
                TimeSpan duration = DateTime.Now - startTime;
                string s_foot = getTemplate(template + "-", DEFAULT_REPORT_FOOT);
                s_foot = file_includer(s_foot);
                s_foot = do_conditional_replace(s_foot, "elapsed_time", String.Format("{0}", duration.TotalSeconds));
                s_foot = do_conditional_replace(s_foot, "results_count", String.Format("{0}", kw_count));
                s_foot = do_conditional_replace(s_foot, "first_date", String.Format("{0}", first_date.ToShortDateString()));
                s_foot = do_conditional_replace(s_foot, "last_date", String.Format("{0}", last_date.ToShortDateString()));
                opResult.AppendFormat("{0}", s_foot);
            }

            // save page to cache - use filter + paging params
            // TODO: elapsed time is incorrectly cached! Add is_cached to custom templates
            if (opResult.StatusCode == OpStatusCode.Ok &&
                action != PLAY_PHOTOS && action != QUEUE_PHOTOS && action != SERV_PHOTO && action != SHOW_STATS) // Save cache
            {
                debug_last_action = "Execute: Saving page to cache";
                try { serialize_rendered_page(opResult, action + "_" + clean_filter_params + clean_paging_params); }
                catch (Exception e) { debug_last_action = "Execute: Save to Cache failed: " + e.Message; }
            }

            debug_last_action = "Execute: End";

            return opResult;
        }
예제 #41
0
 public photoCmd(int do_what)
 {
     action = do_what;
     /* Do init on the statics */
     if (!init_run)
     {
         init_run = true;
         loadTemplate();
         if (Player == null) Player = new WMPLib.WindowsMediaPlayer();
         photo_media_play_list = Player.mediaCollection.getByAttribute("MediaType", "Photo");
         validate_cache();
     }
 }
예제 #42
0
        private void LoadSearcResult()
        {
            Thread.Sleep(TimeSpan.FromSeconds(2));

            this.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                (ThreadStart)delegate ()
                {
                    SearchEngine engine = new SearchEngine(TextBoxSearch.Text);
                    engine.Search();
                    _Result = engine.GetFiles();
                    _ResultUrls = engine.GetUrls();
                    ListWithURLs = activeXMediaPlayer.playlistCollection.newPlaylist("vkPlayList");

                    for (int i = 0; i < _ResultUrls.Count(); i++)
                    {

                        URL = activeXMediaPlayer.newMedia(_ResultUrls[i]);
                        ListWithURLs.appendItem(URL);

                    }
                    activeXMediaPlayer.currentPlaylist = ListWithURLs;
                    activeXMediaPlayer.Ctlcontrols.stop();

                    ListBoxSearch.ItemsSource = engine.GetFiles();

                }
                );
        }
예제 #43
0
파일: Form1.cs 프로젝트: renk46/VK.Player
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            while (!Settings1.Default.auth) { Thread.Sleep(500); }

            WebRequest request =
               WebRequest.Create("https://api.vk.com/method/audio.get?ower_id" + Settings1.Default.id + "&need_user=0&access_token=" + Settings1.Default.token);
            WebResponse response = request.GetResponse();
            Stream dataStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(dataStream);
            string responseFromServer = reader.ReadToEnd();
            reader.Close();
            response.Close();
            responseFromServer = HttpUtility.HtmlDecode(responseFromServer);

            JToken token = JToken.Parse(responseFromServer);
            audioList = Enumerable.Skip(token["response"].Children(), 0).Select(c => c.ToObject<Audio>()).ToList();

            this.Invoke((MethodInvoker)delegate
            {
                PlayList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("vkPlayList");
                for (int i = 0; i < audioList.Count(); i++)
                {
                    Media = axWindowsMediaPlayer1.newMedia(audioList[i].url);
                    PlayList.appendItem(Media);
                    listBox1.Items.Add(audioList[i].artist + " - " + audioList[i].title);
                }
                axWindowsMediaPlayer1.currentPlaylist = PlayList;
                axWindowsMediaPlayer1.settings.setMode("loop", false);
                axWindowsMediaPlayer1.settings.setMode("shuffle", false);
                axWindowsMediaPlayer1.Ctlcontrols.stop();
            });
        }