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);
        }
Exemple #3
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 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;
        }
 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 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 #8
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 #9
0
 public static int Duration(string file)
 {
     WindowsMediaPlayer wmp = new WindowsMediaPlayerClass();
     IWMPMedia mediainfo = wmp.newMedia(file);
     return (int)mediainfo.duration;
 }
        public double GetDurationInSeconds(string path)
        {
            IWMPMedia mediaInfo = _wmp.newMedia(path);

            return(Math.Round(mediaInfo.duration, 2));
        }
    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";
            }
        }
    }