private void zamanFarki(int x)
 {
     if (x == 0)
     {
         StreamReader sr = new StreamReader(veriYoluTxt.Text.ToString());
         while (sr.ReadLine() != null)
         {
             if (sr.ReadLine() != "AccX;AccY;AccZ;GraX;GraY;GraZ;LAX;LAY;LAZ;GyroX;GyroY;GyroZ;Time2" && sr.ReadLine() != "AccX;AccY;AccZ;GraX;GraY;GraZ;LAX;LAY;LAZ;GyroX;GyroY;GyroZ;Time2;")
             {
                 ilkD = sr.ReadLine().Split(';');
                 ilk  = ilkD[ilkD.Length - 1];
                 break;
             }
         }
         son  = File.ReadLines(veriYoluTxt.Text.ToString()).Last();
         sonD = son.Split(';');
         son  = sonD[sonD.Length - 1];
         TimeSpan tilk = TimeSpan.Parse(ilk);
         TimeSpan tson = TimeSpan.Parse(son);
         fark = tson - tilk;
     }
     else if (x == 1)
     {
         WindowsMediaPlayer wmp       = new WindowsMediaPlayerClass();
         IWMPMedia          mediainfo = wmp.newMedia(videoTxt.Text.ToString());
         string             sonV      = "00:" + mediainfo.durationString;
         TimeSpan           tsv       = TimeSpan.Parse(sonV);
         TimeSpan           sonFark   = fark - tsv;
         farkk = Convert.ToInt16(sonFark.TotalSeconds);
     }
 }
Exemple #2
0
        public static int Duration(string file)
        {
            WindowsMediaPlayer wmp       = new WindowsMediaPlayerClass();
            IWMPMedia          mediainfo = wmp.newMedia(file);

            return((int)mediainfo.duration);
        }
        public static void play(string recordPath, PictureBox voiceBtn)
        {
            if (player == null)
            {
                player = new WindowsMediaPlayerClass();
                player.PlayStateChange += Player_PlayStateChange;
            }

            if (player.URL == recordPath && player.playState == WMPPlayState.wmppsPlaying)
            {
                currentVoiceBtn.Load(@"icons\voice.png");
                player.stop();
                Console.WriteLine("停止播放");
            }
            else
            {
                // 停止上一个在播放的图标
                if (currentVoiceBtn != null)
                {
                    currentVoiceBtn.Load(@"icons\voice.png");
                }

                // 开始播放新图标
                currentVoiceBtn = voiceBtn;
                currentVoiceBtn.Load(@"icons\voicePlay.gif");

                player.URL = recordPath;

                player.play();

                Console.WriteLine("开始播放" + recordPath);
            }
        }
Exemple #4
0
        public Double Duration(String file)
        {
            WindowsMediaPlayer wmp       = new WindowsMediaPlayerClass();
            IWMPMedia          mediainfo = wmp.newMedia(file);

            return(mediainfo.duration);
        }
        public string Duration(String file)
        {
            WindowsMediaPlayer wmp       = new WindowsMediaPlayerClass();
            IWMPMedia          mediainfo = wmp.newMedia(file);
            int maxTime = Convert.ToInt32(mediainfo.duration);

            return(string.Format("{0:00}:{1:00}:{2:00}", maxTime / 3600, (maxTime / 60) % 60, maxTime % 60));
        }
        public WmpMediaCollection(string mediaType)
        {
            Validator.IsNotNullOrEmpty(mediaType, "mediaType");

            IWMPPlayer player = new WindowsMediaPlayerClass();
            VersionInfo = player.versionInfo;
            Media = GetItems(player, mediaType);
        }
Exemple #7
0
 public Form1()
 {
     player = new WindowsMediaPlayerClass();
     player.OpenStateChange += Player_OpenStateChange;
     database = new DatabaseHandler();
     Songs    = database.readSongs();
     InitializeComponent();
 }
Exemple #8
0
 private void WmpOnMediaChange(object item)
 {
     _Wmp.MediaChange -= WmpOnMediaChange;
     _Wmp.controls.pause();
     _Wmp.controls.currentPosition = 0;
     _Timecode = ((IWMPControls3)_Wmp.controls).currentPositionTimecode;
     _Wmp.close();
     _Wmp = null;
 }
        public VideoFile(string filePath)
        {
            this.filePath = filePath;
            WindowsMediaPlayerClass wmp = new WindowsMediaPlayerClass();

            WMPLib.IWMPMedia media       = wmp.newMedia(filePath);
            TimeSpan         videoLength = TimeSpan.FromSeconds((int)media.duration);

            this.endTime = videoLength;
        }
