-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from andy840119/ios-support
iOS support
- Loading branch information
Showing
11 changed files
with
199 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"cake.tool": { | ||
"version": "0.35.0", | ||
"commands": [ | ||
"dotnet-cake" | ||
] | ||
}, | ||
"dotnet-format": { | ||
"version": "3.1.37601", | ||
"commands": [ | ||
"dotnet-format" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"sdk": { | ||
"allowPrerelease": false, | ||
"rollForward": "minor", | ||
"version": "3.1.100" | ||
}, | ||
"msbuild-sdks": { | ||
"MSBuild.Sdk.Extras": "2.0.54", | ||
"Microsoft.Build.Traversal": "2.0.52" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
osu.Framework.Microphone.iOS/Input/IOSMicrophoneHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using AVFoundation; | ||
using Foundation; | ||
using osu.Framework.Input.Handlers.Microphone; | ||
using osu.Framework.Logging; | ||
using osu.Framework.Platform; | ||
|
||
namespace osu.Framework.iOS.Input | ||
{ | ||
public class IOSMicrophoneHandler : OsuTKMicrophoneHandler | ||
{ | ||
public override bool IsActive => throw new System.NotImplementedException(); | ||
|
||
public IOSMicrophoneHandler() : base(-1) | ||
{ | ||
} | ||
|
||
public override bool Initialize(GameHost host) | ||
{ | ||
var session = AVAudioSession.SharedInstance(); | ||
var success = false; | ||
|
||
Logger.Log("Begin Recording", LoggingTarget.Information, LogLevel.Verbose); | ||
|
||
session.RequestRecordPermission((granted) => | ||
{ | ||
Logger.Log($"Audio Permission: {granted}", LoggingTarget.Information); | ||
|
||
if (granted) | ||
{ | ||
session.SetCategory(AVAudioSession.CategoryRecord, out NSError error); | ||
if (error == null) | ||
{ | ||
session.SetActive(true, out error); | ||
if (error != null) | ||
{ | ||
Logger.Log(error.LocalizedDescription, LoggingTarget.Information, LogLevel.Error); | ||
} | ||
else | ||
{ | ||
success = base.Initialize(host); | ||
Logger.Log($"Microphone get permission status : {success}", LoggingTarget.Information); | ||
} | ||
} | ||
else | ||
{ | ||
Logger.Log(error.LocalizedDescription, LoggingTarget.Information, LogLevel.Error); | ||
} | ||
} | ||
else | ||
{ | ||
Logger.Log("YOU MUST ENABLE MICROPHONE PERMISSION", LoggingTarget.Information, LogLevel.Error); | ||
} | ||
}); | ||
|
||
Logger.Log($"Checking : {success}", LoggingTarget.Information, LogLevel.Error); | ||
return success; | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
osu.Framework.Microphone.iOS/osu.Framework.Microphone.iOS.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<Project Sdk="MSBuild.Sdk.Extras"> | ||
<PropertyGroup Label="Project"> | ||
<TargetFramework>xamarinios10</TargetFramework> | ||
<OutputType>Library</OutputType> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<AssemblyName>osu.Framework.Microphone.iOS</AssemblyName> | ||
<RootNamespace>osu.Framework.iOS</RootNamespace> | ||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix> | ||
<Description>Unofficial osu!framework extension for using microphon as input device.</Description> | ||
</PropertyGroup> | ||
<PropertyGroup Label="Nuget"> | ||
<GenerateProgramFile>false</GenerateProgramFile> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<IsPackable>true</IsPackable> | ||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> | ||
<Version>1.0.10</Version> | ||
<RepositoryType>Git</RepositoryType> | ||
<PackageTags>osu-framework microphone andy840119</PackageTags> | ||
<Authors>andy840119</Authors> | ||
<Company>osu!Karaoke</Company> | ||
<Product>osu!Karaoke</Product> | ||
<PackageReleaseNotes>喵</PackageReleaseNotes> | ||
<PackageId>osu.Framework.Microphone.iOS</PackageId> | ||
<NeutralLanguage>en</NeutralLanguage> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="Xamarin.iOS" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\osu.Framework.Microphone\osu.Framework.Microphone.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.722.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<NativeLibs Include="$(MSBuildThisFileDirectory)\*.a" /> | ||
<None Include="@(NativeLibs)"> | ||
<Pack>true</Pack> | ||
<PackageCopyToOutput>true</PackageCopyToOutput> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters