IsRateSupported Method

Summary
Determines whether a specific playback rate is supported.
Syntax
C#
C++/CLI
public virtual bool IsRateSupported( 
   double rate 
) 
public: 
virtual bool IsRateSupported(  
   double rate 
)  

Parameters

rate
The playback rate, expressed as a ratio of the normal playback speed. For example, use 1.0 for normal speed, 2.0 for double speed, and 0.5 for half speed.

Return Value

true if the specified playback rate is supported; otherwise, it is false.

Example
C#
using Leadtools; 
using Leadtools.MediaFoundation; 
using LeadtoolsMediaFoundationExamples.Fixtures; 
 
 
public bool _result = false; 
public PlayCtrlForm _form = new PlayCtrlForm(); 
double _duration = 0.0; 
double _currentPos = -1; 
 
public void PlayExample() 
{ 
   // reference the play control 
   PlayCtrl playctrl = _form.PlayCtrl; 
 
   // input file 
   string inFile = Path.Combine(LEAD_VARS.MediaDir, "PlayCtrl_Source.avi"); 
 
   try 
   { 
      // set autostart to false 
      playctrl.AutoStart = false; 
 
      // set the play count to 2 
      playctrl.PlayCount = 2; 
 
      // set our source media file 
      playctrl.SourceFile = inFile; 
 
      // get the reported duration 
      _duration = playctrl.Duration; 
 
      // set the playback rate to 2x 
      if (playctrl.IsRateSupported(2.0)) 
         playctrl.Rate = 2.0; 
 
      // set event handler to get tracking position changes 
      playctrl.TrackingPositionChanged += new TrackingPositionChangedEventHandler(PlayCtrl_TrackingPositionChanged); 
 
      // run it! 
      playctrl.Run(); 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
 
   // 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 (playctrl.State == PlayState.Running) 
      Application.DoEvents(); 
 
   // set the result to determine if the reported duration 
   // is the same as the final position from tracking 
   _result = (_duration == _currentPos && _duration > 0.0); 
} 
 
void PlayCtrl_TrackingPositionChanged(object sender, TrackingPositionChangedEventArgs e) 
{ 
   // get the frame and tracking positions for demonstration only 
   int frame = _form.PlayCtrl.CurrentFramePosition; 
   int tracking = _form.PlayCtrl.CurrentTrackingPosition; 
 
   // get the current position 
   _currentPos = Math.Max(_currentPos, _form.PlayCtrl.CurrentPosition); 
} 
 
static class LEAD_VARS 
{ 
   public const string MediaDir = @"C:\LEADTOOLS23\Media"; 
} 
Requirements

Target Platforms

See Also

Reference

PlayCtrl Class

PlayCtrl Members

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.MediaFoundation Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.