Exemple #10
0
        private void SaveWMPLibraryData(NHibernate.ISession pDataSession)
        {
            // Hip hip hooray for procedural......
            WindowsMediaPlayerClass WMP     = new WindowsMediaPlayerClass();
            IWMPMediaCollection     mc      = WMP.mediaCollection;
            IWMPStringCollection    strings = mc.getAttributeStringCollection("AlbumID", "audio");

            var albumArtistLookup = new System.Collections.Hashtable();

            int WmpCount = strings.count;

            if (WmpCount > 0)
            {
                for (int i = 0; i < WmpCount; i++)
                {
                    string       item     = strings.Item(i);
                    IWMPPlaylist playlist = mc.getByAttribute("AlbumID", item);
                    playlist.setItemInfo("SortAttribute", "OriginalIndex");
                    int playlistCount = playlist.count;
                    if (playlistCount > 0)
                    {
                        for (int ic = 0; ic < playlistCount; ic++)
                        {
                            IWMPMedia mMedia = playlist.get_Item(ic);

                            string guid        = mMedia.getItemInfo("WM/WMCollectionID");
                            string albumTitle  = mMedia.getItemInfo("WM/AlbumTitle");
                            string albumArtist = mMedia.getItemInfo("WM/AlbumArtist");

                            FileInfo file = new FileInfo(mMedia.sourceURL);

                            //Add to array if not found
                            if (!string.IsNullOrEmpty(guid) && !string.IsNullOrEmpty(albumTitle) &&
                                !albumArtistLookup.ContainsKey(file.DirectoryName))
                            {
                                albumArtistLookup[file.DirectoryName] = true;

                                string filePathLarge = System.IO.Path.Combine(file.DirectoryName, string.Format(WMP_LARGE_GUID, guid));
                                string filePathSmall = System.IO.Path.Combine(file.DirectoryName, string.Format(WMP_SMALL_GUID, guid));

                                if (File.Exists(filePathLarge))
                                {
                                    CreateAndSaveLargeArt(albumArtist, albumTitle, filePathLarge, pDataSession);
                                }
                                if (File.Exists(filePathSmall))
                                {
                                    CreateAndSaveSmallArt(albumArtist, albumTitle, filePathSmall, pDataSession);
                                }
                            }
                        }
                    }
                }
            }
        }
 public static PlayListItem CreateItem(string songName, string path)
 {
     TimeSpan? duration = null;
     if (!string.IsNullOrWhiteSpace(path) && System.IO.File.Exists(path))
     {
         // mozno pouzit TagLib
         WindowsMediaPlayerClass wmpc = new WindowsMediaPlayerClass();
         IWMPMedia newFile = wmpc.newMedia(path);
         duration = TimeSpan.Parse(newFile.durationString.Length > 5 ? newFile.durationString : "00:" + newFile.durationString);
     }
     return new PlayListItem(songName, path, duration);
 }
Exemple #12
0
        private void Form1_Load(object sender, EventArgs e)
        {
            player = new WindowsMediaPlayerClass();
            player.URL = "song.mid";

            audios = new SoundPlayer[5];
            audios[0] = LoadSoundFile("launch1.wav");
            audios[1] = new SoundPlayer();
            audios[1].Stream = Resource1.launch2;
            audios[2] = LoadSoundFile("missed1.wav");
            audios[3] = LoadSoundFile("laser.wav");
            audios[4] = LoadSoundFile("foom.wav");
        }
        public static PlayListItem CreateItem(string songName, string path)
        {
            TimeSpan?duration = null;

            if (!string.IsNullOrWhiteSpace(path) && System.IO.File.Exists(path))
            {
                // mozno pouzit TagLib
                WindowsMediaPlayerClass wmpc = new WindowsMediaPlayerClass();
                IWMPMedia newFile            = wmpc.newMedia(path);
                duration = TimeSpan.Parse(newFile.durationString.Length > 5 ? newFile.durationString : "00:" + newFile.durationString);
            }
            return(new PlayListItem(songName, path, duration));
        }
        public MainGameScreen(MainGame game)
            : base(game)
        {
            this.Player = new WindowsMediaPlayerClass();
            this.Textures = new GameTextures();
            this.mainMapLayer = new MainMapLayer();
            this.architectureLayer = new ArchitectureLayer();
            this.mapVeilLayer = new MapVeilLayer();
            this.troopLayer = new TroopLayer();
            this.selectingLayer = new SelectingLayer();
            this.tileAnimationLayer = new TileAnimationLayer();
            this.routewayLayer = new RoutewayLayer();
            this.Plugins = new GamePlugin();
            this.SelectorTroops = new TroopList();
            this.scrollSpeedScale = 1f;
            this.scrollSpeedScaleDefault = 1f;
            this.scrollSpeedScaleSpeedy = 1.7f;
            this.oldScrollWheelValue = 0;
            this.EnableLaterMouseLeftDownEvent = true;
            this.EnableLaterMouseLeftUpEvent = true;
            this.EnableLaterMouseRightDownEvent = true;
            this.EnableLaterMouseRightUpEvent = true;
            this.EnableLaterMouseMoveEvent = true;
            this.EnableLaterMouseScrollEvent = true;
            this.frameRate = 0;
            this.frameCounter = 0;
            this.elapsedTime = TimeSpan.Zero;
            this.UpdateCount = 0;
            this.thisGame = game;
            this.screenManager = new ScreenManager(this);
            base.Scenario = new GameScenario(this);
            this.LoadCommonData();
            base.Game.Window.ClientSizeChanged += new EventHandler(this.Window_ClientSizeChanged);
            base.Game.Activated += new EventHandler(this.Game_Activated);
            base.Game.Deactivated += new EventHandler(this.Game_Deactivated);
            base.Scenario.OnAfterLoadScenario += new GameScenario.AfterLoadScenario(this.Scenario_OnAfterLoadScenario);
            base.Scenario.OnNewFactionAppear += new GameScenario.NewFactionAppear(this.Scenario_OnNewFactionAppear);
            base.Scenario.Date.OnDayStarting += new GameDate.DayStartingEvent(this.Date_OnDayStarting);
            base.Scenario.Date.OnDayPassed += new GameDate.DayPassedEvent(this.Date_OnDayPassed);
            base.Scenario.Date.OnMonthPassed += new GameDate.MonthPassedEvent(this.Date_OnMonthPassed);
            base.Scenario.Date.OnSeasonChange += new GameDate.SeasonChangeEvent(this.Date_OnSeasonChange);
            base.Scenario.Date.OnYearStarting += new GameDate.YearStartingEvent(this.Date_OnYearStarting);
            base.Scenario.Date.OnYearPassed += new GameDate.YearPassedEvent(this.Date_OnYearPassed);
            //this.Player.add_PlayStateChange(new _WMPOCXEvents_PlayStateChangeEventHandler(this.Player_PlayStateChange));
            this.Player.PlayStateChange+=(new _WMPOCXEvents_PlayStateChangeEventHandler(this.Player_PlayStateChange));
            //this.ShowyoucelanInFrame(UndoneWorkKind.Frame, FrameKind.Architecture, FrameFunction.Jump, false, true, false, false, base.Scenario.CurrentPlayer.Architectures, null, "跳转", "");


        }
Exemple #15
0
 private WMPlayer(string fileName)
 {
     _player = new WindowsMediaPlayerClass();
     _player.mute = true;
     _player.OpenStateChange += new _WMPOCXEvents_OpenStateChangeEventHandler(_player_OpenStateChange);
     //_player.windowlessVideo = true;
     _player.URL = fileName;
     if (!_autoResetEvent.WaitOne(_waitingTime))
         throw new Exception(String.Format("WMPlayer не смог обработать файл {0}",
             fileName));
     //Thread.Sleep(_waitingTime);
     _duration = _player.currentMedia.duration;
     _width = _player.currentMedia.imageSourceWidth;
     _height = _player.currentMedia.imageSourceHeight;
 }
