Example #1
0
        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();
        }
        public static void Initialize()
        {
            try
            {
                backgroundPlayer.settings.volume          = 20;
                laserPlayer.settings.autoStart            = false;
                spaceTrashPlayer.settings.autoStart       = false;
                terroristPlayer.settings.autoStart        = false;
                backgroundPlayer.settings.autoStart       = false;
                monsterExplosionPlayer.settings.autoStart = false;
                bombExplosionPlayer.settings.autoStart    = false;
                smallPowerUp.settings.autoStart           = false;
                bigPowerUp.settings.autoStart             = false;

                laserPlayer.URL         = Model.SoundFiles[0];
                spaceTrashPlayer.URL    = Model.SoundFiles[1];
                terroristPlayer.URL     = Model.SoundFiles[2];
                backgroundPlayer.URL    = Model.SoundFiles[3];
                bombExplosionPlayer.URL = Model.SoundFiles[4];
                bigPowerUp.URL          = Model.SoundFiles[5];
                smallPowerUp.URL        = Model.SoundFiles[6];

                playlist.appendItem(monsterExplosionPlayer.newMedia(Model.SoundFiles[2]));
                playlist.appendItem(monsterExplosionPlayer.newMedia(Model.SoundFiles[4]));
                monsterExplosionPlayer.currentPlaylist = playlist;
                (backgroundPlayer.settings as IWMPSettings).setMode("loop", true);
            }
            catch (System.Exception exc)
            {
                System.Windows.Forms.MessageBox.Show(exc.Message);
            }
        }
Example #3
0
        //Initalizesthe board components and begins playing the music in the background
        public Mancala()
        {
            InitializeComponent();
            var playlist = playlistPlayer.newPlaylist("mancalaPlaylist", "");

            playlist.appendItem(playlistPlayer.newMedia("Dragonborn.mp3"));
            playlist.appendItem(playlistPlayer.newMedia("Steel-on-Steel.mp3"));
            playlistPlayer.currentPlaylist = playlist;
            //player.URL = "Dragonborn.mp3";
        }
Example #4
0
        private MP3File TrackCreate(string filename, string name)
        {
            MP3File file = new MP3File();

            ReadMP3File(ref file, filename);
            file.Path     = filename;
            file.Name     = name;
            file.MPtime   = Player.newMedia(this.filename).durationString;
            file.Duration = Player.newMedia(this.filename).duration;
            GetMinutes(file.Duration);
            return(file);
        }
Example #5
0
        private Hashtable getMediaInfo(string in_path)
        {
            Hashtable ht = new Hashtable();

            IWMPMedia imed = mp.newMedia(in_path);

            for (int z = 0; z < imed.attributeCount; z++)
            {
                ht.Add(imed.getAttributeName(z), imed.getItemInfo(imed.getAttributeName(z)));
            }
            mp.close();
            return(ht);
        }
Example #6
0
 public void PlayMusicFiles(List <MusicFile> musicFiles, bool newPlaylist)
 {
     if (newPlaylist)
     {
         Stop();
         CurrentPlayList = _player.playlistCollection.newPlaylist("newSongs");
         musicFiles.ForEach(mFile => CurrentPlayList.appendItem(_player.newMedia(mFile.Url)));
         _player.currentPlaylist = CurrentPlayList;
         _player.controls.play();
     }
     else
     {
         musicFiles.ForEach(mFile => CurrentPlayList.appendItem(_player.newMedia(mFile.Url)));
     }
 }
Example #7
0
        // 각종 변수들의 초기화와 매트릭스 초기화를 담당.
        private void Form1_Load(object sender, EventArgs e)
        {
            centerX = this.Width / 2;
            centerY = this.Height / 2;

            Size screenSize = new Size(this.Width * 2, this.Height * 2);

            screenPoint      = new Point[1];
            screenPoint[0].X = -this.Width / 2; screenPoint[0].Y = -this.Height / 2;
            fullScreen       = new Rectangle(screenPoint[0], screenSize);

            matrix_rotate.RotateAt(turn, new PointF(centerX, centerY));
            matrix_player_right.RotateAt(turn * 5f, new PointF(centerX, centerY));
            matrix_player_left.RotateAt(-turn * 5f, new PointF(centerX, centerY));
            matrix_big.Scale(3, 3);
            matrix_small.Scale(-3, -3);

            // 배경음 초기화
            string filePath = Application.StartupPath + @"\\bgm.mp3";

            wmp = new WindowsMediaPlayer();
            IWMPMedia    bgm      = wmp.newMedia(filePath);
            IWMPPlaylist playlist = wmp.newPlaylist("MusicPlayer", "");

            playlist.appendItem(bgm);
            wmp.currentPlaylist = playlist;
            wmp.controls.stop();

            DateTime dtmcurrent = DateTime.Now;

            generator = new Random(dtmcurrent.Millisecond);
        }
