Пример #1
0
        public void open(string location)
        {
            try
            {
                log.Info("Opening: " + location);

                close();
                //videoDebug.clear();

                videoDecoder.open(location, decodedVideoFormat);
                //videoRender.initialize(videoDecoder.Width, videoDecoder.Height);

                DurationSeconds = videoDecoder.DurationSeconds;
                HasAudio        = videoDecoder.HasAudio;

                if (videoDecoder.HasAudio)
                {
                    audioPlayer.initialize(videoDecoder.SamplesPerSecond, videoDecoder.BytesPerSample,
                                           videoDecoder.NrChannels, videoDecoder.MaxAudioFrameSize * 2);

                    audioDiffThreshold = 2.0 * 1024 / videoDecoder.SamplesPerSecond;
                }

                //videoDebug.VideoQueueMaxSize = videoDecoder.FrameQueue.MaxVideoPackets;
                //videoDebug.VideoQueueSizeBytes = videoDecoder.FrameQueue.VideoQueueSizeBytes;
                //videoDebug.AudioQueueMaxSize = videoDecoder.FrameQueue.MaxAudioPackets;
                //videoDebug.AudioQueueSizeBytes = videoDecoder.FrameQueue.AudioQueueSizeBytes;

                if (syncMode == SyncMode.AUDIO_SYNCS_TO_VIDEO)
                {
                    //videoDebug.IsVideoSyncMaster = true;
                }
                else
                {
                    //videoDebug.IsAudioSyncMaster = true;
                }

                VideoState = VideoState.OPEN;

                if (VideoOpened != null)
                {
                    VideoOpened(this, EventArgs.Empty);
                }
            }
            catch (VideoLib.VideoLibException e)
            {
                VideoState = VideoState.CLOSED;

                log.Error("Cannot open: " + location, e);

                MessageBox.Show("Cannot open: " + location + "\n\n" +
                                e.Message, "Video Error");
            }
        }