Skip to main content

How to play a fragment of the source file?

Products: Media Player SDK .Net

MediaPlayerCore engine (Windows-only)

You can enable fragment playback by setting the start and stop time to the player object.

Sample code:

// enable fragment playback
MediaPlayer1.Selection_Active = true;

//set start time to 2000 ms
MediaPlayer1.Selection_Start = TimeSpan.FromMilliseconds(2000);

// set stop time to 5000 ms
MediaPlayer1.Selection_Stop = TimeSpan.FromMilliseconds(5000);

Required redists

  • Base redist
  • SDK redist

MediaPlayerCoreX engine (cross-platform)

Sample code:

// create new instance of MediaPlayerCoreX
MediaPlayerCoreX MediaPlayer1 = new MediaPlayerCoreX(VideoView1);

// set the source file
var fileSource = await UniversalSourceSettings.CreateAsync(new Uri("video.mkv"));
await MediaPlayer1.OpenAsync(fileSource);

//set start time to 5000 ms
MediaPlayer1.Segment_Start = TimeSpan.FromMilliseconds(2000);

// set stop time to 10000 ms
MediaPlayer1.Segment_Stop = TimeSpan.FromMilliseconds(5000);

// start playback
await MediaPlayer1.PlayAsync();

How can the required redists be installed or deployed to the user's PC?


Visit our GitHub page to get more code samples.