Example #8
0
 public TimeSpan?GetDuration(string filePath)
 {
     try
     {
         using (ShellObject shell = ShellObject.FromParsingName(filePath))
         {
             IShellProperty prop  = shell.Properties.System.Media.Duration;
             var            value = prop.ValueAsObject;
             return(TimeSpan.FromTicks((long)(ulong)value));
             // Duration will be formatted as 00:44:08
             //string duration = prop.FormatForDisplay(PropertyDescriptionFormatOptions.None);
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e);
         try
         {
             IWMPMedia mediainfo = _wmp.newMedia(filePath);
             var       duration  = mediainfo.duration;
             if (duration < double.Epsilon)
             {
                 return(null);
             }
             return(TimeSpan.FromSeconds(duration));
         }
         catch (Exception e2)
         {
             Debug.WriteLine(e);
             return(null);
         }
         return(null);
     }
 }
Example #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog ofd = new OpenFileDialog()
            {
                Multiselect = true, ValidateNames = true, Filter = "WMV|*.wmv|WAV|*.wav|MP3*|*.mp3|MP4|*.mp4|MKV|*.mkv"
            })
            {
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    this.axWindowsMediaPlayer1.URL = ofd.FileName;
                    axWindowsMediaPlayer1.Ctlcontrols.stop();
                }

                button1.Hide();

                label2.Text = "Title: " + axWindowsMediaPlayer1.currentMedia.name; // name of video

                var player = new WindowsMediaPlayer();
                var clip   = player.newMedia(ofd.FileName);
                label3.Text = "Length: " + TimeSpan.FromSeconds(clip.duration).ToString(); // length of video

                var ffMpeg = new NReco.VideoConverter.FFMpegConverter();

                string namepicture = axWindowsMediaPlayer1.currentMedia.name + ".jpg";
                ffMpeg.GetVideoThumbnail(ofd.FileName, namepicture); // using FFMPEG to take first photo of video


                pictureBox1.Image = Image.FromFile(namepicture); // saving picture into pictureBox
            }
        }
Example #10
0
        public double GetLength(String file)
        {
            WindowsMediaPlayer wmp       = new WindowsMediaPlayer();
            IWMPMedia          mediainfo = wmp.newMedia(file);

            return(mediainfo.duration);
        }
Example #11
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if (filePath.Text.ToString() == "")
            {
                MessageBox.Show("Please select a valid file");
                return;
            }

            WindowsMediaPlayer wmp       = new WindowsMediaPlayer();
            IWMPMedia          mediainfo = wmp.newMedia(audioFilePath);
            int minutes = (int)mediainfo.duration / 60;
            int seconds = (int)mediainfo.duration % 60;

            string time;

            if (seconds < 10)
            {
                time = minutes.ToString() + ":0" + seconds.ToString();
            }
            else
            {
                time = minutes.ToString() + ":" + seconds.ToString();
            }

            audioList.Items.Add(new ListViewItem(new String[] { id.ToString(), audioName, time }));
            id++;
        }
Example #12
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // file types, that will be allowed to upload
            openFileDialog1.Filter = "Video files | *.mp4";
            // allow/deny user to upload more than one file at a time
            openFileDialog1.Multiselect = false;
            // if user clicked OK
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    string path     = openFileDialog1.FileName; // get name of file
                    var    savePath = ConfigurationManager.AppSettings["SaveVideoRoot"];
                    if (!Directory.Exists(savePath))
                    {
                        Directory.CreateDirectory(savePath);
                    }

                    string fakeName = (DateTime.Now.ToString("ddMMyyyyyHHmmss") + "" + openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf('.')));
                    File.Copy(path, (savePath + fakeName), true);
                    var player = new WindowsMediaPlayer();
                    var clip   = player.newMedia(path);
                    var time   = TimeSpan.FromSeconds(clip.duration);

                    BLLVideo.Instance.AddFile(connect, new Data.Q_Video()
                    {
                        FileName = openFileDialog1.SafeFileName, FakeName = fakeName, Duration = time
                    });
                    LoadData();
                }
                catch (Exception ex)
                {
                }
            }
        }
