<commit_before>﻿using Android.Media;
using System;
using System.Collections.Generic;

namespace KabeDon.XamarinForms.Droid
{
    class AndroidSoundPlayer : ISoundPlayer
    {
        // 数チャネル同時再生できるようにする？
        private readonly Dictionary<string, MediaPlayer>  _players = new Dictionary<string, MediaPlayer>();

        public void Play(string path)
        {
            try
            {
                MediaPlayer player;
            if (!_players.TryGetValue(path, out player))
            {
                player = new MediaPlayer();
                player.SetAudioStreamType(Stream.Music);
                player.SetDataSource(path);
                player.Prepare();
                    _players.Add(path, player);
            }

                if (player.IsPlaying)
                {
                    player.Stop();
                }
                player.Reset();
                player.Start();
            }
            catch (Exception ex)
            {

            }
        }<commit_msg>AndroidSoundPlayer を SoundPool に変更<commit_after>﻿using Android.Media;
using System;
using System.Collections.Generic;

namespace KabeDon.XamarinForms.Droid
{
    class AndroidSoundPlayer : ISoundPlayer
    {
        private SoundPool _pool = new SoundPool(20, Stream.Music, 0);
        private readonly Dictionary<string, int>  _soundIds = new Dictionary<string, int>();

        public void Play(string path)
        {
            try
            {
                int id;
                if (!_soundIds.TryGetValue(path, out id))
                {
                    id = _pool.Load(path, 1);
                    _soundIds.Add(path, id);
                }
                _pool.Play(id, 1, 1, 1, 0, 1);
            }
            catch (Exception ex)
            {

            }
        }
{'fraction_non_alphanumeric': 0.08823529411764706, 'fraction_numerical': 0.004994450610432853, 'mean_word_length': 1.3661417322834646, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2501185', 'n_tokens_mistral': 493, 'n_tokens_neox': 462, 'n_words': 101}