private void playByTime(DateTime time) { try { onCache(noAnyValidFrameStream(time)); updateHaveDataFromTimePeriods(time); while (!_disposeEvent.WaitOne(0)) { while (needToNextPacket(time) && _cache.Count() > 0) { _videoPacket = _cache.DequeuePacket(); //Console.WriteLine("{0} \t {1}\t{2}", _guid.ToString(), _videoPacket.TimePeriod.BeginTime.TimeOfDay, _videoPacket.TimePeriod.EndTime.TimeOfDay); _packetIndex = 0; } if (_videoPacket == null) { return; } int index = _packetIndex; if (_packetIndex < _videoPacket.VideoStreams.Length) { var stream = _videoPacket.VideoStreams.ElementAt(_packetIndex); if (stream.Time <= time) { lock (_obj) { if (_decoder != null) { _decoder.Update(stream); _packetIndex++; //if (_decoder.Update(stream)) // _packetIndex++; //else // Console.WriteLine("缓冲区已满,需要重复送入数据!"); } } //Console.WriteLine("Stream: {0} \t{1}\t{2}", stream.Time.TimeOfDay, stream.Type, stream.Buffer.Length); } else { return; } } if (index == _packetIndex) { Thread.Sleep(1); } } } catch (Exception ex) { Console.WriteLine("playByTime error! \n" + ex.ToString()); } }