Example #13
0
        static Double getDuration(string file)
        {
            WindowsMediaPlayer wmp       = new WindowsMediaPlayer();
            IWMPMedia          mediainfo = wmp.newMedia(file);

            return(mediainfo.duration);
        }
Example #14
0
        private void LoadFolder(string folderPath)
        {
            var    dirInfo           = new DirectoryInfo(folderPath);
            string AllowedVideoTypes = "*.mkv";
            var    files             = dirInfo.GetFiles(AllowedVideoTypes, SearchOption.TopDirectoryOnly);
            int    season            = (int)nudSeason.Value;
            int    startEp           = (int)nudEpisodes.Value;

            foreach (var info in files)
            {
                var player = new WindowsMediaPlayer();
                var clip   = player.newMedia(info.FullName);
                var file   = new ShowFile()
                {
                    OriginalFileName = info.Name,
                    OriginalFilePath = info.FullName,
                    DirectoryName    = info.DirectoryName,
                    FileSize         = info.Length,
                    FileSizeString   = BytesToString(info.Length),
                    Duration         = TimeSpan.FromSeconds(clip.duration).ToString(),
                    Season           = season,
                    Episode          = startEp,
                    Extension        = info.Extension,
                    CreatedAt        = info.CreationTime,
                    Skip             = false,
                };
                this._showFiles.Add(file);
                if (CbIncEp.Checked)
                {
                    startEp++;
                }
            }
            RefreshView();
        }
Example #15
0
 void showPlaylist(string path)
 {
     //Save selected path in setting
     Properties.Settings.Default.MyPath = path;
     Properties.Settings.Default.Save();
     //Create playlist
     playlist = wp.playlistCollection.newPlaylist("MyPlaylist");
     foreach (string s in Directory.GetFiles(Properties.Settings.Default.MyPath, "*.*").Where(s => s.EndsWith(".mp3") || s.EndsWith(".wav")))
     {
         var temp = wp.newMedia(s);
         playlist.appendItem(temp);
     }
     lvPlaylist.Items.Clear();
     showListView(playlist);
     wp.currentPlaylist = playlist;
 }
Example #16
0
        public List <string> GetMovies(int min, int max)
        {
            List <string> movieFiles = new List <string>();
            var           player     = new WindowsMediaPlayer();
            TimeSpan      minLimit   = new TimeSpan(0, 0, min, 0, 0);
            TimeSpan      maxLimit   = new TimeSpan(0, 0, max, 0, 0);

            //returns files from directory and sub directories
            string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            path = path.Replace("Documents", "Vuze Downloads");
            var files = Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories);

            //only take videos bigger than 15 mins
            foreach (string filepath in files)
            {
                if (filepath.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase) || filepath.EndsWith(".wmv", StringComparison.OrdinalIgnoreCase) || filepath.EndsWith(".avi", StringComparison.OrdinalIgnoreCase) || filepath.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase))
                {
                    var      clip = player.newMedia(filepath);
                    TimeSpan t    = TimeSpan.FromSeconds(clip.duration);
                    if (t >= minLimit && t <= maxLimit)
                    {
                        movieFiles.Add(filepath);
                    }
                }
            }
            movieFiles.Sort();
            return(movieFiles);
        }
Example #17
0
 public void SetMediaList(List <Media> mediaList)
 {
     this.m_mediaArray = mediaList;
     for (int i = 0; i < m_mediaArray.Count; i++)
     {
         wmp.currentPlaylist.appendItem(wmp.newMedia(m_mediaArray[i].filePath));
     }
 }
Example #18
0
        public static TimeSpan Duration(String file)
        {
            // ...
            var player = new WindowsMediaPlayer();
            var clip   = player.newMedia(file);

            return(TimeSpan.FromSeconds(clip.duration));
        }
Example #19
0
        private void btnAddFiles_Click(object sender, EventArgs e)
        {
            BLIO.Log("(MUCSound)btnAddFiles_Click");
            int           songsAdded = 0;
            List <string> songPaths  = FSManager.Files.GetSelectedFilesWithPath("Sound files", "*.mp3; *.wav; *.ogg; *.3gp; *.aac; *.flac; *.webm; *.aiff; *.wma; *.alac; *.m4a; *.MPEG-1; *.MPEG-2; *.MPEG-3; *.MPEG-4; *.MPEG-7; *.MPEG-21; *.MJPEG;").ToList();

            if (songPaths.Count == 1 && songPaths[0] == "")//The user canceled out
            {
                return;
            }

            BLIO.Log("user selected " + songPaths.Count + " sound files.");



            List <Songs> songs = new List <Songs>();

            foreach (string songPath in songPaths)
            {
                myPlayer.URL = songPath;
                mediaInfo    = myPlayer.newMedia(myPlayer.URL);
                myPlayer.controls.play();
                myPlayer.controls.stop();

                Songs song = new Songs();
                song.SongFileName = Path.GetFileName(songPath);
                song.SongFilePath = songPath;
                songs.Add(song);
            }
            BLLocalDatabase.Song.InsertSongs(songs);
            BLIO.Log("Inserted " + songs.Count + " sound files into RemindMe");

            foreach (Songs song in songs)
            {
                if (!ListViewContains(song.SongFilePath))
                {
                    songsAdded++;
                    ListViewItem item = new ListViewItem(song.SongFilePath);
                    item.Tag = song.Id;
                    lvSoundFiles.Items.Add(item);
                }
            }
            MaterialMessageFormManager.MakeMessagePopup(songsAdded + " Files added to RemindMe.", 4);
            MaterialForm1.Instance.mucSettings.FillSoundCombobox();
            LoadSongs();
        }
Example #20
0
        private TimeSpan GetDuration(string fileName)
        {
            WindowsMediaPlayer wmp       = new WindowsMediaPlayer();
            IWMPMedia          mediaInfo = wmp.newMedia(fileName);
            TimeSpan           ts        = TimeSpan.FromSeconds(mediaInfo.duration);

            return(ts);
        }
Example #21
0
        public static int SetDurationSong(Song song)
        {
            WindowsMediaPlayer wmp              = new WindowsMediaPlayer();
            string             path             = song.GetPath();
            IWMPMedia          mediaInformation = wmp.newMedia(path);

            return((int)mediaInformation.duration);
        }
Example #22
0
        //xuất thời gian chạy video
        public String thoigian(String path)
        {
            string times  = "";
            var    player = new WindowsMediaPlayer();
            var    clip   = player.newMedia(path);

            times = TimeSpan.FromSeconds(clip.duration).ToString();
            return(times);
        }
Example #23
0
        public TimeSpan GetVideoLength(string videoPath)
        {
            var player = new WindowsMediaPlayer();
            var video  = player.newMedia(videoPath);
            var ret    = TimeSpan.FromSeconds(video.duration);

            player.close();
            return(ret);
        }
        static TimeSpan DirectoryTreeTotalMediaDuration(string path)
        {
            TimeSpan duration = new TimeSpan(0, 0, 0);

            try
            {
                IEnumerator localDirectories = Directory.EnumerateDirectories(path).GetEnumerator();
                IEnumerator files;
                System.Console.WriteLine(path);
                files = Directory.EnumerateFiles(path).GetEnumerator();
                while (files.MoveNext())
                {
                    int      fileLength     = (int)wmp.newMedia(files.Current.ToString()).duration;
                    TimeSpan fileLengthspan = new TimeSpan(0, 0, fileLength);
                    duration = duration + fileLengthspan;
                }
                while (localDirectories.MoveNext())
                {
                    duration = duration + DirectoryTreeTotalMediaDuration(localDirectories.Current.ToString());
                    files    = Directory.EnumerateFiles(localDirectories.Current.ToString()).GetEnumerator();
                    System.Console.WriteLine(localDirectories.Current.ToString());
                    while (files.MoveNext())
                    {
                        int      fileLength     = (int)wmp.newMedia(files.Current.ToString()).duration;
                        TimeSpan fileLengthspan = new TimeSpan(0, 0, fileLength);
                        duration = duration + fileLengthspan;
                    }
                }
            }
            catch (IOException e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                System.Console.WriteLine(e.Message);
                System.Console.WriteLine("\nPlease enter a valid Directory dont ends with \"\\\"");
                Console.ForegroundColor = ConsoleColor.Gray;
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                System.Console.WriteLine(e.Message);
                Console.ForegroundColor = ConsoleColor.Gray;
            }
            return(duration);
        }
