فهرست منبع

Added a test Sound project to android.

dellis1972 13 سال پیش
والد
کامیت
374ed439a8

+ 1 - 1
Samples/Android/RenderTarget2D/Resources/Resource.designer.cs

@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:4.0.30319.235
+//     Runtime Version:4.0.30319.237
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.

+ 27 - 0
Samples/Android/Sound/Activity1.cs

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

BIN
Samples/Android/Sound/Assets/Content/Explosion1.mp3


+ 36 - 0
Samples/Android/Sound/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 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("Sound")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Sound")]
+[assembly: AssemblyCopyright("Copyright ©  2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a557ce8c-9dbe-4b93-8fc4-95ffc126cf14")]
+
+// 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")]

BIN
Samples/Android/Sound/Resources/Drawable/Icon.png


BIN
Samples/Android/Sound/Resources/Drawable/Splash.png


+ 51 - 0
Samples/Android/Sound/Resources/Resource.Designer.cs

@@ -0,0 +1,51 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.237
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Sound
+{
+	
+	
+	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 Style
+		{
+			
+			// aapt resource value: 0x7f030000
+			public const int Theme_Splash = 2130903040;
+			
+			private Style()
+			{
+			}
+		}
+	}
+}

+ 7 - 0
Samples/Android/Sound/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>

+ 91 - 0
Samples/Android/Sound/Sound.csproj

@@ -0,0 +1,91 @@
+<?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>{E2B6ED3C-A769-47AF-9605-A7410F194B1C}</ProjectGuid>
+    <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Sound</RootNamespace>
+    <AssemblyName>Sound</AssemblyName>
+    <FileAlignment>512</FileAlignment>
+    <AndroidApplication>true</AndroidApplication>
+    <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
+    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;ANDROID</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
+    <AndroidLinkMode>None</AndroidLinkMode>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE;ANDROID</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
+    <AndroidLinkMode>SdkOnly</AndroidLinkMode>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Mono.Android" />
+    <Reference Include="mscorlib" />
+    <Reference Include="OpenTK" />
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="..\..\Linux\Sound\Game1.cs">
+      <Link>Game1.cs</Link>
+    </Compile>
+    <Compile Include="Activity1.cs" />
+    <Compile Include="Resources\Resource.Designer.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <AndroidResource Include="Resources\Drawable\Icon.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <AndroidResource Include="Resources\Drawable\Splash.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <AndroidResource Include="Resources\Values\Styles.xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\..\MonoGame\MonoGame.Framework\MonoGame.Framework.Android.csproj">
+      <Project>{BA9476CF-99BA-4D03-92F2-73D2C5E58883}</Project>
+      <Name>MonoGame.Framework.Android</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\..\MonoGame\ThirdParty\Lidgren.Network\Lidgren.Network.Android.csproj">
+      <Project>{565129E0-4EE5-4F6F-B403-C3484C9740BE}</Project>
+      <Name>Lidgren.Network.Android</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <AndroidAsset Include="..\..\iOS\SpriteFont\Content\SpriteFont1.xnb">
+      <Link>Assets\Content\SpriteFont1.xnb</Link>
+    </AndroidAsset>
+  </ItemGroup>
+  <ItemGroup>
+    <AndroidAsset Include="Assets\Content\Explosion1.mp3" />
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.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>

+ 11 - 3
Samples/Linux/Sound/Game1.cs

@@ -27,7 +27,7 @@ namespace Microsoft.Xna.Samples.Sound
 		SpriteFont font;
 		
 #if ANDROID 
-		public Game1 (Activity activity) : base (activity)
+		public Game1 (AndroidGameActivity activity) : base (activity)
 #else 
         public Game1 ()  
 #endif
@@ -66,7 +66,7 @@ namespace Microsoft.Xna.Samples.Sound
 			// Create a new SpriteBatch, which can be used to draw textures.
 			spriteBatch = new SpriteBatch(GraphicsDevice);
 
-			sound = Content.Load<SoundEffect>("Explosion1");
+			sound = Content.Load<SoundEffect>("explosion1");
 			soundInst = sound.CreateInstance();
 			
 			font = Content.Load<SpriteFont>("spriteFont1");
@@ -80,7 +80,15 @@ namespace Microsoft.Xna.Samples.Sound
 		protected override void Update (GameTime gameTime)
 		{
 			KeyboardState ks = Keyboard.GetState();
-			
+            
+#if ANDROID
+            if (soundInst.State != SoundState.Playing)
+            {
+                soundInst.Volume = 1f;
+                soundInst.IsLooped = true;
+                soundInst.Play();
+            }
+#endif
 			
 			if (ks[Keys.Escape] == KeyState.Down)
 				base.Exit();

+ 8 - 0
Samples/MonoGame.Samples.Android.sln

@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Samples.Peer2Peer.
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Samples.RenderTarget2D.Android", "Android\RenderTarget2D\MonoGame.Samples.RenderTarget2D.Android.csproj", "{DEDD20B5-8F83-46FD-AD05-8F8FCC49FCD6}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sound", "Android\Sound\Sound.csproj", "{E2B6ED3C-A769-47AF-9605-A7410F194B1C}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -43,6 +45,12 @@ Global
 		{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
+		{E2B6ED3C-A769-47AF-9605-A7410F194B1C}.Release|Any CPU.Deploy.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE