Commit 165baeed authored by Martin Finkel's avatar Martin Finkel

android tentative...

parent 0585d18f
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{239A82A5-19A1-4382-8F9B-4A9705648017}</ProjectGuid>
<ProjectTypeGuids>{10368E6C-D01B-4462-8E8B-01FC667A7035};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LibVLCSharp.Android.AWindow</RootNamespace>
<AssemblyName>LibVLCSharp.Android.AWindow</AssemblyName>
<FileAlignment>512</FileAlignment>
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v7.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Jars\AboutJars.txt" />
<None Include="Additions\AboutAdditions.txt" />
<LibraryProjectZip Include="Jars\org.videolan.libvlc.aar" />
</ItemGroup>
<ItemGroup>
<TransformFile Include="Transforms\Metadata.xml" />
<TransformFile Include="Transforms\EnumFields.xml" />
<TransformFile Include="Transforms\EnumMethods.xml" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Android.App;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("LibVLCSharp.Android.AWindow")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LibVLCSharp.Android.AWindow")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<enum-field-mappings>
<!--
This example converts the constants Fragment_id, Fragment_name,
and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
to an enum called Android.Support.V4.App.FragmentTagType with values
Id, Name, and Tag.
<mapping jni-class="android/support/v4/app/FragmentActivity$FragmentTag" clr-enum-type="Android.Support.V4.App.FragmentTagType">
<field jni-name="Fragment_name" clr-name="Name" value="0" />
<field jni-name="Fragment_id" clr-name="Id" value="1" />
<field jni-name="Fragment_tag" clr-name="Tag" value="2" />
</mapping>
-->
</enum-field-mappings>
\ No newline at end of file
<enum-method-mappings>
<!--
This example changes the Java method:
android.support.v4.app.Fragment.SavedState.writeToParcel (int flags)
to be:
android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags)
when bound in C#.
<mapping jni-class="android/support/v4/app/Fragment.SavedState">
<method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
</mapping>
-->
</enum-method-mappings>
\ No newline at end of file
<metadata>
<!--
This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
-->
</metadata>
This diff is collapsed.
......@@ -57,6 +57,10 @@
<Reference Include="Cauldron.Interception, Version=2.0.0.29, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cauldron.Interception.Fody.2.0.29\lib\netstandard2.0\Cauldron.Interception.dll</HintPath>
</Reference>
<Reference Include="LibVLCSharp.Android.AWindow, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\LibVLCSharp.Android.AWindow\bin\Debug\LibVLCSharp.Android.AWindow.dll</HintPath>
</Reference>
<Reference Include="Mono.Android.Export" />
<Reference Include="System" />
<Reference Include="System.Xml" />
......
......@@ -5,8 +5,9 @@ using System.Security;
using Android.App;
using Android.Graphics;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Com.Example.Orgvideolanlibvlc;
using Java.Interop;
using VideoLAN.LibVLC;
......@@ -14,7 +15,7 @@ using VideoLAN.LibVLC;
namespace LibVLCSharp.Android.Sample
{
[Activity(Label = "LibVLCSharp.Android.Sample", MainLauncher = true)]
public class MainActivity : Activity, ICallback
public class MainActivity : Activity, IVLCVoutCallback
{
Instance _instance;
MediaPlayer _mp;
......@@ -27,25 +28,29 @@ namespace LibVLCSharp.Android.Sample
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
JniOnLoad(JniRuntime.CurrentRuntime.InvocationPointer);
}
protected override void OnResume()
{
base.OnResume();
var r = JniOnLoad(JniRuntime.CurrentRuntime.InvocationPointer);
_instance = new Instance();
_mp = new MediaPlayer(_instance);
_awindow = new AWindow(new SurfaceCallback(_mp));
_awindow.AddCallback(this);
_surfaceView = FindViewById<SurfaceView>(Resource.Id.surfaceView);
}
protected override void OnResume()
{
base.OnResume();
_awindow.SetVideoView(_surfaceView);
_awindow.AttachViews();
_surfaceView.AddOnLayoutChangeListener(new LayoutChangeListener(_awindow));
_mp.SetAndroidContext(_awindow.Handle);
_mp.Media = new Media(_instance, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation);
......@@ -76,39 +81,46 @@ namespace LibVLCSharp.Android.Sample
}
}
public void OnSurfaceCreated(IVLCVout vlcVout)
{
System.Diagnostics.Debug.WriteLine("OnSurfaceCreated");
}
//public void OnSurfaceCreated(IVLCVout vlcVout)
//{
// System.Diagnostics.Debug.WriteLine("OnSurfaceCreated");
//}
public void OnSurfacesDestroyed(IVLCVout vlcVout)
{
System.Diagnostics.Debug.WriteLine("OnSurfacesDestroyed");
}
//public void OnSurfacesDestroyed(IVLCVout vlcVout)
//{
// System.Diagnostics.Debug.WriteLine("OnSurfacesDestroyed");
//}
public void OnNewVideoLayout(IVLCVout vlcVout, int width, int height, int visibleWidth, int visibleHeight, int sarNum,
int sarDen)
{
_awindow.SetWindowSize(width, height);
}
//public void OnNewVideoLayout(IVLCVout vlcVout, int width, int height, int visibleWidth, int visibleHeight, int sarNum,
// int sarDen)
//{
// _awindow.SetWindowSize(width, height);
//}
public void SurfaceChanged(ISurfaceHolder holder, Format format, int width, int height)
{
//public void SurfaceChanged(ISurfaceHolder holder, Format format, int width, int height)
//{
}
//}
public void SurfaceCreated(ISurfaceHolder holder)
{
//public void SurfaceCreated(ISurfaceHolder holder)
//{
}
//}
//public void SurfaceDestroyed(ISurfaceHolder holder)
//{
public void SurfaceDestroyed(ISurfaceHolder holder)
//}
public void OnSurfacesCreated(IVLCVout p0)
{
}
public void OnSurfacesDestroyed(IVLCVout p0)
{
}
}
public class SurfaceCallback : Java.Lang.Object, ISurfaceCallback
public class SurfaceCallback : Java.Lang.Object, AWindow.ISurfaceCallback
{
static readonly object _locker = new object();
readonly MediaPlayer _mp;
......@@ -156,6 +168,13 @@ namespace LibVLCSharp.Android.Sample
//_mp.VideoTrackEnabled = false;
}
}
public void Dispose()
{
}
public IntPtr Handle { get; }
}
public class LayoutChangeListener : Java.Lang.Object, View.IOnLayoutChangeListener
......
......@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibVLCSharp.Android.Sample"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibVLCSharp.Android", "LibVLCSharp.Android\LibVLCSharp.Android.csproj", "{D549B545-66FE-42DB-A7F3-34B67F626FB6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibVLCSharp.Android.AWindow", "LibVLCSharp.Android.AWindow\LibVLCSharp.Android.AWindow.csproj", "{239A82A5-19A1-4382-8F9B-4A9705648017}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -89,6 +91,18 @@ Global
{D549B545-66FE-42DB-A7F3-34B67F626FB6}.Release|x64.Build.0 = Release|Any CPU
{D549B545-66FE-42DB-A7F3-34B67F626FB6}.Release|x86.ActiveCfg = Release|Any CPU
{D549B545-66FE-42DB-A7F3-34B67F626FB6}.Release|x86.Build.0 = Release|Any CPU
{239A82A5-19A1-4382-8F9B-4A9705648017}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{239A82A5-19A1-4382-8F9B-4A9705648017}.Debug|Any CPU.Build.0 = Debug|Any CPU
{239A82A5-19A1-4382-8F9B-4A9705648017}.Debug|x64.ActiveCfg = Debug|Any CPU
{239A82A5-19A1-4382-8F9B-4A9705648017}.Debug|x64.Build.0 = Debug|Any CPU
{239A82A5-19A1-4382-8F9B-4A9705648017}.Debug|x86.ActiveCfg = Debug|Any CPU
{239A82A5-19A1-4382-8F9B-4A9705648017}.Debug|x86.Build.0 = Debug|Any CPU
{239A82A5-19A1-4382-8F9B-4A9705648017}.Release|Any CPU.ActiveCfg = Release|Any CPU
{239A82A5-19A1-4382-8F9B-4A9705648017}.Release|Any CPU.Build.0 = Release|Any CPU
{239A82A5-19A1-4382-8F9B-4A9705648017}.Release|x64.ActiveCfg = Release|Any CPU
{239A82A5-19A1-4382-8F9B-4A9705648017}.Release|x64.Build.0 = Release|Any CPU
{239A82A5-19A1-4382-8F9B-4A9705648017}.Release|x86.ActiveCfg = Release|Any CPU
{239A82A5-19A1-4382-8F9B-4A9705648017}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
using System;
namespace VideoLAN.LibVLC.Events
{
/// <summary>LibVLCEvent types</summary>
public enum EventType
{
MediaMetaChanged = 0,
MediaSubItemAdded = 1,
MediaDurationChanged = 2,
MediaParsedChanged = 3,
MediaFreed = 4,
MediaStateChanged = 5,
MediaSubItemTreeAdded = 6,
MediaPlayerMediaChanged = 256,
MediaPlayerNothingSpecial = 257,
MediaPlayerOpening = 258,
MediaPlayerBuffering = 259,
MediaPlayerPlaying = 260,
MediaPlayerPaused = 261,
MediaPlayerStopped = 262,
MediaPlayerForward = 263,
MediaPlayerBackward = 264,
MediaPlayerEndReached = 265,
MediaPlayerEncounteredError = 266,
MediaPlayerTimeChanged = 267,
MediaPlayerPositionChanged = 268,
MediaPlayerSeekableChanged = 269,
MediaPlayerPausableChanged = 270,
MediaPlayerTitleChanged = 271,
MediaPlayerSnapshotTaken = 272,
MediaPlayerLengthChanged = 273,
MediaPlayerVout = 274,
MediaPlayerScrambledChanged = 275,
MediaPlayerESAdded = 276,
MediaPlayerESDeleted = 277,
MediaPlayerESSelected = 278,
MediaPlayerCorked = 279,
MediaPlayerUncorked = 280,
MediaPlayerMuted = 281,
MediaPlayerUnmuted = 282,
MediaPlayerAudioVolume = 283,
MediaPlayerAudioDevice = 284,
MediaPlayerChapterChanged = 285,
MediaListItemAdded = 512,
MediaListWillAddItem = 513,
MediaListItemDeleted = 514,
MediaListWillDeleteItem = 515,
MediaListEndReached = 516,
MediaListViewItemAdded = 768,
MediaListViewWillAddItem = 769,
MediaListViewItemDeleted = 770,
MediaListViewWillDeleteItem = 771,
MediaListPlayerPlayed = 1024,
MediaListPlayerNextItemSet = 1025,
MediaListPlayerStopped = 1026,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_start()</para>
/// </remarks>
MediaDiscovererStarted = 1280,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
MediaDiscovererStopped = 1281,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
RendererDiscovererItemAdded = 1282,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
RendererDiscovererItemDeleted = 1283,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
VlmMediaAdded = 1536,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
VlmMediaRemoved = 1537,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
VlmMediaChanged = 1538,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
VlmMediaInstanceStarted = 1539,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
VlmMediaInstanceStopped = 1540,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
VlmMediaInstanceStatusInit = 1541,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
VlmMediaInstanceStatusOpening = 1542,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
VlmMediaInstanceStatusPlaying = 1543,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
VlmMediaInstanceStatusPause = 1544,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
VlmMediaInstanceStatusEnd = 1545,
/// <remarks>
/// <para>Useless event, it will be triggered only when calling</para>
/// <para>libvlc_media_discoverer_stop()</para>
/// </remarks>
VlmMediaInstanceStatusError = 1546
}
/// <summary>Renderer item</summary>
/// <remarks>
/// <para>This struct is passed by a</para>
/// <para>or deleted.</para>
/// <para>An item is valid until the</para>
/// <para>is called with the same pointer.</para>
/// <para>libvlc_renderer_discoverer_event_manager()</para>
/// </remarks>
/// <summary>A LibVLC event</summary>
public struct LibVLCEvent
{
public EventType Type;
public IntPtr Sender;
public IntPtr RendererItem;
public EventUnion Union;
public struct EventUnion
{
// media
public MediaMetaChanged MediaMetaChanged;
public MediaSubItemAdded MediaSubItemAdded;
public MediaDurationChanged MediaDurationChanged;
public MediaParsedChanged MediaParsedChanged;
public MediaFreed MediaFreed;
public MediaStateChanged MediaStateChanged;
public MediaSubItemTreeAdded MediaSubItemTreeAdded;
// mediaplayer
public MediaPlayerBuffering MediaPlayerBuffering;
public MediaPlayerChapterChanged MediaPlayerChapterChanged;
public MediaPlayerPositionChanged MediaPlayerPositionChanged;
public MediaPlayerTimeChanged MediaPlayerTimeChanged;
public MediaPlayerTitleChanged MediaPlayerTitleChanged;
public MediaPlayerSeekableChanged MediaPlayerSeekableChanged;
public MediaPlayerPausableChanged MediaPlayerPausableChanged;
public MediaPlayerScrambledChanged MediaPlayerScrambledChanged;
public MediaPlayerVoutChanged MediaPlayerVoutChanged;
public MediaPlayerSnapshotTaken MediaPlayerSnapshotTaken;
public MediaPlayerLengthChanged MediaPlayerLengthChanged;
public MediaPlayerMediaChanged MediaPlayerMediaChanged;
public EsChanged EsChanged;
public VolumeChanged MediaPlayerVolumeChanged;
public AudioDeviceChanged AudioDeviceChanged;
// medialist
public MediaListItemAdded MediaListItemAdded;
public MediaListWillAddItem MediaListWillAddItem;
public MediaListItemDeleted MediaListItemDeleted;
public MediaListWillDeleteItem MediaListWillDeleteItem;
public MediaListPlayerNextItemSet MediaListPlayerNextItemSet;
// vlm
public VlmMediaEvent VlmMediaEvent;
}
#region Media
public struct MediaMetaChanged
{
public Media.MetadataType MetaType;
}
public struct MediaSubItemAdded
{
public IntPtr NewChild;
}
public struct MediaDurationChanged
{
public long NewDuration;
}
public struct MediaParsedChanged
{
public Media.MediaParsedStatus NewStatus;
}
public struct MediaFreed
{
public IntPtr MediaInstance;
}
public struct MediaStateChanged
{
public VLCState NewState;
}
public struct MediaSubItemTreeAdded
{
public IntPtr MediaInstance;
}
#endregion
#region MediaPlayer
public struct MediaPlayerBuffering
{
public float NewCache;
}
public struct MediaPlayerChapterChanged
{
public int NewChapter;
}
public struct MediaPlayerPositionChanged
{
public float NewPosition;
}
public struct MediaPlayerTimeChanged
{
public long NewTime;
}
public struct MediaPlayerTitleChanged
{
public int NewTitle;
}
public struct MediaPlayerSeekableChanged
{
public int NewSeekable;
}
public struct MediaPlayerPausableChanged
{
public int NewPausable;
}
public struct MediaPlayerScrambledChanged
{
public int NewScrambled;
}
public struct MediaPlayerVoutChanged
{
public int NewCount;
}
public struct MediaPlayerSnapshotTaken
{
public IntPtr Filename;
}
public struct MediaPlayerLengthChanged
{
public long NewLength;
}
public struct EsChanged
{
public TrackType Type;
public int Id;
}
public struct AudioDeviceChanged
{
public IntPtr Device;
}
public struct MediaPlayerMediaChanged
{
public IntPtr NewMedia;
}
public struct VolumeChanged
{
public float Volume;
}
#endregion
#region MediaList
public struct MediaListItemAdded
{
public IntPtr MediaInstance;
public int Index;
}
public struct MediaListWillAddItem
{
public IntPtr MediaInstance;
public int Index;
}
public struct MediaListItemDeleted
{
public IntPtr MediaInstance;
public int Index;
}
public struct MediaListWillDeleteItem
{
public IntPtr MediaInstance;
public int Index;
}
public struct MediaListPlayerNextItemSet
{
public IntPtr MediaInstance;
}
#endregion MediaList
public struct VlmMediaEvent
{
public IntPtr MediaName;
public IntPtr InstanceName;
}
}
#region Media events
public class MediaMetaChangedEventArgs : EventArgs
{
public readonly Media.MetadataType MetadataType;
public MediaMetaChangedEventArgs(Media.MetadataType metadataType)
{
MetadataType = metadataType;
}
}
public class MediaParsedChangedEventArgs : EventArgs
{
public readonly Media.MediaParsedStatus ParsedStatus;
public MediaParsedChangedEventArgs(Media.MediaParsedStatus parsedStatus)
{
ParsedStatus = parsedStatus;
}
}
public class MediaSubItemAddedEventArgs : EventArgs
{
public readonly Media SubItem;
public MediaSubItemAddedEventArgs(IntPtr mediaPtr)
{
SubItem = new Media(mediaPtr);
}
}
public class MediaDurationChangedEventArgs : EventArgs
{
public readonly long Duration;
public MediaDurationChangedEventArgs(long duration)
{
Duration = duration;
}
}
public class MediaFreedEventArgs : EventArgs
{
public readonly Media Media;
public MediaFreedEventArgs(IntPtr mediaPtr)
{
Media = new Media(mediaPtr);
}
}
public class MediaStateChangedEventArgs : EventArgs
{
public readonly VLCState State;
public MediaStateChangedEventArgs(VLCState state)
{
State = state;
}
}