예제 #1
0
        private NetStreamHelper NewNetStreamHelper(MediaItem item)
        {
            NetStreamHelper nth = null;
            if (netConnection != null && netConnection.IsConnected)
            {
                nth = new NetStreamHelper();
                nth.NetStream = new NetStream(netConnection, false);
                nth.NetStream.OnAssignStream_ID += new NS_OnAssignStream_ID(NS_OnAssignStream_ID);

                nth.Item = item;
                nth.Buffer = new CircularBlockBuffer(Convert.ToInt32(((128 * 1024) / 8) * 30)); // 30 seconden buffer voor 128kbit mp3 stream (= 480kb)
                // renumber
                for (int i = 0; i < netStreams.Count; i++)
                {
                    netStreams[i].IndexNumberInList = i;
                } //for
                nth.IndexNumberInList = netStreams.Count;
            }

            return nth;
        }
예제 #2
0
        private long GetPositionByte(NetStreamHelper nsh)
        {
            if (nsh != null)
            {
                long position = Bass.BASS_ChannelGetPosition(nsh.BassHandle);
                // calculate delta
                if (nsh.NetStream.DeltaTimeStampInMS != 0)
                {
                    position += Convert.ToInt64((nsh.NetStream.DeltaTimeStampInMS / 1000) * nsh.SampleRate * nsh.Channels * (nsh.SampleSize / 8));
                }

                // make it relative to the "song" we are playing
                return position;
            }

            return -1;
        }
예제 #3
0
 /// <summary>
 /// Close NetStream object (is allready removed from "netStreams"
 /// </summary>
 /// <param name="nsh"></param>
 private void CloseAudioStream(NetStreamHelper nsh)
 {
     nsh.NetStream.Close();
     nsh.NetStream = null;
     nsh.Buffer = null;
 }