SourceFile Property

Summary
Gets or sets the media source filename, URL or UDP address.
Syntax
C#
C++/CLI
[EditorAttribute(System.Type, System.Type)] 
public virtual string SourceFile { get; set; } 
public: 
virtual property String^ SourceFile { 
   String^ get(); 
   void set (    String^ ); 
} 

Property Value

A string value representing the source filename.

Remarks

In order for DVD playback support to work under windows 10 (either using DVD Source object or default DirectShow DVD Navigator), the Windows DVD Player App needs to be installed.

Use this property to set the media source to the specified filename, URL or UDP address. The SourceType will be set to SourceObjectType.File. The filename can be used to indicate a regular file or a network stream. For more details on filename syntax, refer to Source File syntax. Assignment can raise an error exception. For more information, refer to the Error Codes. When you set the source to a URL, setting the property will block waiting until data arrives or the filter's timeout is exceeded. The timeouts can be large (15+ seconds), so setting the source in the main user interface thread might block the app for many seconds. If no data is received, some filters (LEAD MPEG-2 Transport UDP Source and LEAD RTSP Source), will cause a MediaEvent event to be fired every second. The event will have eventCode set to MediaEventCode.EC_LOADSTATUS and param1 will be set to LoadStatusEventCode.AM_LOADSTATUS_WAITING_FOR_DATA. See the MediaEventCode enumeration for more details. You can abort the wait for data by calling ResetSource while processing the event. See LoadStatusEventCode for more details.

For more information, refer to the Error Codes.

Example
C#
using Leadtools; 
using Leadtools.Multimedia; 
using LeadtoolsMultimediaExamples.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 video renderer properties dialog is available 
      if (_playctrl.HasDialog(PlayDlg.VideoRenderer)) 
      { 
         // now show it to change some settings 
         _playctrl.ShowDialog(PlayDlg.VideoRenderer, _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.Multimedia.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.Multimedia.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:\LEADTOOLS22\Media"; 
} 
Requirements

Target Platforms

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

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