본문 바로가기
기타/프로그래밍 관련

Android JQuery HTML5 Audio Tag(Click Event Effect)

by WebHack 2012. 9. 11.

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1" />

<title>jQuery UI Example Page</title>

<script type="text/javascript" src="/android_asset/www/cordova-2.0.0.js"></script>

<script type="text/javascript" src="/android_asset/www/jquery_ui/js/jquery-1.8.0.min.js"></script>

<script type="text/javascript" src="/android_asset/www/jquery_ui/development-bundle/ui/jquery.ui.core.js"></script>

        <script type="text/javascript" src="/android_asset/www/jquery_ui/development-bundle/ui/jquery.ui.widget.js"></script>

        <script type="text/javascript" src="/android_asset/www/jquery_ui/development-bundle/ui/jquery.ui.accordion.js"></script>

        <link rel="stylesheet" type="text/css" href="/android_asset/www/jquery_ui/development-bundle/themes/start/jquery.ui.all.css">

        <script>

        function onDeviceReady()

            {

        alert("Device 준비 완료");

        $(document).ready(function() {  

        alert("HTML 문서 준비 완료");

       

        //HTML5 Audio Tag 1/2

        //HTML5 Audio Tag 사용은 src가 무조건 http로 해야함

        //var audio = '<audio id="letter_audio" src="http://192.168.0.99/kids/Jquery_Test/jquery_ui/sound/click.wav" type="audio/wav" preload="auto"></audio>';

        //$('body').append(audio);

       

        //Phonegap(DroidGap)을 이용한 클릭 이벤트 1/2

        //Local에서 하기 위해서는 Media 이용(꼭 cordova-2.0.0.js) 필요

        var myMedia = new Media("/android_asset/www/jquery_ui/sound/click.wav");

       

$('a.click').click(function(){

//HTML5 Audio Tag 2/2

  //$("#letter_audio")[0].play();

//Phonegap(DroidGap)을 이용한 클릭 이벤트 1/2

myMedia.play();

//false로 하면 아코디언이 안 펴짐 return 생략을 하면 true임

return true;

});

  

// Accordion

$("#accordion").accordion({ header: "h3" });

        });

}

        document.addEventListener("deviceready", onDeviceReady, true);

</script>

</head>

<body>

    

<!-- Accordion -->

<h2 class="demoHeaders">Accordion</h2>

<div id="accordion">

<div>

<h3><a href="#" class="click">First</a></h3>

<div>Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.</div>

</div>

<div>

<h3><a href="#" class="click">Second</a></h3>

<div>Phasellus mattis tincidunt nibh.</div>

</div>

<div>

<h3><a href="#" class="click">Third</a></h3>

<div>Nam dui erat, auctor a, dignissim quis.</div>

</div>

</div>


</body>

</html>