//Texture productTexture; protected override void OnAttach() { base.OnAttach(); //create window window = ControlDeclarationManager.Instance.CreateControl("Gui\\ProductLogoWindow.gui"); Controls.Add(window); //productTexture = TextureManager.Instance.Load("Gui\\Various\\AKLogoNew.png", Texture.Type.Type2D); VideoBox videoBox = window.Controls["VideoBox"] as VideoBox; if (string.IsNullOrEmpty(videoBox.FileName) || videoBox.IsEndOfFile()) { if (string.IsNullOrEmpty(videoBox.FileName)) { videoBox.FileName = "Gui\\Various\\akvideo2.ogv"; } if (videoBox.IsEndOfFile()) { videoBox.Rewind(); } } else { videoBox.FileName = ""; } EngineApp.Instance.MouseRelativeMode = true; SoundWorld.Instance.SetListener(new Vec3(1000, 1000, 1000), Vec3.Zero, new Vec3(1, 0, 0), new Vec3(0, 0, 1)); ResetTime(); }
private async void TryToUseFFmpegURI() { try { // Set FFmpeg specific options. List of options can be found in https://www.ffmpeg.org/ffmpeg-protocols.html // Below are some sample options that you can set to configure RTSP streaming // Config.FFmpegOptions.Add("rtsp_flags", "prefer_tcp"); // Config.FFmpegOptions.Add("stimeout", 100000); // Instantiate FFmpegInteropMSS using the URI VideoBox.Stop(); ffmpegMss = await FFmpegInteropMSS.CreateFromUriAsync(inputURI); var source = ffmpegMss.CreateMediaPlaybackItem(); // Pass MediaStreamSource to Media Element VideoBox.SetPlaybackSource(source); } catch (Exception ex) { ShowDialog.DisplayErrorMessage(ex.Message); } //try //{ // // Set FFmpeg specific options. List of options can be found in https://www.ffmpeg.org/ffmpeg-protocols.html // PropertySet options = new PropertySet(); // // Below are some sample options that you can set to configure RTSP streaming // // options.Add("rtsp_flags", "prefer_tcp"); // // options.Add("stimeout", 100000); // // Instantiate FFmpegInteropMSS using the URI // ffmpegMss = await FFmpegInteropMSS.CreateFromUriAsync(inputURI); // if (ffmpegMss != null) // { // MediaStreamSource mss = ffmpegMss.GetMediaStreamSource(); // if (mss != null) // { // // Pass MediaStreamSource to Media Element // VideoBox.Source = MediaSource.CreateFromMediaStreamSource(mss); // } // else // { // ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen); // } // } // else // { // ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen); // } //} //catch (Exception ex) //{ // ShowDialog.DisplayErrorMessage(ex.Message); //} }
/// <summary> /// 初始化点监控图像 /// </summary> private void InitPointVodes() { int count = this.pointVideoCount / this.pointVideoRows; int width = (this.Size.Width / count) + ((this.Size.Width % count) == 0?0:1) - count * this.xSpace; int heigth = ((this.Size.Height / 2) / this.pointVideoRows) - this.pointVideoRows * this.ySpace; int x = 1; int y = this.Height / this.pointVideoRows + 5; int index = 0; for (int row = 0; row < this.pointVideoRows; row++) { for (int idx = 0; idx < count; idx++) { if (idx == 0) { x = 1; } else { x += width + xSpace; } VideoBox vbx = new VideoBox { Location = new Point(x, y), Width = width, Height = heigth, Index = index++, Margin = new Padding(0, 0, 0, 0) }; // this.LoadImage(vbx, "test.bmp"); this.pointVideos.Add(vbx); } y += heigth + this.ySpace; } this.Controls.AddRange(this.pointVideos.ToArray()); }
private void TryToLoadAndPlay(string uri) { inputURI = uri; VideoBox.SetPlaybackSource(MediaSource.CreateFromUri(new Uri(inputURI))); VideoBox.Play(); //VideoBox.MediaPlayer.MediaFailed += URIMediaFailed; }
/// <summary> /// 云台控制 /// </summary> /// <param name="boxHandle">图像</param> /// <param name="type">控制类型</param> /// <param name="speed">速度</param> /// <param name="startOrStop">速度</param> public void CameraContol(VideoBox vbx, ControlType type, uint speed, uint startOrStop) { var video = Videos.Where(c => c == vbx); if (video.Count() == 0 || video.First().Camera == null) { return; } video.First().Camera.CameraContol(type, startOrStop, speed); }
private async void picker_Click(object sender, RoutedEventArgs e) { inputFile = await OpenFile.LoadFileAsync(); if (inputFile != null) { VideoBox.SetPlaybackSource(MediaSource.CreateFromStorageFile(inputFile)); //VideoBox.MediaPlayer.RealTimePlayback = true; VideoBox.Play(); //VideoBox.MediaPlayer.MediaFailed += LocalMediaFailed; } }
void highlightBlobs(Bitmap image) { VideoBox.BackgroundImage = image; VideoBox.crossThreadOperation(() => VideoBox.Image = new Bitmap(image.Width, image.Height)); Graphics gr = Graphics.FromImage(VideoBox.Image); foreach (var blobKeeper in blobKeepers) { blobKeeper.Draw(gr, highlightFormat); } VideoBox.crossThreadOperation(() => Refresh()); }
private async void TryToLoadAndPlay(StorageFile file) { inputFile = file; var stream = await inputFile.OpenAsync(FileAccessMode.Read); VideoBox.SetPlaybackSource(MediaSource.CreateFromStorageFile(inputFile)); VideoBox.Play(); //VideoBox.MediaPlayer.RealTimePlayback = true; //VideoBox.MediaPlayer.Play(); MediaTitleBlock.Text = inputFile.DisplayName; //VideoBox.MediaPlayer.MediaFailed += LocalMediaFailed; }
private void StartButton_Click(object sender, EventArgs e) { if (videoSource.IsRunning == true) { videoSource.Stop(); VideoBox.Image = null; VideoBox.Invalidate(); } else { videoSource = new VideoCaptureDevice(videoDevices[comboBoxVideo.SelectedIndex].MonikerString); // Set NewFrame Event handler videoSource.NewFrame += VideoSource_NewFrame; videoSource.Start(); } }
private void PlayVideo_Click(Button sender) { VideoBox videoBox = window.Controls["VideoBox"] as VideoBox; if (string.IsNullOrEmpty(videoBox.FileName) || videoBox.IsEndOfFile()) { if (string.IsNullOrEmpty(videoBox.FileName)) { videoBox.FileName = "_ResourceEditorSamples\\Video\\Test.ogv"; } if (videoBox.IsEndOfFile()) { videoBox.Rewind(); } } else { videoBox.FileName = ""; } }
private void OnOffButton_Click(object sender, EventArgs e) { //Se o botão On/Off é clicado: //Caso o vídeo já esteja funcionando, ele é desligado if (ImageDevice.IsRunning) { ImageDevice.Stop(); VideoBox.Image = null; VideoBox.Invalidate(); gray = false; RefImage.Image = null; } //Do contrário, é ligado else { ImageDevice = new VideoCaptureDevice(Devices[WebcamsBox.SelectedIndex].MonikerString); ImageDevice.NewFrame += new NewFrameEventHandler(ImageDevice_NewFrame); ImageDevice.Start(); } }
private async void TryToUseFFmpegLocal() { if (inputFile != null) { VideoBox.Stop(); // Open StorageFile as IRandomAccessStream to be passed to FFmpegInteropMSS IRandomAccessStream readStream = await inputFile.OpenAsync(FileAccessMode.Read); try { // Instantiate FFmpegInteropMSS using the opened local file stream ffmpegMss = await FFmpegInteropMSS.CreateFromStreamAsync(readStream); if (ffmpegMss != null) { playbackItem = ffmpegMss.CreateMediaPlaybackItem(); // Pass MediaStreamSource to Media Element VideoBox.SetPlaybackSource(playbackItem); } else { ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen); } } catch (Exception ex) { ShowDialog.DisplayErrorMessage(ex.Message); } } //try //{ // IRandomAccessStream readStream = await inputFile.OpenAsync(FileAccessMode.Read); // ffmpegMss = await FFmpegInteropMSS.CreateFromStreamAsync(readStream); // if (ffmpegMss != null) // { // MediaStreamSource mss = ffmpegMss.GetMediaStreamSource(); // if (mss != null) // { // mss.BufferTime = TimeSpan.Zero; // sender.Source = MediaSource.CreateFromMediaStreamSource(mss); // sender.RealTimePlayback = true; // sender.Play(); // } // else // { // ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen); // } // } // else // { // ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen); // } //} //catch (Exception ex) //{ // ShowDialog.DisplayErrorMessage(ex.Message); //} }
void Awake() { IsOnMagnet = false; Target = null; }