Пример #1
0
 private void InitializeContext()
 {
     try
     {
         this.context         = new SharpDXContext(this.lockObject);
         this.context.Render += new EventHandler(this.ContextOnRender);
         this.Dispatcher.BeginInvoke((Action)(() =>
         {
             try
             {
                 if (this.context != null && !this.context.IsBound && (this.videoPath != null && this.isLoaded) && this.videoStream != null)
                 {
                     this.context.BindToControl(this.drawingSurface);
                 }
                 this.drawingSurface.Visibility = Visibility.Visible;
             }
             catch
             {
             }
         }));
     }
     catch
     {
     }
 }
Пример #2
0
 public override void Disconnect()
 {
     this.runtimeHost.Dispose();
     this.runtimeHost = (DrawingSurfaceRuntimeHost)null;
     Utilities.Dispose <DrawingSurfaceSynchronizedTexture>(ref this.synchronizedTexture);
     if (this.sharpDXContext == null || !this.sharpDXContext.IsDisposed)
     {
         return;
     }
     this.sharpDXContext = (SharpDXContext)null;
 }
 public DrawingSurfaceContentProvider(SharpDXContext context, object lockObject)
 {
     this.sharpDXContext = context;
     this.lockObject     = lockObject;
     using (Device device = new Device(DriverType.Hardware, DeviceCreationFlags.BgraSupport, new FeatureLevel[5] {
         FeatureLevel.Level_11_1, FeatureLevel.Level_11_0, FeatureLevel.Level_10_1, FeatureLevel.Level_10_0, FeatureLevel.Level_9_3
     }))
     {
         Device        newDevice  = (Device)device.QueryInterface <Device1>();
         DeviceContext newContext = (DeviceContext)newDevice.ImmediateContext.QueryInterface <DeviceContext1>();
         this.sharpDXContext.OnDeviceReset(newDevice, newContext);
     }
 }
Пример #4
0
 public void Initialize(SharpDXContext context)
 {
     lock (this.lockObject)
     {
         this.sharpDxContext = context;
         MediaManager.Startup(false);
         this.multithread = this.sharpDxContext.D3DContext.QueryInterface <DeviceMultithread>();
         this.multithread.SetMultithreadProtected((Bool)true);
         this.dxgiDeviceManager = new DXGIDeviceManager();
         this.dxgiDeviceManager.ResetDevice((ComObject)this.sharpDxContext.D3DDevice);
         this.attributes = new MediaEngineAttributes(0)
         {
             DxgiManager       = this.dxgiDeviceManager,
             VideoOutputFormat = 87
         };
         using (MediaEngineClassFactory resource_0 = new MediaEngineClassFactory())
             this.mediaEngine = new MediaEngine(resource_0, this.attributes, MediaEngineCreateFlags.None, new MediaEngineNotifyDelegate(this.OnMediaEngineEvent));
         this.mediaEngineEx        = this.mediaEngine.QueryInterface <MediaEngineEx>();
         this.mediaEngine.Loop     = (Bool)true;
         this.mediaEngine.AutoPlay = (Bool)true;
     }
 }
Пример #5
0
 private void ReleaseResources()
 {
     lock (this.lockObject)
     {
         IRandomAccessStream local_2 = this.videoStream;
         this.videoStream = null;
         if (this.mediaPlayer != null)
         {
             this.mediaPlayer.Dispose();
             this.mediaPlayer = null;
         }
         if (this.context != null)
         {
             this.context.Render -= new EventHandler(this.ContextOnRender);
             this.context.Dispose();
             this.context = null;
         }
         if (local_2 == null)
         {
             return;
         }
         ((IDisposable)local_2).Dispose();
     }
 }