Example #25
0
 public override ListViewItem Add(ListViewItem value)
 {
     if (!(value.Tag is TrackMetadata meta))
     {
         throw new ArgumentException("Precondition violation");
     }
     Player.currentPlaylist.appendItem(Player.newMedia(meta.Path));
     value.Tag = Player.currentPlaylist.Item[Player.currentPlaylist.count - 1];
     return(base.Add(value));
 }
Example #26
0
        private void timer3_Tick(object sender, EventArgs e)                    // used for between time
        {
            timer3.Stop();
            if (counter == filespaths.Length - 1)
            {
                this.Close();
            }
            else if (!fixation_cross)
            {
                if (cursor_log)
                {
                    System.Windows.Forms.Cursor.Position = screens_center;              // Move cursor to the center of presentation screen
                }
                stage = "media";
                counter++;
                current_media_file = filespaths[counter];
                string temp = Regex.Replace(current_media_file, @"\s+", "_");
                //name_of_current_media_file = System.IO.Path.GetFileName(temp);
                if (attribute_log)
                {
                    current_attributes_values = attributes_values[counter];
                }

                var player = new WindowsMediaPlayer();
                var clip   = player.newMedia(current_media_file);
                time = (int)TimeSpan.FromSeconds(clip.duration).TotalMilliseconds;

                uc.setMediaSource(current_media_file, displaymode);
                name_of_current_media_file = System.IO.Path.GetFileName(temp);
                uc.mediaPlay();

                start_time = DateTime.Now;

                if (time == 0)
                {
                    timer2.Interval = duration_time;
                    timer2.Start();
                }
                //else
                //timer2.Interval = time;
            }
            else if (fixation_cross)
            {
                stage = "fixation_cross";

                label2.Visible   = true;                                         // make visible the counter (list1.text)
                label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // Draw label to the center od the screen (mabey optional)

                name_of_current_media_file = "ST_" + stage;                      // current_media_file = "between"
                current_attributes_values  = default_attributes_values;          // current_attributes_values = "NaN,NaN,..."

                start_time = DateTime.Now;
                timer5.Start();
            }
        }
        public WmpTagReader(string filename)
        {
            var player = new WindowsMediaPlayer();
            var media = player.newMedia(filename);
            player.close();

            title = media.getItemInfo("Title");
            album = media.getItemInfo("Album");
            artist = media.getItemInfo("Author");
            trackNo = media.getItemInfo("OriginalIndex");
        }
Example #28
0
        /// <summary>
        /// Generates a playlist.
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        private IWMPPlaylist GeneratePlayList(List <string> fileName)
        {
            var playlist = Playah.playlistCollection.newPlaylist("Playlist");

            foreach (string str in fileName)
            {
                var audio = Playah.newMedia(str);
                playlist.appendItem(audio);
            }
            return(playlist);
        }
Example #29
0
        private void btnPreviewSong_Click(object sender, EventArgs e)
        {
            BLIO.Log("(UCSetings)btnPreviewSong_Click");
            ComboBoxItem selectedItem = (ComboBoxItem)cbSound.SelectedItem;

            if (selectedItem == null)
            {
                return;
            }

            Songs selectedSong = (Songs)selectedItem.Value;

            if (selectedSong == null)
            {
                return;
            }

            //Stop the song
            if (btnPreviewSong.Icon == imgStop)
            {
                btnPreviewSong.Icon = imgPlayResume;
                myPlayer.controls.stop();
                tmrMusic.Stop();
                return;
            }

            //Does the file we're trying to play REALLY exist?
            if (File.Exists(selectedSong.SongFilePath))
            {
                BLIO.Log("selected sound file exists on hard drive (MUCSettings)");
                //Set the image to "Stop", since we're going to play a song. Give the user the option to stop it
                btnPreviewSong.Icon = imgStop;

                //Give the player the path to the file
                myPlayer.URL = selectedSong.SongFilePath;
                //Get media info so we know when the song ends
                mediaInfo = myPlayer.newMedia(myPlayer.URL);

                //Start the timer. the timer ticks when the song ends. The timer will then reset the picture of the play button
                if (mediaInfo.duration > 0)
                {
                    tmrMusic.Interval = (int)(mediaInfo.duration * 1000);
                }
                else
                {
                    tmrMusic.Interval = 1000;
                }
                tmrMusic.Start();

                BLIO.Log("Playing sound... (MUCSettings)");
                myPlayer.controls.play();
                myPlayer.settings.volume = trbVolume.Value;
            }
        }
