2
0
Эх сурвалжийг харах

Ported VideoPlayer sample to Android

CartBlanche 13 жил өмнө
parent
commit
08d16a364f

+ 26 - 0
Samples/Android/VideoPlayer/Activity1.cs

@@ -0,0 +1,26 @@
+using System;
+
+using Android.App;
+using Android.Content;
+using Android.Runtime;
+using Android.Views;
+using Android.Widget;
+using Android.OS;
+
+namespace MonoGame.Samples.VideoPlayer
+{
+	[Activity(Label = "VideoPlayer", MainLauncher = true, Icon = "@drawable/icon", Theme = "@style/Theme.Splash")]
+    public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity
+    {
+        protected override void OnCreate(Bundle bundle)
+        {
+            base.OnCreate(bundle);
+            Game1.Activity = this;
+            var g = new Game1();
+            SetContentView(g.Window);
+            g.Run();
+        }
+    }
+}
+
+

+ 19 - 0
Samples/Android/VideoPlayer/Assets/AboutAssets.txt

@@ -0,0 +1,19 @@
+Any raw assets you want to be deployed with your application can be placed in
+this directory (and child directories) and given a Build Action of "AndroidAsset".
+
+These files will be deployed with you package and will be accessible using Android's
+AssetManager, like this:
+
+public class ReadAsset : Activity
+{
+	protected override void OnCreate (Bundle bundle)
+	{
+		base.OnCreate (bundle);
+
+		InputStream input = Assets.Open ("my_asset.txt");
+	}
+}
+
+Additionally, some Android functions will automatically load asset files:
+
+Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");

+ 81 - 0
Samples/Android/VideoPlayer/MonoGame.Samples.VideoPlayer.csproj

@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>10.0.0</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{27C3DD7C-5322-4C2D-8EE4-07610390CDAF}</ProjectGuid>
+    <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <OutputType>Library</OutputType>
+    <RootNamespace>MonoGame.Samples.VideoPlayer</RootNamespace>
+    <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
+    <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
+    <AndroidResgenClass>Resource</AndroidResgenClass>
+    <AndroidApplication>True</AndroidApplication>
+    <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
+    <AssemblyName>MonoGame.Samples.VideoPlayer</AssemblyName>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+    <AndroidLinkMode>None</AndroidLinkMode>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+    <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
+    <AndroidLinkMode>SdkOnly</AndroidLinkMode>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Xml" />
+    <Reference Include="System.Core" />
+    <Reference Include="Mono.Android" />
+    <Reference Include="OpenTK" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Activity1.cs" />
+    <Compile Include="Resources\Resource.designer.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="..\..\MacOS\VideoPlayer\Game1.cs">
+      <Link>Game1.cs</Link>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Resources\AboutResources.txt" />
+    <None Include="Assets\AboutAssets.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <AndroidResource Include="Resources\layout\Main.axml" />
+    <AndroidResource Include="Resources\values\Strings.xml" />
+    <AndroidResource Include="Resources\drawable\Icon.png" />
+    <AndroidResource Include="Resources\drawable\Splash.png" />
+    <AndroidResource Include="Resources\values\Styles.xml" />
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
+  <ItemGroup>
+    <AndroidAsset Include="..\..\MacOS\VideoPlayer\Content\spriteFont1.xnb">
+      <Link>Assets\Content\spriteFont1.xnb</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\MacOS\VideoPlayer\Content\sintel_trailer.3gp">
+      <Link>Assets\Content\sintel_trailer.3gp</Link>
+    </AndroidAsset>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\..\MonoGame\MonoGame.Framework\MonoGame.Framework.Android.csproj">
+      <Project>{BA9476CF-99BA-4D03-92F2-73D2C5E58883}</Project>
+      <Name>MonoGame.Framework.Android</Name>
+    </ProjectReference>
+  </ItemGroup>
+</Project>

+ 27 - 0
Samples/Android/VideoPlayer/Properties/AssemblyInfo.cs

@@ -0,0 +1,27 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes. 
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("MonoGame.Samples.VideoPlayer")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Savage Software Solutions Ltd.")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("Savage Software Solutions Ltd.")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly, 
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+

+ 44 - 0
Samples/Android/VideoPlayer/Resources/AboutResources.txt