Exemple #16
0
        protected override Id3Tag[] GetTagInfo(Id3Tag tag)
        {
            var windowsMediaPlayer = new WindowsMediaPlayerClass();

            try
            {
                IWMPPlaylist albumContents = windowsMediaPlayer.mediaCollection.getByAlbum(tag.Album.Value);
                IWMPMedia    albumTrack    = null;
                for (int contextIdx = 0; contextIdx < albumContents.count; contextIdx++)
                {
                    string artistContent = albumContents.get_Item(contextIdx).getItemInfo("Artist");
                    if (string.Compare(artistContent, string.Join("/", tag.Artists.Value), StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        albumTrack = albumContents.get_Item(contextIdx);
                        break;
                    }
                }

                if (albumTrack != null)
                {
                    string collectionId = albumTrack.getItemInfo("WM/WMCollectionID");
                    var    largePicture = new PictureFrame();
                    largePicture.SetPicture(
                        Image.FromFile(string.Format("{0}\\AlbumArt_{1}_Large.jpg", Path.GetDirectoryName(albumTrack.sourceURL),
                                                     collectionId)));
                    var smallPicture = new PictureFrame();
                    smallPicture.SetPicture(
                        Image.FromFile(string.Format("{0}\\AlbumArt_{1}_Small.jpg", Path.GetDirectoryName(albumTrack.sourceURL),
                                                     collectionId)));

                    var result = new Id3Tag();
                    result.Pictures.Add(largePicture);
                    result.Pictures.Add(smallPicture);
                    return(new[] { result });
                }

                return(Id3Tag.Empty);
            }
            catch
            {
                return(Id3Tag.Empty);
            }
            finally
            {
                windowsMediaPlayer.close();
            }
        }
        public void Initialize()
        {
            artistDictionary = new Dictionary<string, Artist>();
            WindowsMediaPlayer wmp = new WindowsMediaPlayerClass();
            var items = wmp.mediaCollection.getByAttribute("MediaType", "audio");

            int albumId = 0;
            int artistId = 0;

            for (int i = 0; i < items.count; i++)
            {
                IWMPMedia media = items.get_Item(i);
                string albumArtistName = media.getItemInfo("AlbumArtist").Trim();
                if (albumArtistName == "")
                {
                    albumArtistName = media.getItemInfo("Artist").Trim();
                    if(albumArtistName == "")
                        albumArtistName = "Unknown";
                }
                string albumName = media.getItemInfo("Album").Trim();
                if (albumName == "")
                    albumName = "Unknown";
                string trackName = media.getItemInfo("Title").Trim();
                if (trackName == "")
                    trackName = "Unknown"+i;
                string trackLocation = media.getItemInfo("SourceUrl");
                string trackNumberString = media.getItemInfo("OriginalIndex");
                uint trackNumber = 0;
                var duration = TimeSpan.FromSeconds(media.duration);
                UInt32.TryParse(trackNumberString, out trackNumber);

                Artist artist;

                if (!artistDictionary.TryGetValue(albumArtistName, out artist))
                {
                    artist = new Artist("artist"+artistId++, albumArtistName);
                    artistDictionary.Add(albumArtistName, artist);
                }

                Album album = (Album)artist.Albums.FirstOrDefault(al => al.Name == albumName);
                if(album == null)
                    album = artist.AddAlbum("album"+albumId++, albumName);

                Song song = new Song(trackName, album, artist, trackLocation, trackNumber, i.ToString(), duration);
                album.AddSong(song);
            }
        }
Exemple #18
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            if (_totalDuration > 0)
            {
                return;
            }
            _totalDuration = 0;
            if (_filesList == null || _filesList.Count <= 0)
            {
                return;
            }
            _totalDuration = 0;
            int progress = 0;

            try
            {
                foreach (string file in _filesList)
                {
                    progress++;
                    if (_backgroundWorker1.CancellationPending)
                    {
                        _totalDuration = 0;
                        break;
                    }
                    else
                    {
                        this.UpdateForm(progress, file.Replace(_path, ""), progress + "/" + _filesList.Count);
                        if (StringContainsCorrectExtension(file, _videoExtensions) ||
                            StringContainsCorrectExtension(file, _audioExtensions))
                        {
                            WindowsMediaPlayer wmp       = new WindowsMediaPlayerClass();
                            IWMPMedia          mediainfo = wmp.newMedia(file);
                            _totalDuration += Convert.ToInt64(mediainfo.duration);
                        }
                    }
                }
            }
            catch (Exception)
            {
                _totalDuration = 0;
                // fileslist changed while looping through it
            }
        }
