FrameDuration Property

Summary
Gets the frame duration of the media, in seconds.
Syntax
C#
VB
C++
public virtual int FrameDuration { get; } 
Public Overridable ReadOnly Property FrameDuration As Integer 
public: 
virtual property int FrameDuration { 
   int get(); 
} 

Property Value

A value representing the frame duration, in seconds.

Remarks

Gets the frame duration of the media, in seconds.

Example
C#
VB
using Leadtools; 
using Leadtools.MediaFoundation; 
using LeadtoolsMediaFoundationExamples.Fixtures; 
 
public bool _result = false; 
public PlayCtrlForm _form = new PlayCtrlForm(); 
public PlayCtrl _playctrl; 
public PlaySeeking _seekingCaps; 
public TimeSpan _start = TimeSpan.Zero; 
 
public void HasDialogExample() 
{ 
   // reference the play control 
   _playctrl = _form.PlayCtrl; 
 
   // input file for playback 
   string inFile = Path.Combine(LEAD_VARS.MediaDir, "PlayCtrl_Source.avi"); 
 
   try 
   { 
      // turn off autostart and auto rewind 
      _playctrl.AutoStart = false; 
      _playctrl.AutoRewind = false; 
 
      // set the source file 
      _playctrl.SourceFile = inFile; 
 
      // show some media info if available 
      ShowMediaInfo(); 
 
      // the HasDialog method tells us that the control 
      // can display the desired settings dialog. 
      // check to see if the selected video processor properties dialog is available 
      if (_playctrl.HasDialog(PlayDlg.SelVideoProcessor)) 
      { 
         // now show it to change some settings 
         _playctrl.ShowDialog(PlayDlg.SelVideoProcessor, _form); 
         _result = true; 
      } 
 
      // get the source object type 
      SourceObjectType sot = _playctrl.SourceType; 
 
      // check some audio properties 
      bool mute = _playctrl.Mute; 
      int bal = _playctrl.Balance; 
      int vol = _playctrl.Volume; 
 
      // seeking caps - you can use these to enable menu states or toolbar buttons 
      _seekingCaps = _playctrl.CheckSeekingCapabilities(PlaySeeking.Forward | PlaySeeking.Backward); 
 
      // subscribe to the key press event to demo play functions 
      _playctrl.KeyPress += new Leadtools.MediaFoundation.KeyPressEventHandler(PlayCtrl_KeyPress); 
 
      // start the capture process 
      _playctrl.Run(); 
 
      // 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 
         || _playctrl.State == PlayState.Paused 
         || _playctrl.State == PlayState.NotReady) 
         Application.DoEvents(); 
 
      // call reset source here to release resources 
      // but not necessary if we are just exiting 
      _playctrl.ResetSource(); 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
} 
 
// state variables for helper timer states 
public bool _markedSelStart = false; 
public bool _markedSelEnd = false; 
public bool _seekedSelStart = false; 
public bool _seekedSelEnd = false; 
 
// key press event handler to manage playback functions 
void PlayCtrl_KeyPress(object sender, Leadtools.MediaFoundation.KeyPressEventArgs e) 
{ 
   char key = (char)e.keyAscii; 
   switch (key) 
   { 
      case 'b': 
         if (!_markedSelStart) 
         { 
            _markedSelStart = true; 
            _playctrl.MarkSelectionStart(); 
            System.Diagnostics.Debug.WriteLine("Mark Selection Start: " + _playctrl.SelectionStart.ToString() + " secs"); 
            System.Diagnostics.Debug.WriteLine("  ... playctrl.State: " + _playctrl.State.ToString()); 
         } 
         break; 
      case 'e': 
         if (!_markedSelEnd) 
         { 
            _markedSelEnd = true; 
            _playctrl.Pause(); 
            _playctrl.MarkSelectionEnd(); 
            System.Diagnostics.Debug.WriteLine("Mark Selection End: " 
                                               + _playctrl.SelectionEnd.ToString() 
                                               + " secs"); 
            System.Diagnostics.Debug.WriteLine("  ... playctrl.State: " 
                                               + _playctrl.State.ToString()); 
            _playctrl.SeekSelectionStart(); 
            _playctrl.Run(); 
         } 
         break; 
      case 's': 
         if (!_seekedSelStart) 
         { 
            _seekedSelStart = true; 
            System.Diagnostics.Debug.WriteLine("Seek To Selection Start: " 
                                               + _playctrl.SelectionStart.ToString() 
                                               + " secs"); 
            System.Diagnostics.Debug.WriteLine("  ... playctrl.State: " 
                                               + _playctrl.State.ToString()); 
            _playctrl.SeekSelectionStart(); 
         } 
         break; 
      case 'f': 
         // toggle full screen 
         _playctrl.ToggleFullScreenMode(); 
         break; 
      case '+': 
         if (_playctrl.State == PlayState.Running) 
            _playctrl.Pause(); 
 
         _playctrl.NextFrame(); 
         break; 
      case '-': 
         if (_playctrl.State == PlayState.Running) 
            _playctrl.Pause(); 
 
         _playctrl.PreviousFrame(); 
         break; 
      case 'z': 
         if (!_seekedSelEnd) 
         { 
            // turn off full screen mode 
            _playctrl.FullScreenMode = false; 
 
            _seekedSelEnd = true; 
            System.Diagnostics.Debug.WriteLine("Seek To Selection End: " 
                                               + _playctrl.SelectionEnd.ToString() 
                                               + " secs"); 
            System.Diagnostics.Debug.WriteLine("  ... playctrl.State: " 
                                               + _playctrl.State.ToString()); 
            _playctrl.SeekSelectionEnd(); 
         } 
         break; 
      case 'x': 
         _playctrl.Stop(); 
         break; 
 
   } 
} 
 
