public void MountObbs(Context context) { if ((int) Android.OS.Build.VERSION.SdkInt >= (int) Android.OS.BuildVersionCodes.Kitkat) { var obbMgr = context.GetSystemService (Context.StorageService).JavaCast<StorageManager> (); var obbs = context.GetObbDirs ().SelectMany (d => Directory.GetFiles (d.Path, "*.obb")); foreach (var obb in obbs.Where (obb => !obbMgr.IsObbMounted (obb))) obbMgr.MountObb (obb, null, new ObbListener ()); } }
public static void GetSoundFonts(IList<string> soundFonts, Context context, string predefinedTempPath, CancellationToken cancellationToken = default (CancellationToken)) { // OBB support if ((int) Android.OS.Build.VERSION.SdkInt >= (int) Android.OS.BuildVersionCodes.Kitkat) { var obbMgr = context.GetSystemService (Context.StorageService).JavaCast<StorageManager> (); var obbs = context.GetObbDirs ().SelectMany (d => Directory.GetFiles (d.Path, "*.obb")); foreach (var obbDir in obbs.Where (d => obbMgr.IsObbMounted (d)).Select (d => obbMgr.GetMountedObbPath (d))) foreach (var sf2 in Directory.GetFiles (obbDir, "*.sf2", SearchOption.AllDirectories)) soundFonts.Add (sf2); } // Assets foreach (var asset in context.Assets.List ("")) if (asset.EndsWith (".sf2", StringComparison.OrdinalIgnoreCase)) soundFonts.Add (asset); #if DEBUG // temporary local files for debugging if (Directory.Exists (predefinedTempPath)) foreach (var sf2 in Directory.GetFiles (predefinedTempPath, "*.sf2", SearchOption.AllDirectories)) if (!soundFonts.Any (_ => Path.GetFileName (_) == Path.GetFileName (sf2))) soundFonts.Add (sf2); #endif }