{"id":301,"date":"2018-10-04T03:31:16","date_gmt":"2018-10-03T18:31:16","guid":{"rendered":"https:\/\/www.dogrow.net\/android\/?p=301"},"modified":"2021-03-21T05:41:21","modified_gmt":"2021-03-20T20:41:21","slug":"blog18","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/android\/blog18\/","title":{"rendered":"(18) \u753b\u9762\u30bf\u30c3\u30d7\u3057\u305f\u3089\u97f3\u3092\u9cf4\u3089\u3059\u3002"},"content":{"rendered":"<h1 class=\"my_h\">1. \u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p><span class=\"my_fc_deeppink my_fs_big2\">\u753b\u9762\u3092\u30bf\u30c3\u30d7\u3057\u305f\u3089\u97f3\u3092\u9cf4\u3089\u3057\u305f\u3044\u3002<\/span><\/p>\n<p>\u305d\u308c\u3060\u3051&#8230;<\/p>\n<h1 class=\"my_h\">2. \u3084\u3063\u3066\u307f\u308b\uff01<\/h1>\n<p>\u4eca\u56de\u30ad\u30fc\u3068\u306a\u308b\u8981\u7d20\u306f\u4e09\u3064\u3042\u308b\u3002<br \/>\n(1) \u97f3\u697d\u30d5\u30a1\u30a4\u30eb\u306e\u30ea\u30bd\u30fc\u30b9\u767b\u9332<br \/>\n(2) \u753b\u9762\u30bf\u30c3\u30d7\u306e\u691c\u77e5<br \/>\n(3) \u97f3\u697d\u518d\u751f<\/p>\n<p>Android\u3067\u306f\u3069\u308c\u3082\u7c21\u5358\u306b\u5b9f\u88c5\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u304f\u308c\u3066\u3044\u308b\u3002<\/p>\n<h2 class=\"my_h\">(1) \u97f3\u697d\u30d5\u30a1\u30a4\u30eb\u306e\u30ea\u30bd\u30fc\u30b9\u767b\u9332<\/h2>\n<p>Project\u30da\u30a4\u30f3\u306e res\u914d\u4e0b\u306b <span class=\"my_fc_deeppink\">raw<\/span> \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u308a\u3001\u305d\u3053\u306b MP3\u306a\u308a WAV\u306a\u308a\u3092\u767b\u9332\u3059\u308c\u3070\u3088\u3044\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/android\/wp-content\/uploads\/2018\/10\/001-4.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/android\/wp-content\/uploads\/2018\/10\/002-3.png\" alt=\"\" \/><\/p>\n<p>raw\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3078\u306e\u97f3\u697d\u30d5\u30a1\u30a4\u30eb\u306e\u767b\u9332\u65b9\u6cd5\u306f\u3001drawable\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3078\u306e\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u8ffd\u52a0\u3068\u540c\u3058\u5bb9\u91cf\u3060\u3002<br \/>\nExplorer\u306a\u3069\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30d4\u30fc\u3057\u3001Project\u30da\u30a4\u30f3\u4e0a\u306e raw\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u30da\u30fc\u30b9\u30c8\u3059\u308c\u3070\u3088\u3044\u3002<\/p>\n<h2 class=\"my_h\">(2) \u753b\u9762\u30bf\u30c3\u30d7\u306e\u691c\u77e5<\/h2>\n<p><span class=\"my_fc_deeppink\">onTouchEvent<\/span> \u3067\u901a\u77e5\u3055\u308c\u308b\u3002<br \/>\n\u57fa\u672c\u5f62\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n@Override public boolean onTouchEvent( MotionEvent event ) {\r\n    float x = event.getX();\r\n    float y = event.getY();\r\n    switch (event.getAction()) {\r\n    case MotionEvent.ACTION_DOWN:\r\n       \/\/ \u62bc\u3055\u308c\u305f\u3068\u304d\u306e\u51e6\u7406\u3092\u66f8\u304f\u3002\r\n       break;\r\n    case MotionEvent.ACTION_MOVE:\r\n       \/\/ \u30c9\u30e9\u30c3\u30b0\u3055\u308c\u305f\u3068\u304d\u306e\u51e6\u7406\u3092\u66f8\u304f\u3002\r\n       break;\r\n    case MotionEvent.ACTION_UP:\r\n       \/\/ \u96e2\u3055\u308c\u305f\u3068\u304d\u306e\u51e6\u7406\u3092\u66f8\u304f\u3002\r\n       break;\r\n    }\r\n    return true;\r\n}\r\n<\/pre>\n<h2 class=\"my_h\">(3) \u97f3\u697d\u518d\u751f<\/h2>\n<p><span class=\"my_fc_deeppink\">SoundPool<\/span> \u3092\u4f7f\u3048\u3070\u3088\u3044\u3002<br \/>\n\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nSoundPool soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);\r\nint sound_id = soundPool.load(context, R.raw.mysound, 1);\r\nsoundPool.play(sound_id,  1.0F, 1.0F, 0, 0, 1.0F);\r\n<\/pre>\n<p><a href=\"https:\/\/developer.android.com\/reference\/android\/media\/SoundPool.html#play(int,%20float,%20float,%20int,%20int,%20float)\" target=\"_blank\" rel=\"noopener\">SoundPool\u306e\u4f7f\u3044\u65b9\u306f\u3053\u3061\u3089\u3092\u53c2\u7167\u306e\u3053\u3068\u3002<\/a><\/p>\n<h2 class=\"my_h\">(4) \u5b9f\u88c5<\/h2>\n<p>\u305f\u3063\u305f\u306e\u3053\u308c\u3060\u3051\u3060\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nimport android.media.AudioManager;\r\nimport android.media.SoundPool;\r\nimport android.support.v7.app.AppCompatActivity;\r\nimport android.os.Bundle;\r\nimport android.view.MotionEvent;\r\n\r\npublic class MainActivity extends AppCompatActivity {\r\n    private SoundPool m_soundPool;\r\n    private int m_soundID;\r\n\r\n    @Override protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_main);\r\n\r\n        m_soundPool = new SoundPool(1,AudioManager.STREAM_MUSIC,0);\r\n        m_soundID = m_soundPool.load(this.getApplicationContext(), R.raw.cheer, 1);\r\n    }\r\n\r\n    @Override public boolean onTouchEvent( MotionEvent event ) {\r\n        if(event.getAction() == MotionEvent.ACTION_UP){\r\n            \r\n            m_soundPool.play(m_soundID, 1.0F, 1.0F, 0, 0, 1.0F);    \/\/ \u97f3\u697d\u518d\u751f\r\n        }\r\n        return true;\r\n    }\r\n}\r\n<\/pre>\n<h1 class=\"my_h\">3. \u6240\u611f<\/h1>\n<p>\u30fb\u30b2\u30fc\u30e0\u306e\u52b9\u679c\u97f3\u306b\u306f\u3053\u306e\u65b9\u6cd5\u304c\u4f7f\u3048\u305d\u3046\u3060\u3002<br \/>\n\u30fb\u30a2\u30d7\u30ea\u3092\u4e00\u822c\u516c\u958b\u3059\u308b\u5834\u5408\u3001WEB\u4e0a\u3067\u62fe\u3063\u305f\u97f3\u697d\u30d5\u30a1\u30a4\u30eb\u306e\u4f7f\u7528\u306f\u8457\u4f5c\u6a29\u306b\u6ce8\u610f\u3059\u308b\u3053\u3068\u3002<\/p>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>1. \u3084\u308a\u305f\u3044\u3053\u3068 \u753b\u9762\u3092\u30bf\u30c3\u30d7\u3057\u305f\u3089\u97f3\u3092\u9cf4\u3089\u3057\u305f\u3044\u3002 \u305d\u308c\u3060\u3051&#8230; 2. \u3084\u3063\u3066\u307f\u308b\uff01 \u4eca\u56de\u30ad\u30fc\u3068\u306a\u308b\u8981\u7d20\u306f\u4e09\u3064\u3042\u308b\u3002 (1) \u97f3\u697d\u30d5\u30a1\u30a4\u30eb\u306e\u30ea\u30bd\u30fc\u30b9\u767b\u9332 (2) \u753b\u9762\u30bf\u30c3\u30d7\u306e\u691c\u77e5 (3) \u97f3\u697d\u518d\u751f Andr\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/android\/blog18\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,8],"tags":[],"class_list":["post-301","post","type-post","status-publish","format-standard","hentry","category-9","category-8"],"views":7741,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/posts\/301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/comments?post=301"}],"version-history":[{"count":13,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/posts\/301\/revisions"}],"predecessor-version":[{"id":431,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/posts\/301\/revisions\/431"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/media?parent=301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/categories?post=301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/tags?post=301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}