private void MediaPlugin_DownloadStreamDataCompleted(IAdaptiveMediaPlugin mediaPlugin, IMediaTrack track,
                                                      IStreamDownloadResult result)
 {
     //Dispatcher.BeginInvoke(() => OnDownloadStreamDataCompleted(mediaPlugin, track, result));
     OnDownloadStreamDataCompleted(mediaPlugin, track, result);
 }
Beispiel #2
0
        private void OnDownloadStreamDataCompleted(IAdaptiveMediaPlugin mediaPlugin, IMediaTrack track, IStreamDownloadResult result)
        {
            try
            {
                if (result != null && result.Stream != null)
                {
                    var data = new byte[result.Stream.Length];
                    result.Stream.Read(data, 0, data.Length);
                    result.Stream.Flush();

                    this.ParseTimelineEvent(data);
                }
            }
            catch (Exception ex)
            {
            }
        }
        protected virtual void OnDownloadStreamDataCompleted(IAdaptiveMediaPlugin mediaPlugin, IMediaTrack track,
                                                             IStreamDownloadResult result)
        {
            try
            {
                if (DataReceived != null)
                {
                    int length = (int)result.Stream.Length;
                    var data = new byte[length];
                    int count;
                    int sum = 0;

                    do
                    {
                        count = result.Stream.Read(data, sum, length - sum);
                        sum += count;
                    } while (count > 0 && sum < length);

                    DataReceived(this, new DataReceivedInfo(data, result.DataChunk, track.ParentStream.Attributes));
                    SendLogEntry(KnownLogEntryTypes.DataReceived);
                }
            }
            catch (Exception err)
            {
                string message = string.Format(SilverlightMediaFrameworkResources.GenericErrorOccurredLogMessage,
                                               "OnDownloadStreamDataCompleted", err.Message);
                SendLogEntry(KnownLogEntryTypes.DownloadStreamDataCompleted, LogLevel.Error, message);
            }
        }