<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0" />
<title>Sample</title>
<script src="cordova-2.7.0.js" type="text/javascript"></script>
<script src="tts.js" type="text/javascript"></script>
<style type="text/css">
.auto-style1 {
text-align: center;
}
</style>
</head>
<body onload="onLoaded()">
<div class="info" style="font-size:12px">TTS TEST</div>
<script>
function onLoaded() {
alert('onLoaded');
document.addEventListener("deviceready", onDeviceReady, false);
}

function onDeviceReady(){
alert('onDeviceReady');
window.requestFileSystem(LocalFileSystem.PERSISTENT,0, gotFS, fail);
}

function gotFS(fileSystem){
alert('gotFS');
fileSystem.root.getDirectory("Android/data/com.example.tts/app_new_file",{create:true}, gotDir,fail);
}
function gotDir(dirEntry){
alert('gotDir');
dirEntry.getFile("GodIsGood2.txt",{create:true, exclusive:true}, gotFile,fail);
}

function gotFile(fileEntry){
alert('成功建立檔');
fileEntry.createWriter(onGetFileWriterSuccess, onGetFileWriterError);
}
function onGetFileWriterSuccess(writer){
writer.onwrite=onWriteSuccess;
writer.onerror=onWriteError;
writer.write("Some text to the file");
}
function onGetFileWriterError(err){
alert('onGetFileWriterError...'+err.code);
}
function onWriteSuccess(evt){
alert('YES!! DONE!');
}

function onWriteError(evt){
alert('onWriteError...'+evt.target.error.code);
}
function fail(evt){
alert(evt.error.code);
}
</script>
</body>
</html>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 amychang2014 的頭像
    amychang2014

    工作需要筆記

    amychang2014 發表在 痞客邦 留言(0) 人氣()