Example #30
0
 public MediaFacade(string fileName)
 {
     wmp = new WindowsMediaPlayer();
     wmp.settings.autoStart = true;
     wmp.settings.setMode("autoRewind", true);
     wmp.PlayStateChange += Wmp_PlayStateChange;
     var media = wmp.newMedia(fileName);
     if (0.0 == media.duration) throw new Exception("Could not load file '" + fileName + "'");
     Length = (float)media.duration;
     wmp.URL = fileName;
 }
Example #31
0
        private void InitMedia(string path)
        {
            WindowsMediaPlayer wmp = new WindowsMediaPlayer();

            this.Media = wmp.newMedia(path);

            this.name      = Media.name;
            this.url       = Media.sourceURL;
            this.fullname  = FileExtendFun.GetFileFullname(Media.sourceURL);
            this.size      = FileExtendFun.GetFileSize(Media.sourceURL);
            this.totaltime = Media.durationString;
        }
        /// <summary>
        /// Opens a folder browser dialog, finds all the karaoke songs in the selected folder and any subfolders and returns a list of songs found.
        /// </summary>
        /// <returns>List of all valid karaoke songs found in the selected folder</returns>
        public List<Song> GetSongList(string filePath)
        {
            //Open the folder dialog and ensure that a folder was selected
            string folderPath = filePath;
            if (folderPath.Equals(""))
                return new List<Song>();

            List<Song> songList = new List<Song>();

            //List of folders, including subfolders to search over
            Queue<string> folderQueue = new Queue<string>();
            folderQueue.Enqueue(folderPath);

            //Iterate over the list of folders and get all karaoke songs out
            while (folderQueue.Count > 0)
            {
                string currentPath = folderQueue.Dequeue();

                //For the current folder get a list of subfolders
                foreach (string path in GetSubFoldersForPath(currentPath))
                    folderQueue.Enqueue(path);

                //Get a list of all files in this folder
                DirectoryInfo directory = new DirectoryInfo(currentPath);
                FileInfo[] files = directory.GetFiles();
                List<FileInfo> karaokeFiles = RemoveInvalidKaraokeFiles(files);

                //Now add the valid karaoke files to the song list
                foreach (FileInfo songInfo in karaokeFiles)
                    songList.Add(GetSongFromFileName(songInfo.FullName, songInfo.Name));
            }

            //Add the song duration to each of the songs
            WindowsMediaPlayer player = new WindowsMediaPlayer();
            for (int x = 0; x < songList.Count; x++)
            {
                IWMPMedia media = player.newMedia(songList[x].pathOnDisk);
                songList[x].duration = (int)media.duration;

                if (x % 10 == 0 && ProgressUpdated != null)
                {
                    ProgressUpdated(this, new ProgressArgs(x, songList.Count));
                }
            }

            if (ProgressUpdated != null)
            {
                ProgressUpdated(this, new ProgressArgs(songList.Count, songList.Count));
            }

            return songList;
        }
Example #33
0
        public frmMenu()
        {
            InitializeComponent();
          

            bmBackground = new PPPBitmap(new Bitmap("CombatGameBackground.gif"), "CombatGameBackground.gif");
            
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
           // this.pbNewGame.Image = imgNewGameSelected;
            wplayer = new WindowsMediaPlayer();
            playlistMenu = wplayer.playlistCollection.newPlaylist("Playlist Menu");
            playlistFight = wplayer.playlistCollection.newPlaylist("Playlist Fight");
            playlistMenu.appendItem(wplayer.newMedia("Eye Of The Tiger Instrumental.mp3"));
            playlistFight.appendItem(wplayer.newMedia("Hardest Gangsta beat ever.mp3"));
            wplayer.currentPlaylist = playlistMenu;
            wplayer.settings.setMode("loop", true);
            wplayer.controls.play();

            pickAForm = 0;
            Invalidate();
            
           
        }
