In the program I am working on, I am looking for a way to create chapter cues in the mp4 file programmatically without altering the mp4 file. I am currently replacing our Windows.UI MediaPlayerElement
with the LibVLCSharp
library, but I am running into difficulty in this functionality. I am looking for some type of functionality similar to the TimedMetaDataTrack in windows, which is what we have used previously
Currently I have the media being set like so
public async Task<bool> SetMedia(string path, bool loop = false)
{
if (_libVLC == null || _mediaPlayer == null)
return false;
CloseMedia();
Uri videoPath = new Uri("ms-appx:///Assets/" + path);
StorageFile storageFile = await StorageFile.GetFileFromApplicationUriAsync(videoPath);
_fileStream = await storageFile.OpenStreamForReadAsync();
_mediaStream = new StreamMediaInput(_fileStream);
var _playerMedia = new Media(_libVLC, _mediaStream);
if (loop)
_playerMedia.AddOption($":input-repeat={int.MaxValue}");
_mediaPlayer.Media = _playerMedia;
await _playerMedia.Parse(MediaParseOptions.ParseLocal);
_mediaPlayer.Play();
_playerMedia.Dispose();
_playerMedia = null;
return true;
}
It works well and there is no issues with the media playing, however I have not been able to find documentation for this specific need.
I have attempted to access the MediaTracks[]
array of the media, but I think this may be readonly and not possible to change in order to update the metadata. Is there a different way I can do this? Essentially, I need the tracks to be configurable and not based off of the existing metadata of the mp4 file. I am sure there must be something I can pass to the AddOption
on creating the media, but I haven't been able to find anything in the command line help about creating tracks rather than how it should access existing ones.