Specifies the media type from portable data.
public void SetPortableType(byte[] Type)
Public Sub SetPortableType( _ByVal Type() As Byte _)
public:void SetPortableType(array<byte>^ Type)
Type
A byte array containing the portable media type information to set.
Specifies the media type from portable data. Only pass data obtained from GetPortableType method to this method. The portable data contains all the information to describe the media type. For example, you do not need to set MediaType.Type, etc. You can, if you want to, but you don't have to. For more information on using the high level method of acquiring the media type, refer to MediaType object. If the method fails, an error is raised. For more information, refer to the Error Codes.
using Leadtools;using Leadtools.Multimedia;using LeadtoolsMultimediaExamples.Fixtures;public bool _result = false;public CaptureAndPlayCtrlForm _form = new CaptureAndPlayCtrlForm();public SampleTarget _captureTarget;public SampleSource _playSource;public void GetPortableTypeExample(){// reference the convert controlCaptureCtrl capturectrl = _form.CaptureCtrl;PlayCtrl playctrl = _form.PlayCtrl;// This example demonstrates how to play a capture stream// using a play control and portable media types.try{// set the source deviceif (capturectrl.VideoDevices["Analog"] == null)throw new Exception("No Analog video devices available!");capturectrl.VideoDevices["Analog"].Selected = true;// set the previewcapturectrl.Preview = true;// create a sample target object for the capture control_captureTarget = new SampleTarget();// set the capture target to our sample target created earliercapturectrl.TargetObject = _captureTarget;// create a new sample source object for the play control_playSource = new SampleSource();// set the video compressorcapturectrl.VideoCompressors.MCmpMJpeg.Selected = true;//// for this example we will only capture 120 seconds of videocapturectrl.UseTimeLimit = true;capturectrl.TimeLimit = 120;// start the capturecapturectrl.StartCapture(CaptureMode.Video);// we could just assign the media type from target to source// however, let's use the portable type to simulate// the needed steps for remote playbackByte[] portableMediaType = _captureTarget.GetConnectedMediaType().GetPortableType();// initialize a new media type object with the portable typeMediaType mt = new MediaType();mt.SetPortableType(portableMediaType);// set the sample source media type_playSource.SetMediaType(mt);// set the play controls sample source objectplayctrl.SourceObject = _playSource;// create a timer to drive the sample delivery_form.TestTimer.Tick += new EventHandler(SampleDeliver_Tick);_form.TestTimer.Interval = 33;_form.TestTimer.Start();// we'll loop on the state and pump messages for this example.// but you should not need to if running from a Windows Forms application.while (capturectrl.State == CaptureState.Running|| capturectrl.State == CaptureState.Paused|| capturectrl.State == CaptureState.Pending)Application.DoEvents();}catch (Exception){_result = false;}}void SampleDeliver_Tick(object sender, EventArgs e){_form.TestTimer.Stop();bool eos = false;MediaSample cs = null;try{cs = _captureTarget.GetSample(1000);}catch (COMException cex){if (cex.ErrorCode == (int)ErrorCode.VFW_E_SAMPLE_REJECTED_EOS)eos = true;elsethrow;}catch (Exception ex){throw new Exception(ex.Message);}if (!eos){_playSource.DeliverSample(1000, cs);_form.TestTimer.Start();}else{_playSource.DeliverEndOfStream(1000);_form.TestTimer.Stop();// set the result_result = true;}}
Imports LeadtoolsImports Leadtools.MultimediaImports LeadtoolsMultimediaExamples.FixturesPublic _result As Boolean = FalsePublic _form As CaptureAndPlayCtrlForm = New CaptureAndPlayCtrlForm()Public _captureTarget As SampleTargetPublic _playSource As SampleSourcePublic Sub GetPortableTypeExample()' reference the convert controlDim capturectrl As CaptureCtrl = _form.CaptureCtrlDim playctrl As PlayCtrl = _form.PlayCtrl' This example demonstrates how to play a capture stream' using a play control and portable media types.Try' set the source deviceIf capturectrl.VideoDevices("Analog") Is Nothing ThenThrow New Exception("No Analog video devices available!")End Ifcapturectrl.VideoDevices("Analog").Selected = True' set the previewcapturectrl.Preview = True' create a sample target object for the capture control_captureTarget = New SampleTarget()' set the capture target to our sample target created earliercapturectrl.TargetObject = _captureTarget' create a new sample source object for the play control_playSource = New SampleSource()' set the video compressorcapturectrl.VideoCompressors.MCmpMJpeg.Selected = True'// for this example we will only capture 120 seconds of videocapturectrl.UseTimeLimit = Truecapturectrl.TimeLimit = 120' start the capturecapturectrl.StartCapture(CaptureMode.Video)' we could just assign the media type from target to source' however, let's use the portable type to simulate' the needed steps for remote playbackDim portableMediaType As Byte() = _captureTarget.GetConnectedMediaType().GetPortableType()' initialize a new media type object with the portable typeDim mt As MediaType = New MediaType()mt.SetPortableType(portableMediaType)' set the sample source media type_playSource.SetMediaType(mt)' set the play controls sample source objectplayctrl.SourceObject = _playSource' create a timer to drive the sample deliveryAddHandler _form.TestTimer.Tick, AddressOf SampleDeliver_Tick_form.TestTimer.Interval = 33_form.TestTimer.Start()' we'll loop on the state and pump messages for this example.' but you should not need to if running from a Windows Forms application.Do While capturectrl.State = CaptureState.Running _OrElse capturectrl.State = CaptureState.Paused OrElse capturectrl.State = CaptureState.PendingApplication.DoEvents()LoopCatch e1 As Exception_result = FalseEnd TryEnd SubPrivate Sub SampleDeliver_Tick(ByVal sender As Object, ByVal e As EventArgs)_form.TestTimer.Stop()Dim eos As Boolean = FalseDim cs As MediaSample = NothingTrycs = _captureTarget.GetSample(1000)Catch cex As COMExceptionIf cex.ErrorCode = CInt(ErrorCode.VFW_E_SAMPLE_REJECTED_EOS) Theneos = TrueElseThrowEnd IfCatch ex As ExceptionThrowEnd TryIf (Not eos) Then_playSource.DeliverSample(1000, cs)_form.TestTimer.Start()Else_playSource.DeliverEndOfStream(1000)_form.TestTimer.Stop()' set the result_result = TrueEnd IfEnd Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