@@ -0,0 +1,44 @@
+Images, layout descriptions, binary blobs and string dictionaries can be included 
+in your application as resource files.  Various Android APIs are designed to 
+operate on the resource IDs instead of dealing with images, strings or binary blobs 
+directly.
+
+For example, a sample Android app that contains a user interface layout (main.axml),
+an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) 
+would keep its resources in the "Resources" directory of the application:
+
+Resources/
+    drawable/
+        icon.png
+
+    layout/
+        main.axml
+
+    values/
+        strings.xml
+
+In order to get the build system to recognize Android resources, set the build action to
+"AndroidResource".  The native Android APIs do not operate directly with filenames, but 
+instead operate on resource IDs.  When you compile an Android application that uses resources, 
+the build system will package the resources for distribution and generate a class called "R" 
+(this is an Android convention) that contains the tokens for each one of the resources 
+included. For example, for the above Resources layout, this is what the R class would expose:
+
+public class R {
+    public class drawable {
+        public const int icon = 0x123;
+    }
+
+    public class layout {
+        public const int main = 0x456;
+    }
+
+    public class strings {
+        public const int first_string = 0xabc;
+        public const int second_string = 0xbcd;
+    }
+}
+
+You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main 
+to reference the layout/main.axml file, or R.strings.first_string to reference the first 
+string in the dictionary file values/strings.xml.

+ 73 - 0
Samples/Android/VideoPlayer/Resources/Resource.designer.cs

@@ -0,0 +1,73 @@
+// ------------------------------------------------------------------------------
+//  <autogenerated>
+//      This code was generated by a tool.
+//      Mono Runtime Version: 4.0.30319.1
+// 
+//      Changes to this file may cause incorrect behavior and will be lost if 
+//      the code is regenerated.
+//  </autogenerated>
+// ------------------------------------------------------------------------------
+
+namespace MonoGame.Samples.VideoPlayer
+{
+	
+	
+	public partial class Resource
+	{
+		
+		public partial class Attribute
+		{
+			
+			private Attribute()
+			{
+			}
+		}
+		
+		public partial class Drawable
+		{
+			
+			// aapt resource value: 0x7f020000
+			public const int Icon = 2130837504;
+			
+			// aapt resource value: 0x7f020001
+			public const int Splash = 2130837505;
+			
+			private Drawable()
+			{
+			}
+		}
+		
+		public partial class Layout
+		{
+			
+			// aapt resource value: 0x7f030000
+			public const int Main = 2130903040;
+			
+			private Layout()
+			{
+			}
+		}
+		
+		public partial class String
+		{
+			
+			// aapt resource value: 0x7f040000
+			public const int app_name = 2130968576;
+			
+			private String()
+			{
+			}
+		}
+		
+		public partial class Style
+		{
+			
+			// aapt resource value: 0x7f050000
+			public const int Theme_Splash = 2131034112;
+			
+			private Style()
+			{
+			}
+		}
+	}
+}

BIN
Samples/Android/VideoPlayer/Resources/drawable/Icon.png


BIN
Samples/Android/VideoPlayer/Resources/drawable/Splash.png


+ 8 - 0
Samples/Android/VideoPlayer/Resources/layout/Main.axml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    >
+</LinearLayout>
+

+ 4 - 0
Samples/Android/VideoPlayer/Resources/values/Strings.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+	<string name="app_name">MonoGame.Samples.VideoPlayer</string>
+</resources>

+ 7 - 0
Samples/Android/VideoPlayer/Resources/values/Styles.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <style name="Theme.Splash" parent="android:Theme">
+    <item name="android:windowBackground">@drawable/splash</item>
+    <item name="android:windowNoTitle">true</item>
+  </style>
+</resources>

+ 22 - 16
Samples/MonoGame.Samples.Android.sln

