Ejemplo n.º 1
0
        private void Update(object sender, EventArgs e)
        {
            TimeSpan    ts, ts2;
            TStreamTime pos  = new TStreamTime();
            TStreamInfo info = new TStreamInfo();
            TStreamTime time = new TStreamTime();

            player2.GetPosition(ref pos);
            player2.GetStreamInfo(ref info);
            time = info.Length;
            ts   = TimeSpan.FromSeconds(Convert.ToDouble(pos.sec.ToString()));
            ts2  = TimeSpan.FromSeconds(Convert.ToDouble(time.sec.ToString()));

            if (Convert.ToInt32(time.sec) > 0)
            {
                if (Convert.ToInt32(time.sec) - Convert.ToInt32(pos.sec) <= 0)
                {
                    frm1.Invoke((MethodInvoker) delegate
                    {
                        frm1.Forward();
                    });
                }
                Form1.ChangeNameLabel(ts + "/" + ts2);
                Form1.ChangePositionBar(Convert.ToInt32(pos.sec) * 100 / Convert.ToInt32(time.sec));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 循环播放当前配置文件中的音频文件,告警信息时候调用
        /// </summary>
        public void Play()
        {
            try
            {
                string source  = string.Empty;
                bool   enabled = false;
                VoiceXmlHelper.ReadFromXML(out source, out enabled);

                if (File.Exists(source) && enabled)
                {
                    m_currentPlayer.OpenFile(source, TStreamFormat.sfAutodetect);
                    // 循环播放
                    TStreamInfo info = new TStreamInfo();
                    m_currentPlayer.GetStreamInfo(ref info);

                    TStreamTime time = new TStreamTime();
                    time.sec = 0;
                    TStreamTime timeEnd = new TStreamTime();
                    timeEnd.sec = info.Length.sec;
                    m_currentPlayer.PlayLoop(TTimeFormat.tfSecond, ref time, TTimeFormat.tfSecond, ref timeEnd, Int32.MaxValue, true);
                    m_bIsCurrentFromWarningInfo = true;
                    //Play(source);
                }
            }
            catch (Exception exp)
            {
                System.Diagnostics.Debug.WriteLine(exp.Message);
            }
            finally
            {
            }
        }
Ejemplo n.º 3
0
        //void ChkWavestMouseWheel(object sender, MouseEventArgs e)
        //{
        //System.Diagnostics.Debug.WriteLine(chkWaves.TopIndex);
        //System.Diagnostics.Debug.WriteLine(chkWaves.);
        //	Text1MouseWheel(this.textBox1, e);
        //}

        //void Text1MouseWheel(object sender, MouseEventArgs e)
        //{
        //	int pos = textBox1.GetCharIndexFromPosition(e.Location);
        //	int line = textBox1.GetLineFromCharIndex(pos);
        //	System.Diagnostics.Debug.WriteLine(line);
        //}

        void ChkWavesSelectedIndexChanged(object sender, EventArgs e)
        {
            if (chkWaves.SelectedIndex == -1)
            {
                return;
            }
            gPlayer.StopPlayback();
            gPlayer.Close();

            String selFile = chkWaves.SelectedItem.ToString();

            String folder = cmbQisquchlar.SelectedItem.ToString();
            string yol    = Path.Combine(gAwazyol, folder, selFile);

            gInfo = new TStreamInfo();
            gPlayer.OpenFile(yol, TStreamFormat.sfAutodetect);
            gPlayer.GetStreamInfo(ref gInfo);
            label2.Text = string.Format("Uzunluqi : {0} millisecond", gInfo.Length.ms);

            int qur = chkWaves.SelectedIndex;

            textBox1.Focus();
            int qurUzun = 0;

            if (qur < textBox1.Lines.Length)
            {
                qurUzun = textBox1.GetFirstCharIndexFromLine(qur);
            }
            textBox1.SelectionLength = 0;
            textBox1.SelectionStart  = qurUzun;
            textBox1.ScrollToCaret();
        }
Ejemplo n.º 4
0
        private TStreamInfo GetStreamInfo(ref ZPlay player)
        {
            TStreamInfo streamInfo = new TStreamInfo();

            player?.GetStreamInfo(ref streamInfo);

            return(streamInfo);
        }
Ejemplo n.º 5
0
		/// <summary>
		/// Show info
		/// </summary>
		/// <remarks></remarks>
        public void showinfo()
        {
           
            Label3.Text = "";
            Label4.Text = "";
            Label5.Text = "";
            Label6.Text = "";
            Label7.Text = "";
            Label8.Text = "";
            Label9.Text = "";

            TID3InfoEx info = new TID3InfoEx();
            if (player.LoadID3Ex(ref info, true))
            {
                 Label3.Text = info.Title;
                Label4.Text = info.Artist;
                Label5.Text = info.Album;
                Label6.Text = info.Year;
                Label7.Text = info.Track;
                Label8.Text = info.Encoder;
                Label9.Text = info.Comment;

            }


            descr.Text = "Format:" + System.Environment.NewLine + "Length:" + System.Environment.NewLine + "Samplerate:" + System.Environment.NewLine + "Bitrate:" + System.Environment.NewLine + "Channel:" + System.Environment.NewLine + "VBR:";

            TStreamInfo StreamInfo = new TStreamInfo();
            player.GetStreamInfo(ref StreamInfo);
            descr1.Text = StreamInfo.Description + System.Environment.NewLine + System.Convert.ToString(StreamInfo.Length.hms.hour) + " : " + System.Convert.ToString(StreamInfo.Length.hms.minute) + " : " + System.Convert.ToString(StreamInfo.Length.hms.second) + System.Environment.NewLine + System.Convert.ToString(StreamInfo.SamplingRate) + " Hz" + System.Environment.NewLine + System.Convert.ToString(StreamInfo.Bitrate) + " kbps" + System.Environment.NewLine + System.Convert.ToString(StreamInfo.ChannelNumber) + System.Environment.NewLine + System.Convert.ToString(StreamInfo.VBR);

            if (info.Picture.PicturePresent)
                pictureBox2.Image = info.Picture.Bitmap;

            ProgressBar1.Minimum = 0;
            ProgressBar1.Maximum = System.Convert.ToInt32((int)(StreamInfo.Length.sec));
            ProgressBar1.Value = 0;
            
            Timer1.Enabled = true;
            Timer2.Enabled = true;

          
        }
Ejemplo n.º 6
0
        private void _loadImformation(string filename)
        {
            IsEmpty = true;
            if (filename == string.Empty)
            {
                return;
            }
            FilePath = filename;
            #region 获取文件信息
            #region 设置文件时间
            ZPlay tempPlay = new ZPlay();
            //如果文件不存在,则退出构造..
            bool bret = tempPlay.OpenFile(filename, TStreamFormat.sfAutodetect);
            if (!bret)
            {
                return;
            }
            TStreamInfo streamInfo = new TStreamInfo();
            tempPlay.GetStreamInfo(ref streamInfo);
            Length  = streamInfo.Length;
            Minutes = streamInfo.Length.sec / 60;
            Seconds = streamInfo.Length.sec % 60;

            tempPlay.Close();
            #endregion
            #region 获取歌曲名
            string musicName = filename.Substring(filename.LastIndexOf('\\') + 1);
            MusicName = musicName.Substring(0, musicName.LastIndexOf('.'));
            #endregion
            #region 设置文件格式
            string format = filename.Substring(filename.LastIndexOf('.'));
            switch (format.ToLower())
            {
            case ".wav":
                Format = TStreamFormat.sfWav;
                break;

            case ".mp3":
                Format = TStreamFormat.sfMp3;
                break;

            case ".flac":
                Format = TStreamFormat.sfFLAC;
                break;

            default:
                Format = TStreamFormat.sfAutodetect;
                break;
            }
            #endregion
            IsEmpty = false;

            #endregion
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Playing test.mp3. Press Q to quit.\n");
            // create ZPlay class
            ZPlay player = new ZPlay();

            // open file
            if (player.AddFile("1.mp3", TStreamFormat.sfAutodetect) == false)
            {
                Console.WriteLine(player.GetError());
                return;
            }


            // get song length
            TStreamInfo info = new TStreamInfo();

            player.GetStreamInfo(ref info);
            Console.WriteLine("Length: {0:G}:{1:G}:{2:G}:{3:G}",
                              info.Length.hms.hour,
                              info.Length.hms.minute,
                              info.Length.hms.second,
                              info.Length.hms.millisecond);

            // start playing
            player.StartPlayback();

            TStreamStatus status = new TStreamStatus();
            TStreamTime   time   = new TStreamTime();

            status.fPlay = true;

            while (status.fPlay)
            {
                player.GetPosition(ref time);
                Console.Write("Pos: {0:G}:{1:G}:{2:G}:{3:G}\r",
                              time.hms.hour,
                              time.hms.minute,
                              time.hms.second,
                              time.hms.millisecond);
                player.GetStatus(ref status);
                System.Threading.Thread.Sleep(50);
                if (Console.KeyAvailable)
                {
                    var cki = Console.ReadKey(true);
                    if (cki.Key == ConsoleKey.Q)
                    {
                        player.StopPlayback();
                    }
                }
            }
        }