private void ShowMediaInfo() 
{ 
   double d = 0; 
   string sa, scr, sd, sr, st; 
 
   sa = scr = sd = sr = st = "Unavailable"; 
 
   try 
   { 
      d = _playctrl.FrameDuration; 
      sa = _playctrl.Author; 
      scr = _playctrl.Copyright; 
      sd = _playctrl.Description; 
      sr = _playctrl.Rating; 
      st = _playctrl.Title; 
   } 
   catch (Exception) 
   { 
   } 
 
   MessageBox.Show(_form, string.Format("Duration: {0}\nAuthor: {1}\nCopyright: {2}\nDesc: {3}\nRating: {4}\nTitle: {5}\n", 
      d, sa, scr, sd, sr, st), "Media Info"); 
} 
 
void SelectedOptions() 
{ 
   _playctrl.SeekStart(); 
   _playctrl.SeekEnd(); 
   int te = _playctrl.TrackingSelectionEnd; 
   int ts = _playctrl.TrackingSelectionStart; 
   double se = _playctrl.SelectionEnd; 
   double ss = _playctrl.SelectionStart; 
} 
 
static class LEAD_VARS 
{ 
   public const string MediaDir = @"C:\LEADTOOLS21\Media"; 
} 
Imports Leadtools 
Imports Leadtools.MediaFoundation 
Imports LeadtoolsMediaFoundationExamples.Fixtures 
 
Public _result As Boolean = False 
Public _form As PlayCtrlForm = New PlayCtrlForm() 
Public _playctrl As PlayCtrl 
Public _seekingCaps As PlaySeeking 
Public _start As TimeSpan = TimeSpan.Zero 
 
Public Sub HasDialogExample() 
   ' reference the play control 
   _playctrl = _form.PlayCtrl 
 
   ' input file for playback 
   Dim inFile As String = Path.Combine(LEAD_VARS.MediaDir, "PlayCtrl_Source.avi") 
 
   Try 
      ' turn off autostart and auto rewind 
      _playctrl.AutoStart = False 
      _playctrl.AutoRewind = False 
 
      ' set the source file 
      _playctrl.SourceFile = inFile 
 
      ' show some media info if available 
      ShowMediaInfo() 
 
      ' the HasDialog method tells us that the control 
      ' can display the desired settings dialog. 
      ' check to see if the selected video processor properties dialog is available 
      If _playctrl.HasDialog(PlayDlg.SelVideoProcessor) Then 
         ' now show it to change some settings 
         _playctrl.ShowDialog(PlayDlg.SelVideoProcessor, _form) 
         _result = True 
      End If 
 
      ' get the source object type 
      Dim sot As SourceObjectType = _playctrl.SourceType 
 
      ' check some audio properties 
      Dim mute As Boolean = _playctrl.Mute 
      Dim bal As Integer = _playctrl.Balance 
      Dim vol As Integer = _playctrl.Volume 
 
      ' seeking caps - you can use these to enable menu states or toolbar buttons 
      _seekingCaps = _playctrl.CheckSeekingCapabilities(PlaySeeking.Forward Or PlaySeeking.Backward) 
 
      ' subscribe to the key press event to demo play functions 
      AddHandler _playctrl.KeyPress, AddressOf PlayCtrl_KeyPress 
 
      ' start the capture process 
      _playctrl.Run() 
 
      ' 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 _playctrl.State = PlayState.Running _ 
           OrElse _playctrl.State = PlayState.Paused _ 
           OrElse _playctrl.State = PlayState.NotReady 
         Application.DoEvents() 
      Loop 
 
      ' call reset source here to release resources 
      ' but not necessary if we are just exiting 
      _playctrl.ResetSource() 
   Catch e1 As Exception 
      _result = False 
   End Try 
End Sub 
 
