Commit 63741ddb authored by Martin Finkel's avatar Martin Finkel

Add initial MediaConfiguration object for WIP crossplatform libvlc...

Add initial MediaConfiguration object for WIP crossplatform libvlc configuration, used in Android sample
parent 02999ed2
......@@ -26,7 +26,11 @@ namespace LibVLCSharp.Android.Sample
_videoView = new VideoView(this);
AddContentView(_videoView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
_videoView.MediaPlayer.Play(new Media(_videoView.LibVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation));
var media = new Media(_videoView.LibVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation);
var configuration = new MediaConfiguration();
configuration.EnableHardwareDecoding();
media.AddOption(configuration);
_videoView.MediaPlayer.Play(media);
}
protected override void OnPause()
......
......@@ -425,6 +425,20 @@ namespace LibVLCSharp.Shared
Native.LibVLCMediaAddOption(NativeReference, options);
}
/// <summary>
/// Convenience method for crossplatform media configuration
/// </summary>
/// <param name="mediaConfiguration">mediaConfiguration translate to strings parsed by the vlc engine, some are platform specific</param>
public void AddOption(MediaConfiguration mediaConfiguration)
{
if (mediaConfiguration == null) throw new ArgumentNullException(nameof(mediaConfiguration));
var options = mediaConfiguration.Build();
if (string.IsNullOrEmpty(options)) throw new ArgumentNullException(nameof(options));
Native.LibVLCMediaAddOption(NativeReference, options);
}
/// <summary>Add an option to the media with configurable flags.</summary>
/// <param name="options">the options (as a string)</param>
/// <param name="flags">the flags for this option</param>
......@@ -1036,4 +1050,19 @@ namespace LibVLCSharp.Shared
public uint Priority;
}
#endregion
public class MediaConfiguration
{
HashSet<string> _options = new HashSet<string>();
public MediaConfiguration EnableHardwareDecoding()
{
#if ANDROID
_options.Add(":codec=mediacodec_ndk");
#endif
return this;
}
public string Build() => string.Join(",", _options);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment