{"id":1828,"date":"2020-04-17T18:01:00","date_gmt":"2020-04-17T09:01:00","guid":{"rendered":"https:\/\/www.itchefblog.com\/?p=1828"},"modified":"2021-04-22T03:02:16","modified_gmt":"2021-04-21T18:02:16","slug":"%ec%82%ac%ec%9a%b4%eb%93%9c-%ec%9e%ac%ec%83%9d%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/www.itchefblog.com\/?p=1828","title":{"rendered":"\uc0ac\uc6b4\ub4dc \uc7ac\uc0dd\ud558\uae30"},"content":{"rendered":"\n<p>MediaPlayer \ud074\ub798\uc2a4\uc640 SoundPool \ud074\ub798\uc2a4\ub97c \uc774\uc6a9\ud560 \uc218 \uc788\uc73c\uba70, MediaPlayer \ud074\ub798\uc2a4\uc758 \uacbd\uc6b0 \uc18c\ub9ac\ub97c \ud55c \ubc88\ub9cc \uc7ac\uc0dd\ud558\ub294 \uacbd\uc6b0 \ub610\ub294 \ub178\ub798\ub098 \ubc30\uacbd\uc74c \ub4f1\uc758 \uacbd\uc6b0 \uc720\uc6a9\ud558\ub2e4.<br>\uc545\uae30\uc640 \uac19\uc774 \uc5f0\uc18d\uc73c\ub85c \uc18c\ub9ac\ub97c \uc7ac\uc0dd\ud558\ub294 \uacbd\uc6b0\uc5d0\ub294 SoundPool \ud074\ub798\uc2a4\uac00 \ub354 \uc720\uc6a9\ud558\ub2e4.<\/p>\n\n\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/MediaPlayer \ud074\ub798\uc2a4\ub85c \uc0ac\uc6b4\ub4dc \uc7ac\uc0dd\ud558\uae30\nval mediaPlayer = MediaPlayer.create(this, R.row.do1)\nbutton.setOnClickListener{ mediaPlayer.start() }\n\n\/\/\uc0ac\uc6a9\uc774 \ub05d\ub098\uba74 \ubc18\ub4dc\uc2dc \ub9b4\ub9ac\uc988 \ud574\uc57c\ud568\nmediaPlater.release()\n<\/pre>\n\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/SoundPool \ud074\ub798\uc2a4\ub85c \uc0ac\uc6b4\ub4dc \uc7ac\uc0dd\ud558\uae30 (setMaxStreams\ub294 \ucd5c\ub300 \ub3d9\uc2dc \ud50c\ub808\uc774 \uac00\ub2a5\ud55c \uc74c\uc6d0 \uac2f\uc218)\nval soundPool = SoundPool.Builder().setMaxStreams(8).build()\n\nval soundId = soundPool.load(this, R.row.do1, 1)\nbutton.setOnClickListener{ soundPool.play(soundId, 1.0f, 10f, 0, 1.0f) }\n\n\/\/load\uc758 \uc6d0\ud615\nload(context: Context, redId: Int, priority: Int)\n\/\/\ucee8\ud14d\uc2a4\ud2b8 \uc9c0\uc815, \uc7ac\uc0dd\ud560 row \ub514\ub809\ud1a0\ub9ac\uc758 \uc18c\ub9ac \ud30c\uc77c \ub9ac\uc18c\uc2a4, \uc6b0\uc120\uc21c\uc704 (\uc22b\uc790\uac00 \ub192\uc73c\uba74 \uc6b0\uc120\uc21c\uc704\uac00 \ub192\ub2e4)\n\n\/\/play\uc758 \uc6d0\ud615\nplay(soundId: Int, leftVolume: Float, rightVolume: Float, priority: Int, loop: Int, rate: Float)\n\/\/load()\uc5d0\uc11c \ubc18\ud658\ub41c \uc74c\uc6d0\uc758 id, \uc67c\ucabd \ubcfc\ub968 0.0~1.0\uc0ac\uc774, \uc624\ub978\ucabd \ubcfc\ub968\ub3c4 \ub9c8\ucc2c\uac00\uc9c0, \uc6b0\uc120\uc21c\uc704 (0\uc774 \uac00\uc7a5 \ub0ae\uc74c),\n\/\/\ubc18\ubcf5 \uc9c0\uc815 (0\uc774\uba74 \ubc18\ubcf5\ub178\ub178, -1\uc774\uba74 \ubc18\ubcf5), \uc7ac\uc0dd\uc18d\ub3c4 (1.0\uc774\uba74 \ubcf4\ud1b5, 0.5\uc774\uba74 0.5\ubc30\ubaa9, 2.0\uc774\uba74 2\ubc30\uc18d)\n<\/pre>\n\n\n<p>\ubc84\uc804\ubcc4 \ubd84\uae30<\/p>\n\n\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nprivate val soundPool = if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP) {\n    SoundPool.Builder().setMaxStreams(8).build()\n} else {\n    SoundPool(8, AudioManager.STREAM_MUSIC, 0)\n}\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>MediaPlayer \ud074\ub798\uc2a4\uc640 SoundPool \ud074\ub798\uc2a4\ub97c \uc774\uc6a9\ud560 \uc218 \uc788\uc73c\uba70, MediaPlayer \ud074\ub798\uc2a4\uc758 \uacbd\uc6b0 \uc18c\ub9ac\ub97c \ud55c \ubc88\ub9cc \uc7ac\uc0dd\ud558\ub294 \uacbd\uc6b0 \ub610\ub294 \ub178\ub798\ub098 \ubc30\uacbd\uc74c \ub4f1\uc758 \uacbd\uc6b0 \uc720\uc6a9\ud558\ub2e4.\uc545\uae30\uc640 \uac19\uc774 \uc5f0\uc18d\uc73c\ub85c \uc18c\ub9ac\ub97c \uc7ac\uc0dd\ud558\ub294 \uacbd\uc6b0\uc5d0\ub294 SoundPool \ud074\ub798\uc2a4\uac00 \ub354 \uc720\uc6a9\ud558\ub2e4. \ubc84\uc804\ubcc4 \ubd84\uae30<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[349,372,7,4],"tags":[],"_links":{"self":[{"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1828"}],"collection":[{"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1828"}],"version-history":[{"count":1,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1828\/revisions"}],"predecessor-version":[{"id":1829,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1828\/revisions\/1829"}],"wp:attachment":[{"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}