' state variables for helper timer states 
Public _markedSelStart As Boolean = False 
Public _markedSelEnd As Boolean = False 
Public _seekedSelStart As Boolean = False 
Public _seekedSelEnd As Boolean = False 
 
' key press event handler to manage playback functions 
Private Sub PlayCtrl_KeyPress(ByVal sender As Object, ByVal e As Leadtools.MediaFoundation.KeyPressEventArgs) 
   Dim key As Char = CChar(ChrW(e.keyAscii)) 
   Select Case key 
      Case "b"c 
         If (Not _markedSelStart) Then 
            _markedSelStart = True 
            _playctrl.MarkSelectionStart() 
            System.Diagnostics.Debug.WriteLine("Mark Selection Start: " & _playctrl.SelectionStart.ToString() & " secs") 
            System.Diagnostics.Debug.WriteLine("  ... playctrl.State: " & _playctrl.State.ToString()) 
         End If 
      Case "e"c 
         If (Not _markedSelEnd) Then 
            _markedSelEnd = True 
            _playctrl.Pause() 
            _playctrl.MarkSelectionEnd() 
            System.Diagnostics.Debug.WriteLine("Mark Selection End: " & _playctrl.SelectionEnd.ToString() & " secs") 
            System.Diagnostics.Debug.WriteLine("  ... playctrl.State: " & _playctrl.State.ToString()) 
            _playctrl.SeekSelectionStart() 
            _playctrl.Run() 
         End If 
      Case "s"c 
         If (Not _seekedSelStart) Then 
            _seekedSelStart = True 
            System.Diagnostics.Debug.WriteLine("Seek To Selection Start: " & _playctrl.SelectionStart.ToString() & " secs") 
            System.Diagnostics.Debug.WriteLine("  ... playctrl.State: " & _playctrl.State.ToString()) 
            _playctrl.SeekSelectionStart() 
         End If 
      Case "f"c 
         ' toggle full screen 
         _playctrl.ToggleFullScreenMode() 
      Case "+"c 
         If _playctrl.State = PlayState.Running Then 
            _playctrl.Pause() 
         End If 
 
         _playctrl.NextFrame() 
      Case "-"c 
         If _playctrl.State = PlayState.Running Then 
            _playctrl.Pause() 
         End If 
 
         _playctrl.PreviousFrame() 
      Case "z"c 
         If (Not _seekedSelEnd) Then 
            ' turn off full screen mode 
            _playctrl.FullScreenMode = False 
 
            _seekedSelEnd = True 
            System.Diagnostics.Debug.WriteLine("Seek To Selection End: " & _playctrl.SelectionEnd.ToString() & " secs") 
            System.Diagnostics.Debug.WriteLine("  ... playctrl.State: " & _playctrl.State.ToString()) 
            _playctrl.SeekSelectionEnd() 
         End If 
      Case "x"c 
         _playctrl.Stop() 
 
   End Select 
End Sub 
 
Private Sub ShowMediaInfo() 
   Dim d As Double = 0 
   Dim sa, scr, sd, sr, st As String 
 
   sa = "Unavailable" 
   scr = "Unavailable" 
   sd = "Unavailable" 
   sr = "Unavailable" 
   st = "Unavailable" 
 
   Try 
      d = _playctrl.FrameDuration 
      sa = _playctrl.Author 
      scr = _playctrl.Copyright 
      sd = _playctrl.Description 
      sr = _playctrl.Rating 
      st = _playctrl.Title 
   Catch e1 As Exception 
   End Try 
 
   MessageBox.Show(_form, String.Format("Duration: {0}" _ 
                                        & Microsoft.VisualBasic.Constants.vbLf _ 
                                        & "Author: {1}" _ 
                                        & Microsoft.VisualBasic.Constants.vbLf _ 
                                        & "Copyright: {2}" _ 
                                        & Microsoft.VisualBasic.Constants.vbLf _ 
                                        & "Desc: {3}" & Microsoft.VisualBasic.Constants.vbLf _ 
                                        & "Rating: {4}" & Microsoft.VisualBasic.Constants.vbLf _ 
                                        & "Title: {5}" _ 
                                        & Microsoft.VisualBasic.Constants.vbLf, 
                                        d, sa, scr, sd, sr, st), "Media Info") 
End Sub 
 
Private Sub SelectedOptions() 
   _playctrl.SeekStart() 
   _playctrl.SeekEnd() 
   Dim te As Integer = _playctrl.TrackingSelectionEnd 
   Dim ts As Integer = _playctrl.TrackingSelectionStart 
   Dim se As Double = _playctrl.SelectionEnd 
   Dim ss As Double = _playctrl.SelectionStart 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const MediaDir As String = "C:\LEADTOOLS21\Media" 
End Class 
Requirements

Target Platforms

See Also

Reference

PlayCtrl Class

PlayCtrl Members

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

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