Example #34
0
        static void Main(string[] args)
        {
            WindowsMediaPlayer wmp = new WindowsMediaPlayer();
            string path = args[0];
            DirectoryInfo home = Directory.CreateDirectory(path);
            path = home.FullName;

            FileInfo[] files= home.GetFiles();
            foreach (FileInfo f in files)
            {

               IWMPMedia media= wmp.newMedia(f.FullName);
                string name = media.getItemInfo("Title");
                Console.WriteLine(name);
                f.MoveTo(path+"\\"+name+f.Extension);

            }
        }
Example #35
0
        public static VideoInfo GetVideoInfo(string filePath)
        {
            int videoWidth = 0;
            int videoHeight = 0;

            try
            {
                var player = new WindowsMediaPlayer();
                IWMPMedia mediaInfo = player.newMedia(filePath);

                ShellFile shellFile = ShellFile.FromFilePath(filePath);

                if (shellFile != null)
                {
                    if (shellFile.Properties.System.Video.FrameWidth.Value != null)
                    {
                        videoWidth = (int)shellFile.Properties.System.Video.FrameWidth.Value;
                    }
					else
					{
						videoWidth = 0;
					}

                    if (shellFile.Properties.System.Video.FrameHeight.Value != null)
                    {
                        videoHeight = (int)shellFile.Properties.System.Video.FrameHeight.Value;
                    }
					else
					{
						videoHeight = 0;
					}
                }
                
                VideoInfo video = new VideoInfo(filePath, videoWidth, videoHeight, mediaInfo.duration);
                return video;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Example #36
0
    void UpdateMediaInfo()
    {
        // Solution 1: cannot get width and height

        var mediaDet = (IMediaDet)new MediaDet();
        //DsError.ThrowExceptionForHR(mediaDet.put_Filename(mFileName));
        mediaDet.put_Filename(mFileName);
        // find the video stream in the file
        int index;
        var type = Guid.Empty;
        for (index = 0; index < 1000 && type != MediaType.Video; index++)
        {
            mediaDet.put_CurrentStream(index);
            mediaDet.get_StreamType(out type);
        }
        // retrieve some measurements from the video            
        mediaDet.get_FrameRate(out mFrameRate);
        var mediaType = new AMMediaType();
        var videoInfo = (VideoInfoHeader)Marshal.PtrToStructure(mediaType.formatPtr, typeof(VideoInfoHeader));
        
        // videoInfo.BmiHeader is Null here
        mWidth = videoInfo.BmiHeader.Width;
        mHeight = videoInfo.BmiHeader.Height;
        double mediaLength;
        mediaDet.get_StreamLength(out mediaLength);
        mDuration = (int)(mFrameRate * mediaLength / mFrameRate);
        DsUtils.FreeAMMediaType(mediaType);

        // Solution 2: cannot get width and height

        WindowsMediaPlayer wmp = new WindowsMediaPlayer();
        IWMPMedia mediainfo = wmp.newMedia(mFileName);
        mDuration = mediainfo.duration;
        mWidth = mediainfo.imageSourceWidth;
        mHeight = mediainfo.imageSourceHeight;
        mFrameRate = mediainfo.durationString;

        // Solution 3: don't have video-specific information

        Dictionary<int, KeyValuePair<string, string>> fileProps = GetFileProps(mFileName);
        foreach (KeyValuePair<int, KeyValuePair<string, string>> kv in fileProps)
        {
            Console.WriteLine(kv.ToString());
        }

        // Solution 4: LoadLock & x86 conflict problem

        Video video = new Video(mFileName, false);
        Size size = video.DefaultSize;
        mWidth = size.Width;
        mHeight = size.Height;
        mDuration = video.Duration;

        // Solution 5: Use Cygwin file.exe to fetch infomation

        Process p = new Process();
        p.StartInfo.CreateNoWindow = true;
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardOutput = true;
        //p.StartInfo.WorkingDirectory = strWorkingDirectory;
        p.StartInfo.FileName = "file.exe";
        p.StartInfo.Arguments = "\"" + Regex.Replace(mFileName, @"(\\+)$", @"$1$1") + "\"";
        p.Start();
        string strOutput = p.StandardOutput.ReadToEnd();
        p.WaitForExit();
        Console.WriteLine("result: " + strOutput);

        // Solution 6: Use NReco.VideoInfo (wrapper of FFProbe)

        var filePath = "gizmo.mp4";
        var ffProbe = new FFProbe();
        var videoInfo = ffProbe.GetMediaInfo(filePath);

        Console.WriteLine("Media information for: {0}", filePath);
        Console.WriteLine("File format: {0}", videoInfo.FormatName);
        Console.WriteLine("Duration: {0}", videoInfo.Duration);
        foreach (var tag in videoInfo.FormatTags)
        {
            Console.WriteLine("\t{0}: {1}", tag.Key, tag.Value);
        }

        foreach (var stream in videoInfo.Streams)
        {
            Console.WriteLine("Stream {0} ({1})", stream.CodecName, stream.CodecType);
            if (stream.CodecType == "video")
            {
                Console.WriteLine("\tFrame size: {0}x{1}", stream.Width, stream.Height);
                Console.WriteLine("\tFrame rate: {0:0.##}", stream.FrameRate);
            }
            foreach (var tag in stream.Tags)
            {
                Console.WriteLine("\t{0}: {1}", tag.Key, tag.Value);
            }
        }

        Console.WriteLine("\nPress any key to exit...");
        Console.ReadKey();
    }
        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            btn_Upload.Enabled = true;
            txt_Filepath.Text = openFileDialog1.FileName;
            FileInfo file = new FileInfo(openFileDialog1.FileName);
            lbl_Filesize.Text = "File Size: " + GetFileSize(file.Length);

            var player = new WindowsMediaPlayer();
            var clip = player.newMedia(openFileDialog1.FileName);
            Console.WriteLine(TimeSpan.FromSeconds(clip.duration));
        }
		public static Dictionary<ColumnType, object> GetVideoDetails(string fileName)
		{
			Dictionary<ColumnType, object> info = null;
			try
			{
				var ffProbe = new FFProbe();
				var videoInfo = ffProbe.GetMediaInfo(fileName);
				Console.WriteLine("Media information for: {0}", fileName);
				Console.WriteLine("File format: {0}", videoInfo.FormatName);
				Console.WriteLine("Duration: {0}", videoInfo.Duration);
				info = new Dictionary<ColumnType, object>();
				info.Add(ColumnType.Duration, Math.Round(videoInfo.Duration.TotalSeconds));

				foreach (var tag in videoInfo.FormatTags)
				{
					Console.WriteLine("\t{0}: {1}", tag.Key, tag.Value);
				}
				foreach (var stream in videoInfo.Streams)
				{
					Console.WriteLine("Stream {0} ({1})", stream.CodecName, stream.CodecType);
					if (stream.CodecType == "video")
					{
						Console.WriteLine("\tFrame size: {0}x{1}", stream.Width, stream.Height);
						Console.WriteLine("\tFrame rate: {0:0.##}", stream.FrameRate);
						info.Add(ColumnType.Width, stream.Width);
						info.Add(ColumnType.Height, stream.Height);
					}
					foreach (var tag in stream.Tags)
					{
						Console.WriteLine("\t{0}: {1}", tag.Key, tag.Value);
					}
				}
			}
			catch { }
			if (info == null)
			{
				try
				{
					WindowsMediaPlayer wmp = new WindowsMediaPlayer();
					IWMPMedia mediaInfo = wmp.newMedia(fileName);
					info = new Dictionary<ColumnType, object>();
					info.Add(ColumnType.Duration, Math.Round(mediaInfo.duration));
					info.Add(ColumnType.Width, mediaInfo.imageSourceWidth);
					info.Add(ColumnType.Height, mediaInfo.imageSourceHeight);
				}
				catch { throw; }
			}
			return info;
		}
Example #39
-1
 public static void Play(string file)
 {
     WindowsMediaPlayer wmp = new WindowsMediaPlayer();
     wmp.currentMedia = wmp.newMedia(file);
     wmp.controls.currentPosition = 600;
     wmp.controls.play();
 }
Example #40
-2
 public Player(IEnumerable<FileInfo> Playlist)
 {
     _player = new WindowsMediaPlayer();
     playlist = _player.playlistCollection.newPlaylist("myplaylist");
     foreach (var file in Playlist)
     {
         var media = _player.newMedia(file.FullName);
         playlist.appendItem(media);
     }
     _player.currentPlaylist = playlist;
     _player.controls.stop();
     _player.PlayStateChange += _player_PlayStateChange;
 }