示例#1
0
        private void timeLrcTime_Tick(object sender, EventArgs e)
        {
            if (lrcanalysis != null)
            {
                //lblLrcText.Text=lrcanalysis.getLrcInfo(wmpPlay.currentMedia.
                //lblLrcText.Text = "ss:" + wmpPlay.currentMedia.duration.ToString();获取总时间秒
                //lblLrcText.Text=wmpPlay.Ctlcontrols.currentPosition.ToString();获取当前进度
                long    temp = 0;
                LrcInfo info = lrcanalysis.getLrcInfo((long)(wmpPlay.Ctlcontrols.currentPosition * 1000), out temp);
                if (info != null)
                {
                    lblLrcText.Text = info.Lrcstr;
                    lbl_trim.Text   = (temp / 1000).ToString();
                    if (!lrc_temp.Equals(info.Lrcstr))
                    {
                        lrc_temp = info.Lrcstr;
                        tmp_i    = 0;
                        //dll动态链接库歌词程序
                        byte[] tempStr = Encoding.Default.GetBytes(info.Lrcstr);
                        byte[] tempDef = Encoding.Convert(Encoding.Default, Encoding.Unicode, tempStr);
                        //String lrcstr = Encoding.Unicode.GetString(tempDef);

                        lrc_fun.LoadFun("DrawLRC_SHOW_TEXT");
                        object[]   Parameters     = new object[] { (byte[])tempDef };
                        Type[]     ParameterTypes = new Type[] { typeof(byte[]) };
                        ModePass[] themode        = new ModePass[] { ModePass.ByValue };
                        Type       Type_Return    = typeof(void);
                        lrc_fun.Invoke(Parameters, ParameterTypes, themode, Type_Return);
                        lrc_fun.LoadFun("SetDrawLRCTime");
                        Parameters     = new object[] { (long)(temp / 1000) };
                        ParameterTypes = new Type[] { typeof(long) };
                        themode        = new ModePass[] { ModePass.ByValue };
                        lrc_fun.Invoke(Parameters, ParameterTypes, themode, Type_Return);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// 通过时间返回歌词信息,如果没有时间段就返回null
        /// </summary>
        /// <param name="time">歌词时间</param>
        /// <param name="TotalTime">歌词长度时间,如果为-1就是最后一行歌词</param>
        /// <returns>歌词信息</returns>
        public LrcInfo getLrcInfo(long time, out long TotalTime)
        {
            LrcInfo tempinfo = new LrcInfo();

            tempinfo.Time   = time;
            tempinfo.Lrcstr = "";
            int index = list.FindIndex(delegate(LrcInfo lrc) { return(lrc.Equals(tempinfo)); });

            //if (index == -1) {
            //    TotalTime = -1;
            //    return null;
            //}
            //LrcInfo info = list[index];
            //if (list.Count <= index + 1)
            //{
            //    TotalTime = -1;
            //}
            //else {
            //    TotalTime = list[index + 1].Time - info.Time;
            //}
            if (index - 1 < 0)
            {
                TotalTime = -1;
                return(null);
            }
            LrcInfo info = list[index - 1];

            if (index < 0)
            {
                TotalTime = -1;
            }
            else
            {
                TotalTime = list[index].Time - info.Time;
            }
            return(info);
        }