Commit d46f704f authored by Martin Finkel's avatar Martin Finkel

Move media enums outside the Media class

Aligns with other enum types
Remove unneeded redundancy
parent a5030594
...@@ -33,7 +33,7 @@ namespace LibVLCSharp.Tests ...@@ -33,7 +33,7 @@ namespace LibVLCSharp.Tests
var mp = new MediaPlayer(_libVLC) var mp = new MediaPlayer(_libVLC)
{ {
Media = new Media(_libVLC, UrlRequireAuth, Media.FromType.FromLocation) Media = new Media(_libVLC, UrlRequireAuth, FromType.FromLocation)
}; };
mp.Play(); mp.Play();
...@@ -63,7 +63,7 @@ namespace LibVLCSharp.Tests ...@@ -63,7 +63,7 @@ namespace LibVLCSharp.Tests
var mp = new MediaPlayer(_libVLC) var mp = new MediaPlayer(_libVLC)
{ {
Media = new Media(_libVLC, UrlRequireAuth, Media.FromType.FromLocation) Media = new Media(_libVLC, UrlRequireAuth, FromType.FromLocation)
}; };
mp.Play(); mp.Play();
...@@ -95,7 +95,7 @@ namespace LibVLCSharp.Tests ...@@ -95,7 +95,7 @@ namespace LibVLCSharp.Tests
var mp = new MediaPlayer(_libVLC) var mp = new MediaPlayer(_libVLC)
{ {
Media = new Media(_libVLC, UrlRequireAuth, Media.FromType.FromLocation) Media = new Media(_libVLC, UrlRequireAuth, FromType.FromLocation)
}; };
mp.Play(); mp.Play();
......
...@@ -14,13 +14,13 @@ namespace LibVLCSharp.Tests ...@@ -14,13 +14,13 @@ namespace LibVLCSharp.Tests
{ {
var media = new Media(_libVLC, Path.GetTempFileName()); var media = new Media(_libVLC, Path.GetTempFileName());
var eventHandlerCalled = false; var eventHandlerCalled = false;
const Media.MetadataType description = Media.MetadataType.Description; const MetadataType description = MetadataType.Description;
media.MetaChanged += (sender, args) => media.MetaChanged += (sender, args) =>
{ {
Assert.AreEqual(description, args.MetadataType); Assert.AreEqual(description, args.MetadataType);
eventHandlerCalled = true; eventHandlerCalled = true;
}; };
media.SetMeta(Media.MetadataType.Description, "test"); media.SetMeta(MetadataType.Description, "test");
Assert.True(eventHandlerCalled); Assert.True(eventHandlerCalled);
} }
......
...@@ -32,7 +32,7 @@ namespace LibVLCSharp.Tests ...@@ -32,7 +32,7 @@ namespace LibVLCSharp.Tests
public async Task TrackDescription() public async Task TrackDescription()
{ {
var mp = new MediaPlayer(_libVLC); var mp = new MediaPlayer(_libVLC);
var media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation); var media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation);
var tcs = new TaskCompletionSource<bool>(); var tcs = new TaskCompletionSource<bool>();
mp.Media = media; mp.Media = media;
...@@ -51,7 +51,7 @@ namespace LibVLCSharp.Tests ...@@ -51,7 +51,7 @@ namespace LibVLCSharp.Tests
[Test] [Test]
public async Task Play() public async Task Play()
{ {
var media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation); var media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation);
var mp = new MediaPlayer(media); var mp = new MediaPlayer(media);
var called = false; var called = false;
mp.Playing += (sender, args) => mp.Playing += (sender, args) =>
...@@ -72,7 +72,7 @@ namespace LibVLCSharp.Tests ...@@ -72,7 +72,7 @@ namespace LibVLCSharp.Tests
{ {
try try
{ {
var media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation); var media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation);
var mp = new MediaPlayer(media); var mp = new MediaPlayer(media);
...@@ -147,7 +147,7 @@ namespace LibVLCSharp.Tests ...@@ -147,7 +147,7 @@ namespace LibVLCSharp.Tests
{ {
var mp = new MediaPlayer(_libVLC); var mp = new MediaPlayer(_libVLC);
mp.Play(new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation)); mp.Play(new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation));
await Task.Delay(1000); await Task.Delay(1000);
...@@ -161,7 +161,7 @@ namespace LibVLCSharp.Tests ...@@ -161,7 +161,7 @@ namespace LibVLCSharp.Tests
{ {
var mp = new MediaPlayer(_libVLC); var mp = new MediaPlayer(_libVLC);
mp.Play(new Media(_libVLC, "https://streams.videolan.org/streams/360/eagle_360.mp4", Media.FromType.FromLocation)); mp.Play(new Media(_libVLC, "https://streams.videolan.org/streams/360/eagle_360.mp4", FromType.FromLocation));
await Task.Delay(1000); await Task.Delay(1000);
......
...@@ -53,7 +53,7 @@ namespace LibVLCSharp.Tests ...@@ -53,7 +53,7 @@ namespace LibVLCSharp.Tests
[Test] [Test]
public async Task CreateRealMedia() public async Task CreateRealMedia()
{ {
using (var media = new Media(_libVLC, RealStreamMediaPath, Media.FromType.FromLocation)) using (var media = new Media(_libVLC, RealStreamMediaPath, FromType.FromLocation))
{ {
Assert.NotZero(media.Duration); Assert.NotZero(media.Duration);
using (var mp = new MediaPlayer(media)) using (var mp = new MediaPlayer(media))
...@@ -86,9 +86,9 @@ namespace LibVLCSharp.Tests ...@@ -86,9 +86,9 @@ namespace LibVLCSharp.Tests
{ {
var media = new Media(_libVLC, Path.GetTempFileName()); var media = new Media(_libVLC, Path.GetTempFileName());
const string test = "test"; const string test = "test";
media.SetMeta(Media.MetadataType.ShowName, test); media.SetMeta(MetadataType.ShowName, test);
Assert.True(media.SaveMeta()); Assert.True(media.SaveMeta());
Assert.AreEqual(test, media.Meta(Media.MetadataType.ShowName)); Assert.AreEqual(test, media.Meta(MetadataType.ShowName));
} }
[Test] [Test]
...@@ -104,14 +104,14 @@ namespace LibVLCSharp.Tests ...@@ -104,14 +104,14 @@ namespace LibVLCSharp.Tests
public async Task CreateRealMediaSpecialCharacters() public async Task CreateRealMediaSpecialCharacters()
{ {
_libVLC.Log += LibVLC_Log; _libVLC.Log += LibVLC_Log;
using (var media = new Media(_libVLC, RealMp3PathSpecialCharacter, Media.FromType.FromPath)) using (var media = new Media(_libVLC, RealMp3PathSpecialCharacter, FromType.FromPath))
{ {
Assert.False(media.IsParsed); Assert.False(media.IsParsed);
media.Parse(); media.Parse();
await Task.Delay(5000); await Task.Delay(5000);
Assert.True(media.IsParsed); Assert.True(media.IsParsed);
Assert.AreEqual(Media.MediaParsedStatus.Done, media.ParsedStatus); Assert.AreEqual(MediaParsedStatus.Done, media.ParsedStatus);
using (var mp = new MediaPlayer(media)) using (var mp = new MediaPlayer(media))
{ {
Assert.True(mp.Play()); Assert.True(mp.Play());
......
...@@ -22,7 +22,7 @@ namespace LibVLCSharp.Tests ...@@ -22,7 +22,7 @@ namespace LibVLCSharp.Tests
var mp = new MediaPlayer(_libVLC) var mp = new MediaPlayer(_libVLC)
{ {
Media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4",
Media.FromType.FromLocation) FromType.FromLocation)
}; };
Assert.True(mp.Play()); Assert.True(mp.Play());
......
...@@ -243,7 +243,7 @@ namespace LibVLCSharp.Shared ...@@ -243,7 +243,7 @@ namespace LibVLCSharp.Shared
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal readonly struct MediaMetaChanged internal readonly struct MediaMetaChanged
{ {
internal readonly Media.MetadataType MetaType; internal readonly MetadataType MetaType;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
...@@ -261,7 +261,7 @@ namespace LibVLCSharp.Shared ...@@ -261,7 +261,7 @@ namespace LibVLCSharp.Shared
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal readonly struct MediaParsedChanged internal readonly struct MediaParsedChanged
{ {
internal readonly Media.MediaParsedStatus NewStatus; internal readonly MediaParsedStatus NewStatus;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
...@@ -441,9 +441,9 @@ namespace LibVLCSharp.Shared ...@@ -441,9 +441,9 @@ namespace LibVLCSharp.Shared
public class MediaMetaChangedEventArgs : EventArgs public class MediaMetaChangedEventArgs : EventArgs
{ {
public readonly Media.MetadataType MetadataType; public readonly MetadataType MetadataType;
internal MediaMetaChangedEventArgs(Media.MetadataType metadataType) internal MediaMetaChangedEventArgs(MetadataType metadataType)
{ {
MetadataType = metadataType; MetadataType = metadataType;
} }
...@@ -451,9 +451,9 @@ namespace LibVLCSharp.Shared ...@@ -451,9 +451,9 @@ namespace LibVLCSharp.Shared
public class MediaParsedChangedEventArgs : EventArgs public class MediaParsedChangedEventArgs : EventArgs
{ {
public readonly Media.MediaParsedStatus ParsedStatus; public readonly MediaParsedStatus ParsedStatus;
internal MediaParsedChangedEventArgs(Media.MediaParsedStatus parsedStatus) internal MediaParsedChangedEventArgs(MediaParsedStatus parsedStatus)
{ {
ParsedStatus = parsedStatus; ParsedStatus = parsedStatus;
} }
......
...@@ -162,117 +162,7 @@ namespace LibVLCSharp.Shared ...@@ -162,117 +162,7 @@ namespace LibVLCSharp.Shared
EntryPoint = "libvlc_media_get_codec_description")] EntryPoint = "libvlc_media_get_codec_description")]
internal static extern string LibvlcMediaGetCodecDescription(TrackType type, uint codec); internal static extern string LibvlcMediaGetCodecDescription(TrackType type, uint codec);
} }
#region enums
/// <summary>Meta data types</summary>
public enum MetadataType
{
Title = 0,
Artist = 1,
Genre = 2,
Copyright = 3,
Album = 4,
TrackNumber = 5,
Description = 6,
Rating = 7,
Date = 8,
Setting = 9,
URL = 10,
Language = 11,
NowPlaying = 12,
Publisher = 13,
EncodedBy = 14,
ArtworkURL = 15,
TrackID = 16,
TrackTotal = 17,
Director = 18,
Season = 19,
Episode = 20,
ShowName = 21,
Actors = 22,
AlbumArtist = 23,
DiscNumber = 24,
DiscTotal = 25
}
/// <summary>
/// The FromType enum is used to drive the media creation.
/// A media is usually created using a string, which can represent one of 3 things: FromPath, FromLocation, AsNode.
/// </summary>
public enum FromType
{
/// <summary>
/// Create a media for a certain file path.
/// </summary>
FromPath,
/// <summary>
/// Create a media with a certain given media resource location,
/// for instance a valid URL.
/// note To refer to a local file with this function,
/// the file://... URI syntax <b>must</b> be used (see IETF RFC3986).
/// We recommend using FromPath instead when dealing with
///local files.
/// </summary>
FromLocation,
/// <summary>
/// Create a media as an empty node with a given name.
/// </summary>
AsNode
}
/// <summary>
/// Parse flags used by libvlc_media_parse_with_options()
/// </summary>
/// <remarks>libvlc_media_parse_with_options</remarks>
[Flags]
public enum MediaParseOptions
{
/// <summary>Parse media if it's a local file</summary>
ParseLocal = 0,
/// <summary>Parse media even if it's a network file</summary>
ParseNetwork = 1,
/// <summary>Fetch meta and covert art using local resources</summary>
FetchLocal = 2,
/// <summary>Fetch meta and covert art using network resources</summary>
FetchNetwork = 4,
/// <summary>
/// Interact with the user (via libvlc_dialog_cbs) when preparsing this item
/// (and not its sub items). Set this flag in order to receive a callback
/// when the input is asking for credentials.
/// </summary>
DoInteract = 8
}
/// <summary>
/// Parse status used sent by libvlc_media_parse_with_options() or returned by
/// libvlc_media_get_parsed_status()
/// </summary>
/// <remarks>
/// libvlc_media_parse_with_options
/// libvlc_media_get_parsed_status
/// </remarks>
public enum MediaParsedStatus
{
Skipped = 1,
Failed = 2,
Timeout = 3,
Done = 4
}
/// <summary>Media type</summary>
/// <remarks>libvlc_media_get_type</remarks>
public enum MediaType
{
Unknown = 0,
File = 1,
Directory = 2,
Disc = 3,
Stream = 4,
Playlist = 5
}
#endregion
/// <summary> /// <summary>
/// Media Constructs a libvlc Media instance /// Media Constructs a libvlc Media instance
/// </summary> /// </summary>
...@@ -1030,6 +920,114 @@ namespace LibVLCSharp.Shared ...@@ -1030,6 +920,114 @@ namespace LibVLCSharp.Shared
/// </summary> /// </summary>
Audio = 1 Audio = 1
} }
/// <summary>Meta data types</summary>
public enum MetadataType
{
Title = 0,
Artist = 1,
Genre = 2,
Copyright = 3,
Album = 4,
TrackNumber = 5,
Description = 6,
Rating = 7,
Date = 8,
Setting = 9,
URL = 10,
Language = 11,
NowPlaying = 12,
Publisher = 13,
EncodedBy = 14,
ArtworkURL = 15,
TrackID = 16,
TrackTotal = 17,
Director = 18,
Season = 19,
Episode = 20,
ShowName = 21,
Actors = 22,
AlbumArtist = 23,
DiscNumber = 24,
DiscTotal = 25
}
/// <summary>
/// The FromType enum is used to drive the media creation.
/// A media is usually created using a string, which can represent one of 3 things: FromPath, FromLocation, AsNode.
/// </summary>
public enum FromType
{
/// <summary>
/// Create a media for a certain file path.
/// </summary>
FromPath,
/// <summary>
/// Create a media with a certain given media resource location,
/// for instance a valid URL.
/// note To refer to a local file with this function,
/// the file://... URI syntax <b>must</b> be used (see IETF RFC3986).
/// We recommend using FromPath instead when dealing with
///local files.
/// </summary>
FromLocation,
/// <summary>
/// Create a media as an empty node with a given name.
/// </summary>
AsNode
}
/// <summary>
/// Parse flags used by libvlc_media_parse_with_options()
/// </summary>
/// <remarks>libvlc_media_parse_with_options</remarks>
[Flags]
public enum MediaParseOptions
{
/// <summary>Parse media if it's a local file</summary>
ParseLocal = 0,
/// <summary>Parse media even if it's a network file</summary>
ParseNetwork = 1,
/// <summary>Fetch meta and covert art using local resources</summary>
FetchLocal = 2,
/// <summary>Fetch meta and covert art using network resources</summary>
FetchNetwork = 4,
/// <summary>
/// Interact with the user (via libvlc_dialog_cbs) when preparsing this item
/// (and not its sub items). Set this flag in order to receive a callback
/// when the input is asking for credentials.
/// </summary>
DoInteract = 8
}
/// <summary>
/// Parse status used sent by libvlc_media_parse_with_options() or returned by
/// libvlc_media_get_parsed_status()
/// </summary>
/// <remarks>
/// libvlc_media_parse_with_options
/// libvlc_media_get_parsed_status
/// </remarks>
public enum MediaParsedStatus
{
Skipped = 1,
Failed = 2,
Timeout = 3,
Done = 4
}
/// <summary>Media type</summary>
/// <remarks>libvlc_media_get_type</remarks>
public enum MediaType
{
Unknown = 0,
File = 1,
Directory = 2,
Disc = 3,
Stream = 4,
Playlist = 5
}
#endregion #endregion
/// <summary> /// <summary>
......
...@@ -1610,12 +1610,6 @@ namespace LibVLCSharp.Shared ...@@ -1610,12 +1610,6 @@ namespace LibVLCSharp.Shared
return frame; return frame;
} }
#endif #endif
#region Enums
#endregion
#region Callbacks #region Callbacks
......
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