Skip to content

Commit 25c4bc5

Browse files
committed
Add new ExoPlayer Modules
1 parent 6e6ee35 commit 25c4bc5

14 files changed

+184
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Additions allow you to add arbitrary C# to the generated classes
2+
before they are compiled. This can be helpful for providing convenience
3+
methods or adding pure C# classes.
4+
5+
== Adding Methods to Generated Classes ==
6+
7+
Let's say the library being bound has a Rectangle class with a constructor
8+
that takes an x and y position, and a width and length size. It will look like
9+
this:
10+
11+
public partial class Rectangle
12+
{
13+
public Rectangle (int x, int y, int width, int height)
14+
{
15+
// JNI bindings
16+
}
17+
}
18+
19+
Imagine we want to add a constructor to this class that takes a Point and
20+
Size structure instead of 4 ints. We can add a new file called Rectangle.cs
21+
with a partial class containing our new method:
22+
23+
public partial class Rectangle
24+
{
25+
public Rectangle (Point location, Size size) :
26+
this (location.X, location.Y, size.Width, size.Height)
27+
{
28+
}
29+
}
30+
31+
At compile time, the additions class will be added to the generated class
32+
and the final assembly will a Rectangle class with both constructors.
33+
34+
35+
== Adding C# Classes ==
36+
37+
Another thing that can be done is adding fully C# managed classes to the
38+
generated library. In the above example, let's assume that there isn't a
39+
Point class available in Java or our library. The one we create doesn't need
40+
to interact with Java, so we'll create it like a normal class in C#.
41+
42+
By adding a Point.cs file with this class, it will end up in the binding library:
43+
44+
public class Point
45+
{
46+
public int X { get; set; }
47+
public int Y { get; set; }
48+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<AssemblyName>ExoPlayer.Container</AssemblyName>
4+
<RootNamespace>ExoPlayer.Container</RootNamespace>
5+
<Description>Xamarin bindings for ExoPlayer</Description>
6+
<PackageId>Xam.Plugins.Android.ExoPlayer.Container</PackageId>
7+
</PropertyGroup>
8+
</Project>
22.1 KB
Binary file not shown.
18.6 KB
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<enum-field-mappings>
2+
<!--
3+
This example converts the constants Fragment_id, Fragment_name,
4+
and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
5+
to an enum called Android.Support.V4.App.FragmentTagType with values
6+
Id, Name, and Tag.
7+
8+
<mapping jni-class="android/support/v4/app/FragmentActivity$FragmentTag" clr-enum-type="Android.Support.V4.App.FragmentTagType">
9+
<field jni-name="Fragment_name" clr-name="Name" value="0" />
10+
<field jni-name="Fragment_id" clr-name="Id" value="1" />
11+
<field jni-name="Fragment_tag" clr-name="Tag" value="2" />
12+
</mapping>
13+
-->
14+
</enum-field-mappings>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<enum-method-mappings>
2+
<!--
3+
This example changes the Java method:
4+
android.support.v4.app.Fragment.SavedState.writeToParcel (int flags)
5+
to be:
6+
android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags)
7+
when bound in C#.
8+
9+
<mapping jni-class="android/support/v4/app/Fragment.SavedState">
10+
<method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
11+
</mapping>
12+
-->
13+
</enum-method-mappings>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<metadata>
2+
<!--
3+
This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
4+
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
5+
6+
This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
7+
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
8+
-->
9+
</metadata>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Additions allow you to add arbitrary C# to the generated classes
2+
before they are compiled. This can be helpful for providing convenience
3+
methods or adding pure C# classes.
4+
5+
== Adding Methods to Generated Classes ==
6+
7+
Let's say the library being bound has a Rectangle class with a constructor
8+
that takes an x and y position, and a width and length size. It will look like
9+
this:
10+
11+
public partial class Rectangle
12+
{
13+
public Rectangle (int x, int y, int width, int height)
14+
{
15+
// JNI bindings
16+
}
17+
}
18+
19+
Imagine we want to add a constructor to this class that takes a Point and
20+
Size structure instead of 4 ints. We can add a new file called Rectangle.cs
21+
with a partial class containing our new method:
22+
23+
public partial class Rectangle
24+
{
25+
public Rectangle (Point location, Size size) :
26+
this (location.X, location.Y, size.Width, size.Height)
27+
{
28+
}
29+
}
30+
31+
At compile time, the additions class will be added to the generated class
32+
and the final assembly will a Rectangle class with both constructors.
33+
34+
35+
== Adding C# Classes ==
36+
37+
Another thing that can be done is adding fully C# managed classes to the
38+
generated library. In the above example, let's assume that there isn't a
39+
Point class available in Java or our library. The one we create doesn't need
40+
to interact with Java, so we'll create it like a normal class in C#.
41+
42+
By adding a Point.cs file with this class, it will end up in the binding library:
43+
44+
public class Point
45+
{
46+
public int X { get; set; }
47+
public int Y { get; set; }
48+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<AssemblyName>ExoPlayer.Muxer</AssemblyName>
4+
<RootNamespace>ExoPlayer.Muxer</RootNamespace>
5+
<Description>Xamarin bindings for ExoPlayer</Description>
6+
<PackageId>Xam.Plugins.Android.ExoPlayer.Muxer</PackageId>
7+
</PropertyGroup>
8+
</Project>
34.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)