@@ -15,47 +15,53 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Samples.RenderTarg
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sound", "Android\Sound\Sound.csproj", "{E2B6ED3C-A769-47AF-9605-A7410F194B1C}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Samples.VideoPlayer", "Android\VideoPlayer\MonoGame.Samples.VideoPlayer.csproj", "{27C3DD7C-5322-4C2D-8EE4-07610390CDAF}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Release|Any CPU = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{27C3DD7C-5322-4C2D-8EE4-07610390CDAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{27C3DD7C-5322-4C2D-8EE4-07610390CDAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{27C3DD7C-5322-4C2D-8EE4-07610390CDAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{27C3DD7C-5322-4C2D-8EE4-07610390CDAF}.Release|Any CPU.Build.0 = Release|Any CPU
 		{565129E0-4EE5-4F6F-B403-C3484C9740BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{565129E0-4EE5-4F6F-B403-C3484C9740BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{565129E0-4EE5-4F6F-B403-C3484C9740BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{565129E0-4EE5-4F6F-B403-C3484C9740BE}.Release|Any CPU.Build.0 = Release|Any CPU
-		{BA9476CF-99BA-4D03-92F2-73D2C5E58883}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{BA9476CF-99BA-4D03-92F2-73D2C5E58883}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{BA9476CF-99BA-4D03-92F2-73D2C5E58883}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{BA9476CF-99BA-4D03-92F2-73D2C5E58883}.Release|Any CPU.Build.0 = Release|Any CPU
-		{F05F90DC-DD37-4967-A96A-8D36C1C23E81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{F05F90DC-DD37-4967-A96A-8D36C1C23E81}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{F05F90DC-DD37-4967-A96A-8D36C1C23E81}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{F05F90DC-DD37-4967-A96A-8D36C1C23E81}.Release|Any CPU.Build.0 = Release|Any CPU
-		{616BBFA6-52F2-40A1-AA76-1CF2BD6390D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{616BBFA6-52F2-40A1-AA76-1CF2BD6390D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{616BBFA6-52F2-40A1-AA76-1CF2BD6390D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{616BBFA6-52F2-40A1-AA76-1CF2BD6390D5}.Release|Any CPU.Build.0 = Release|Any CPU
 		{56F6C06F-6F07-402E-89A5-39EDB037A516}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{56F6C06F-6F07-402E-89A5-39EDB037A516}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{56F6C06F-6F07-402E-89A5-39EDB037A516}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{56F6C06F-6F07-402E-89A5-39EDB037A516}.Release|Any CPU.Build.0 = Release|Any CPU
+		{616BBFA6-52F2-40A1-AA76-1CF2BD6390D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{616BBFA6-52F2-40A1-AA76-1CF2BD6390D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{616BBFA6-52F2-40A1-AA76-1CF2BD6390D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{616BBFA6-52F2-40A1-AA76-1CF2BD6390D5}.Release|Any CPU.Build.0 = Release|Any CPU
+		{BA9476CF-99BA-4D03-92F2-73D2C5E58883}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{BA9476CF-99BA-4D03-92F2-73D2C5E58883}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{BA9476CF-99BA-4D03-92F2-73D2C5E58883}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{BA9476CF-99BA-4D03-92F2-73D2C5E58883}.Release|Any CPU.Build.0 = Release|Any CPU
 		{DEDD20B5-8F83-46FD-AD05-8F8FCC49FCD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{DEDD20B5-8F83-46FD-AD05-8F8FCC49FCD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{DEDD20B5-8F83-46FD-AD05-8F8FCC49FCD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{DEDD20B5-8F83-46FD-AD05-8F8FCC49FCD6}.Release|Any CPU.Build.0 = Release|Any CPU
 		{E2B6ED3C-A769-47AF-9605-A7410F194B1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{E2B6ED3C-A769-47AF-9605-A7410F194B1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{E2B6ED3C-A769-47AF-9605-A7410F194B1C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
 		{E2B6ED3C-A769-47AF-9605-A7410F194B1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{E2B6ED3C-A769-47AF-9605-A7410F194B1C}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F05F90DC-DD37-4967-A96A-8D36C1C23E81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F05F90DC-DD37-4967-A96A-8D36C1C23E81}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F05F90DC-DD37-4967-A96A-8D36C1C23E81}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F05F90DC-DD37-4967-A96A-8D36C1C23E81}.Release|Any CPU.Build.0 = Release|Any CPU
+		{E2B6ED3C-A769-47AF-9605-A7410F194B1C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
 		{E2B6ED3C-A769-47AF-9605-A7410F194B1C}.Release|Any CPU.Deploy.0 = Release|Any CPU
 	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
 	GlobalSection(MonoDevelopProperties) = preSolution
 		StartupItem = ..\..\MonoGame\ThirdParty\Lidgren.Network\Lidgren.Network.Android.csproj
 	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
 EndGlobal