Пример #1
0
        async void MSS_Starting(Windows.Media.Core.MediaStreamSource sender, MediaStreamSourceStartingEventArgs args)
        {
            MediaStreamSourceStartingRequest request = args.Request;

            if ((request.StartPosition != null) && request.StartPosition.Value <= MSS.Duration)
            {
                UInt64 sampleOffset = (UInt64)request.StartPosition.Value.Ticks / (UInt64)sampleDuration.Ticks;
                timeOffset = new TimeSpan((long)sampleOffset * sampleDuration.Ticks);
                byteOffset = sampleOffset * sampleSize;
            }

            // create the RandomAccessStream for the input file for the first time

            if (mssStream == null)
            {
                MediaStreamSourceStartingRequestDeferral deferal = request.GetDeferral();
                try
                {
                    mssStream = await inputMP3File.OpenAsync(FileAccessMode.Read);

                    request.SetActualStartPosition(timeOffset);
                    deferal.Complete();
                }
                catch (Exception)
                {
                    MSS.NotifyError(MediaStreamSourceErrorStatus.FailedToOpenFile);
                    deferal.Complete();
                }
            }
            else
            {
                request.SetActualStartPosition(timeOffset);
            }
        }
        public void Start(MediaStreamSourceStartingRequest request)
        {
            lock ( m_lock )
            {
                Debug.Assert(m_state == State.Created);

                m_startRequest           = request;
                m_startRequestCompletion = request.GetDeferral();
                m_state = State.Started;
                m_session.StartCapture();
            }
        }
Пример #3
0
        void mkvStreamSource_Starting(MediaStreamSource sender, MediaStreamSourceStartingEventArgs args)
        {
            MediaStreamSourceStartingRequest request = args.Request;

            if (request.StartPosition.HasValue && sender.CanSeek)
            {
                var deferal = request.GetDeferral();
                var mkvFs   = mediaStreamFileSource as CCPlayer.HWCodecs.Matroska.MKV.MKVFileSource;
                if (mkvFs != null)
                {
                    var newTime = mkvFs.Seek((ulong)request.StartPosition.Value.Ticks / 10000);
                    request.SetActualStartPosition(newTime);
                }

                deferal.Complete();
            }
        }
Пример #4
0
        private void flvStreamSource_Starting(MediaStreamSource sender, MediaStreamSourceStartingEventArgs args)
        {
            MediaStreamSourceStartingRequest request = args.Request;

            if (request.StartPosition.HasValue && sender.CanSeek)
            {
                var deferal = request.GetDeferral();
                var flvFile = mediaStreamFileSource as FlvFile;

                if (flvFile != null)
                {
                    var newTime = SeekForFlv(flvFile, (long)(request.StartPosition.Value.TotalMilliseconds * 10000));
                    request.SetActualStartPosition(TimeSpan.FromTicks(newTime));
                }

                deferal.Complete();
            }
        }