private void Player_DataReceived(object sender, DataReceivedInfo args) { if (IsMastStream(args.StreamAttributes)) { try { var dataAsString = System.Text.Encoding.UTF8.GetString(args.Data, 0, args.Data.Length); base.LoadMastDoc(dataAsString); } catch (Exception error) { ReleasePlayer(); string logMessage = string.Format(MastMarkerProviderResources.DownloadFailedLogMessage, error.Message); SendLogEntry(LogEntryTypes.DownloadFailed, LogLevel.Warning, logMessage); OnRetrieveMarkersFailed(error); } } }
private void Player_DataReceived(object sender, DataReceivedInfo e) { if (IsCaptionStream(e.StreamAttributes)) { try { var stream = new MemoryStream(e.Data); var text = new StreamReader(stream).ReadToEnd(); var duration = e.DataChunk.Duration != TimeSpan.Zero ? e.DataChunk.Duration : TimeSpan.FromMilliseconds(2002); if (_captionRegion.Begin == TimeSpan.MinValue || _captionRegion.Begin > e.DataChunk.Timestamp) { _captionRegion.Begin = e.DataChunk.Timestamp; } #if SILVERLIGHT3 if (!SystemExtensions.IsNullOrWhiteSpace(text)) #else if (!string.IsNullOrWhiteSpace(text)) #endif { var caption = new CaptionElement { Content = text, Begin = e.DataChunk.Timestamp, End = e.DataChunk.Timestamp.Add(duration) }; _captionRegion.Children.Add(caption); } } catch (Exception err) { Debug.WriteLine(err.Message); } } }
private void Player_DataReceived(object sender, DataReceivedInfo args) { if (IsCaptionStream(args.StreamAttributes)) { var player = (SMFPlayer)sender; var workload = new WorkLoad() { data = args.Data, timeOffset = player.CalculateRelativeMediaPosition(args.DataChunk.Timestamp), //Added a workaround for an issue w/ the SSME that causes the //duration data to be empty. In this case we'll default to 2 seconds //TODO: Remove this once the issue has been fix in the SSME. endTime = args.DataChunk.Timestamp.Add(args.DataChunk.Duration != TimeSpan.Zero ? args.DataChunk.Duration : TimeSpan.FromMilliseconds(2002)) }; workerQueue.Enqueue(workload); if (workerQueue.Count == 1) { RunWorkLoad(workload); } } }