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 (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);
                }
            }
        }