Commit 43c7939d authored by Martin Finkel's avatar Martin Finkel

Fix native samples

parent 4633523b
......@@ -11,6 +11,8 @@ namespace LibVLCSharp.Android.Sample
public class MainActivity : Activity
{
VideoView _videoView;
LibVLC _libVLC;
MediaPlayer _mediaPlayer;
protected override void OnCreate(Bundle savedInstanceState)
{
......@@ -24,9 +26,14 @@ namespace LibVLCSharp.Android.Sample
{
base.OnResume();
_videoView = new VideoView(this);
Core.Initialize();
_libVLC = new LibVLC();
_mediaPlayer = new MediaPlayer(_libVLC);
_videoView = new VideoView(this) { MediaPlayer = _mediaPlayer };
AddContentView(_videoView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
var media = new Media(_videoView.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", Media.FromType.FromLocation);
var configuration = new MediaConfiguration();
configuration.EnableHardwareDecoding();
media.AddOption(configuration);
......
......@@ -11,6 +11,8 @@ namespace LibVLCSharp.Mac.Sample
public partial class ViewController : NSViewController
{
VideoView _videoView;
LibVLC _libVLC;
Shared.MediaPlayer _mediaPlayer;
public ViewController(IntPtr handle) : base(handle)
{
......@@ -20,13 +22,14 @@ namespace LibVLCSharp.Mac.Sample
{
base.ViewDidLoad();
_videoView = new VideoView();
_libVLC = new LibVLC();
_mediaPlayer = new Shared.MediaPlayer(_libVLC);
_videoView = new VideoView { MediaPlayer = _mediaPlayer };
View = _videoView;
_videoView.MediaPlayer.Play(new Media(
_videoView.LibVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4",
Media.FromType.FromLocation));
_videoView.MediaPlayer.Play(new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation));
}
public override NSObject RepresentedObject
......@@ -42,4 +45,4 @@ namespace LibVLCSharp.Mac.Sample
}
}
}
}
}
\ No newline at end of file
......@@ -8,6 +8,8 @@ namespace LibVLCSharp.WPF.Sample
public partial class Controls : UserControl
{
readonly Example1 parent;
LibVLC _libVLC;
MediaPlayer _mediaPlayer;
public Controls(Example1 Parent)
{
......@@ -15,23 +17,34 @@ namespace LibVLCSharp.WPF.Sample
InitializeComponent();
Loaded += Controls_Loaded;
PlayButton.Click += PlayButton_Click;
StopButton.Click += StopButton_Click;
}
private void Controls_Loaded(object sender, RoutedEventArgs e)
{
Core.Initialize();
_libVLC = new LibVLC();
_mediaPlayer = new MediaPlayer(_libVLC);
parent.VideoView.MediaPlayer = _mediaPlayer;
}
void StopButton_Click(object sender, RoutedEventArgs e)
{
if (parent.Player.MediaPlayer.IsPlaying)
if (parent.VideoView.MediaPlayer.IsPlaying)
{
parent.Player.MediaPlayer.Stop();
parent.VideoView.MediaPlayer.Stop();
}
}
void PlayButton_Click(object sender, RoutedEventArgs e)
{
if (!parent.Player.MediaPlayer.IsPlaying)
if (!parent.VideoView.MediaPlayer.IsPlaying)
{
parent.Player.MediaPlayer.Play(new Media(parent.Player.LibVLC,
parent.VideoView.MediaPlayer.Play(new Media(_libVLC,
"http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation));
}
}
......
......@@ -8,6 +8,6 @@
mc:Ignorable="d"
Title="Example1" Height="450" Width="800">
<Grid>
<uc:VideoView x:Name="Player" />
<uc:VideoView x:Name="VideoView" />
</Grid>
</Window>
\ No newline at end of file
......@@ -11,7 +11,7 @@ namespace LibVLCSharp.WPF.Sample
InitializeComponent();
_controls = new Controls(this);
Player.Content = _controls;
VideoView.Content = _controls;
}
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@
mc:Ignorable="d"
Title="Example2" Height="450" Width="800">
<Grid>
<uc:VideoView x:Name="Player" Panel.ZIndex="1">
<uc:VideoView x:Name="VideoView" Panel.ZIndex="1">
<StackPanel Orientation="Horizontal" x:Name="test">
<Button Content="PLAY" Height="25" Width="50" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="PlayButton_Click" />
<Button Content="STOP" Height="25" Width="50" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="StopButton_Click" />
......
......@@ -3,11 +3,15 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using MediaPlayer = LibVLCSharp.Shared.MediaPlayer;
namespace LibVLCSharp.WPF.Sample
{
public partial class Example2 : Window
{
LibVLC _libVLC;
MediaPlayer _mediaPlayer;
public Example2()
{
InitializeComponent();
......@@ -20,21 +24,33 @@ namespace LibVLCSharp.WPF.Sample
Foreground = new SolidColorBrush(Colors.Red)
};
test.Children.Add(label);
Loaded += Controls_Loaded;
}
private void Controls_Loaded(object sender, RoutedEventArgs e)
{
Core.Initialize();
_libVLC = new LibVLC();
_mediaPlayer = new MediaPlayer(_libVLC);
VideoView.MediaPlayer = _mediaPlayer;
}
void StopButton_Click(object sender, RoutedEventArgs e)
{
if (Player.MediaPlayer.IsPlaying)
if (VideoView.MediaPlayer.IsPlaying)
{
Player.MediaPlayer.Stop();
VideoView.MediaPlayer.Stop();
}
}
void PlayButton_Click(object sender, RoutedEventArgs e)
{
if (!Player.MediaPlayer.IsPlaying)
if (!VideoView.MediaPlayer.IsPlaying)
{
Player.MediaPlayer.Play(new Media(Player.LibVLC,
VideoView.MediaPlayer.Play(new Media(_libVLC,
"http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation));
}
}
......
......@@ -8,16 +8,21 @@ namespace LibVLCSharp.iOS.Sample
public class ViewController : UIViewController
{
VideoView _videoView;
LibVLC _libVLC;
Shared.MediaPlayer _mediaPlayer;
public override void ViewDidLoad()
{
base.ViewDidLoad();
_videoView = new VideoView();
_libVLC = new LibVLC();
_mediaPlayer = new Shared.MediaPlayer(_libVLC);
_videoView = new VideoView { MediaPlayer = _mediaPlayer };
View = _videoView;
_videoView.MediaPlayer.Play(new Media(_videoView.LibVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation));
_videoView.MediaPlayer.Play(new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation));
}
}
}
\ No newline at end of file
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