Exemple #19
0
        public static void Main(string[] args)
        {
/*
 *                      BinaryReader br = new BinaryReader(File.OpenRead("Conquest_of_Paradise.mid"));
 *                      Midi_Header_C m = new Program.Midi_Header_C();
 *                      Midi_Track_C t = new Program.Midi_Track_C();
 *                      m.Midi_Header_gs = br.ReadBytes(4);
 *                      m.Header_Length_gs = br.ReadBytes(4);
 *                      m.Midi_Format_gs = br.ReadBytes(2);
 *                      m.Number_Track_Chunks_gs = br.ReadBytes(2);
 *                      m.Timing_Unit_gs = br.ReadBytes(2);
 *
 *                      t.Track_Header_gs = br.ReadBytes(4);
 *                      t.Track_Length_gs = br.ReadBytes(4);
 *                      t.Midi_Event_gs = br.ReadBytes(4);
 */
            WindowsMediaPlayer WMP = new WindowsMediaPlayerClass();

            WMP.openPlayer("Conquest_of_Paradise.mid");

            /*
             * Console.WriteLine("Header: " + Bytes2String(m.Midi_Header_gs));
             * Console.WriteLine("Header length: " + ByteArray2Int(m.Header_Length_gs));
             * Console.WriteLine("Midi format: " + ByteArray2Int(m.Midi_Format_gs));
             * Console.WriteLine("n Chunks: " + ByteArray2Int(m.Number_Track_Chunks_gs));
             * Console.WriteLine("Timing unit: " + Midi_Tick_Format(m.Timing_Unit_gs));
             * Console.WriteLine();
             * Console.WriteLine("Track Header: " + Bytes2String(t.Track_Header_gs));
             * Console.WriteLine("Track length: " + ByteArray2Int(t.Track_Length_gs));
             * Console.WriteLine("Midi Event: " + Detect_Midi_Event(t.Midi_Event_gs));
             */
            //Console.WriteLine("n Tracks: " + C.ToString());



            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    protected void upload_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["ids"] == null)
        {
            if (title.Text != "")
            {
                if (Image1.ImageUrl != "~/video_img/index.PNG")
                {
                    if (category.SelectedIndex != 0)
                    {
                        if (tags.Text != "")
                        {
                            System.Threading.Thread.Sleep(3000);

                            cn.Open();
                            var player = new WindowsMediaPlayerClass();
                            var clip   = player.newMedia(Server.MapPath("~/videos/" + Session["file"]));
                            int a      = clip.imageSourceWidth;
                            d1 = clip.durationString;

                            SqlCommand cmd = cn.CreateCommand();
                            cmd.CommandType = CommandType.Text;

                            cmd.CommandText = "select *from user_registration where username='******' ";
                            cmd.ExecuteScalar();
                            DataSet        ds = new DataSet();
                            SqlDataAdapter da = new SqlDataAdapter(cmd);
                            da.Fill(ds);

                            string id = ds.Tables[0].Rows[0]["user_id"].ToString();
                            string nm = ds.Tables[0].Rows[0]["name"].ToString();

                            SqlCommand cmd1 = new SqlCommand("insert into videos(user_id,user_name,title,link,description,duration,likes,dislikes,views,img,publish_date,category,tags) values('" + id + "','" + nm + "','" + title.Text + "','" + video_path + "','" + description.Text + "','" + d1 + "','" + 0 + "','" + 0 + "','" + 0 + "','" + img_path + "','" + DateTime.Today.ToString("dd-MM-yyyy") + "','" + category.SelectedItem + "','" + tags.Text + "')", cn);
                            cmd1.ExecuteNonQuery();
                            cn.Close();
                            Response.Redirect("User_home.aspx");
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        lblmsg.Text = "";
                        lblmsg.Text = "Please select Category";
                    }
                }
                else
                {
                    Label1.Text = "Please select image";
                }
            }
        }
        else
        {
            if (Image1.ImageUrl != "~/video_img/index.PNG")
            {
                if (Image1.ImageUrl != null)
                {
                    cn.Open();
                    SqlCommand cmd = new SqlCommand("update videos set title='" + title.Text + "',description='" + description.Text + "',img='" + img_path + "',category='" + category.SelectedItem + "',tags='" + tags.Text + "' where id='" + Request.QueryString["ids"] + "'", cn);
                    cmd.ExecuteNonQuery();
                    cn.Close();
                    Response.Redirect("User_home.aspx");
                }
                else
                {
                    cn.Open();
                    SqlCommand cmd = new SqlCommand("update videos set title='" + title.Text + "',description='" + description.Text + "',category='" + category.SelectedItem + "',tags='" + tags.Text + "' where id='" + Request.QueryString["ids"] + "'", cn);
                    cmd.ExecuteNonQuery();
                    cn.Close();
                    Response.Redirect("User_home.aspx");
                }
            }
            else
            {
                Label1.Text = "Please select image";
            }
        }
    }
 public WindowsMediaFormatsFileDurationDetector()
 {
     _wmp = new WindowsMediaPlayerClass();
 }
Exemple #22
0
 public static int Duration(string file)
 {
     WindowsMediaPlayer wmp = new WindowsMediaPlayerClass();
     IWMPMedia mediainfo = wmp.newMedia(file);
     return (int)mediainfo.duration;
 }
Exemple #23
0
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_autoResetEvent != null)
         {
             _autoResetEvent.Close();
             _autoResetEvent = null;
         }
     }
     if (_player != null)
     {
         _player.close();
         _player = null;
     }
 }