예제 #1
0
        private void CheckVideoResolutionChanges()
        {
            if (videoWin == null || basicVideo == null)
            {
                return;
            }
            int aspectX, aspectY;
            int videoWidth = 1, videoHeight = 1;

            if (basicVideo != null)
            {
                basicVideo.GetVideoSize(out videoWidth, out videoHeight);
            }
            aspectX = videoWidth;
            aspectY = videoHeight;
            if (basicVideo != null)
            {
                basicVideo.GetPreferredAspectRatio(out aspectX, out aspectY);
            }
            if (videoHeight != m_iVideoHeight || videoWidth != m_iVideoWidth ||
                aspectX != m_aspectX || aspectY != m_aspectY)
            {
                _updateNeeded = true;
                SetVideoWindow();
            }
        }
예제 #2
0
        public override void GetNativeVideoSize(out int width, out int height, out int arWidth, out int arHeight)
        {
            if (!_initialized)
            {
                Initialize(GraphBuilder, MediaWindowHandle);
                _initialized = true;
            }

            BasicVideo2.GetVideoSize(out width, out height);
            BasicVideo2.GetPreferredAspectRatio(out arWidth, out arHeight);
        }
예제 #3
0
        void TestVideoDim()
        {
            int hr;
            int vw, vh;

            hr = m_ibv.get_VideoWidth(out vw);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(vw == 320, "get_VideoWidth");

            hr = m_ibv.get_VideoHeight(out vh);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(vh == 240, "get_VideoHeight");

            hr = m_ibv.GetVideoSize(out vw, out vh);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(vw == 320, "get_VideoWidth");
            Debug.Assert(vh == 240, "get_VideoHeight");
        }
    public override bool Play(string strFile)
    {
      _endOfFileDetected = false;
      Log.Info("TSReaderPlayer play:{0} radio:{1}", strFile, _isRadio);
      if (strFile.ToLowerInvariant().StartsWith("rtsp:") == false)
      {
        if (!File.Exists(strFile))
        {
          return false;
        }
      }
      Speed = 1;
      iSpeed = 1;
      _speedRate = 10000;
      _isLive = false;
      _duration = -1d;
      if (strFile.ToLowerInvariant().IndexOf(".tsbuffer") >= 0)
      {
        Log.Info("TSReaderPlayer: live tv");
        _isLive = true;
      }
      if (strFile.ToLowerInvariant().IndexOf("rtsp") >= 0)
      {
        Log.Info("TSReaderPlayer: live tv");
        _isLive = true;
      }
      ExclusiveMode(true);
      VideoRendererStatistics.VideoState = VideoRendererStatistics.State.VideoPresent;
      _isVisible = false;
      GUIGraphicsContext.IsWindowVisible = false;
      _volume = 100;
      _state = PlayState.Init;
      _currentFile = strFile;
      _isFullscreen = false;
      _geometry = Geometry.Type.Normal;
      _updateNeeded = true;

      Log.Info("TSReaderPlayer:play {0}", strFile);
      _isStarted = false;
      if (!GetInterfaces(strFile))
      {
        Log.Error("TSReaderPlayer:GetInterfaces() failed");
        _currentFile = "";
        CloseInterfaces();
        ExclusiveMode(false);
        return false;
      }

      _basicVideo = _graphBuilder as IBasicVideo2;
      _videoWin = _graphBuilder as IVideoWindow;

      int hr = _mediaEvt.SetNotifyWindow(GUIGraphicsContext.ActiveForm, WM_GRAPHNOTIFY, IntPtr.Zero);
      if (hr < 0)
      {
        Log.Error("TSReaderPlayer:SetNotifyWindow() failed");
        _currentFile = "";
        CloseInterfaces();
        ExclusiveMode(false);
        return false;
      }

      if (_basicVideo != null)
      {
        hr = _basicVideo.GetVideoSize(out _videoWidth, out _videoHeight);
        if (hr < 0)
        {
          Log.Info("TSReaderPlayer:GetVideoSize() failed");
        }
        Log.Info("TSReaderPlayer:VideoSize:{0}x{1}", _videoWidth, _videoHeight);
      }
      GUIGraphicsContext.VideoSize = new Size(_videoWidth, _videoHeight);
      if (_mediaCtrl == null)
      {
        Log.Error("TSReaderPlayer:_mediaCtrl==null");
        _currentFile = "";
        CloseInterfaces();
        ExclusiveMode(false);
        return false;
      }
      //if (_videoWin != null)
      //{
      //  _videoWin.put_WindowStyle((WindowStyle)((int)WindowStyle.Child + (int)WindowStyle.ClipSiblings + (int)WindowStyle.ClipChildren));
      //  _videoWin.put_MessageDrain(GUIGraphicsContext.form.Handle);
      //}
      if (_isRadio)
      {
        hr = _mediaCtrl.Run();
      }
      else if (VMR9Util.g_vmr9 != null)
      {
        hr = VMR9Util.g_vmr9.StartMediaCtrl(_mediaCtrl);
      }
      if (hr < 0)
      {
        Log.Error("TSReaderPlayer: Unable to start playing");
        _currentFile = "";
        CloseInterfaces();
        ExclusiveMode(false);
        return false;
      }
      //      _interfaceTSReader = _fileSource;
      _startingUp = _isLive;
      GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null);
      msg.Label = strFile;
      GUIWindowManager.SendThreadMessage(msg);
      _state = PlayState.Playing;
      _positionX = GUIGraphicsContext.VideoWindow.X;
      _positionY = GUIGraphicsContext.VideoWindow.Y;
      _width = GUIGraphicsContext.VideoWindow.Width;
      _height = GUIGraphicsContext.VideoWindow.Height;
      _geometry = GUIGraphicsContext.ARType;
      _updateNeeded = true;
      SetVideoWindow();
      UpdateCurrentPosition();
      UpdateDuration();
      OnInitialized();
      Log.Info("TSReaderPlayer: position:{0}, duration:{1}", CurrentPosition, Duration);
      return true;
    }