Skip to content

Commit

Permalink
Merge pull request #270 from dennisgranasen/master
Browse files Browse the repository at this point in the history
VlcOptions as List instead of array
  • Loading branch information
devkanro authored Jun 4, 2018
2 parents ca8c1b5 + e28590c commit 0084bfa
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
5 changes: 3 additions & 2 deletions Meta.Vlc.Wpf/ApiManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Version: 20160214

using System;
using System.Linq;
using System.Collections.Generic;

namespace Meta.Vlc.Wpf
Expand Down Expand Up @@ -45,7 +46,7 @@ public static void ReleaseAll()
/// <summary>
/// The options when initialize LibVlc.
/// </summary>
public static String[] VlcOption { get; private set; }
public static IList<String> VlcOption { get; private set; }

/// <summary>
/// The list of VLC.
Expand All @@ -61,7 +62,7 @@ public static Vlc DefaultVlc
{
if (_defaultVlc == null)
{
Vlcs.Add(_defaultVlc = new Vlc(VlcOption));
Vlcs.Add(_defaultVlc = new Vlc(VlcOption.ToArray()));
}

return _defaultVlc;
Expand Down
37 changes: 20 additions & 17 deletions Meta.Vlc.Wpf/ThreadSeparatedImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,34 @@ namespace Meta.Vlc.Wpf
public sealed class ThreadSeparatedImage : ThreadSeparatedControlHost
{
private static Dispatcher _commonDispatcher;
private static object _staticLock = new object();
public static Dispatcher CommonDispatcher
{
get
{
if (_commonDispatcher == null)
lock (_staticLock)
{
Thread separateThread = new Thread(() =>
if (_commonDispatcher == null)
{
Dispatcher.Run();
})
{
IsBackground = true
};
separateThread.SetApartmentState(ApartmentState.STA);
separateThread.Priority = ThreadPriority.Highest;

separateThread.Start();

while (Dispatcher.FromThread(separateThread) == null)
{
Thread.Sleep(50);
Thread separateThread = new Thread(() =>
{
Dispatcher.Run();
})
{
IsBackground = true
};
separateThread.SetApartmentState(ApartmentState.STA);
separateThread.Priority = ThreadPriority.Highest;

separateThread.Start();

while (Dispatcher.FromThread(separateThread) == null)
{
Thread.Sleep(50);
}
_commonDispatcher = Dispatcher.FromThread(separateThread);
}
_commonDispatcher = Dispatcher.FromThread(separateThread);
}

return _commonDispatcher;
}
}
Expand Down
7 changes: 4 additions & 3 deletions Meta.Vlc.Wpf/VlcPlayer.DependencyProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Version: 20160327

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
Expand Down Expand Up @@ -32,14 +33,14 @@ public String LibVlcPath
/// <summary>
/// The options of LibVlc, it is a DependencyProperty.
/// </summary>
public String[] VlcOption
public IList<String> VlcOption
{
get { return (String[]) GetValue(VlcOptionProperty); }
get { return (IList<String>) GetValue(VlcOptionProperty); }
set { SetValue(VlcOptionProperty, value); }
}

public static readonly DependencyProperty VlcOptionProperty =
DependencyProperty.Register("VlcOption", typeof (String[]), typeof (VlcPlayer), null);
DependencyProperty.Register("VlcOption", typeof (IList<String>), typeof (VlcPlayer), new PropertyMetadata(new List<string>()));

#endregion VlcOption

Expand Down
5 changes: 3 additions & 2 deletions Meta.Vlc.Wpf/VlcPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -178,7 +179,7 @@ protected override void OnInitialized(EventArgs e)
}
else
{
Initialize(libVlcPath, libVlcOption);
Initialize(libVlcPath, libVlcOption.ToArray());
}
}
else
Expand All @@ -204,7 +205,7 @@ protected override void OnInitialized(EventArgs e)
libVlcOption = vlcSettingsAttribute.VlcOption;
}

Initialize(libVlcPath, libVlcOption);
Initialize(libVlcPath, libVlcOption.ToArray());
}
}

Expand Down

0 comments on commit 0084bfa

Please sign in to comment.