4

在 Tizen 应用程序中,我想在发布通知时播放音频文件,并且我编写了以下代码。

function postNotification()
{
    try {
        var iconPath=tizen.application.getCurrentApplication().appInfo.iconPath;
          var myappInfo = tizen.application.getAppInfo();
          var myAudio = document.getElementById('myAudio');
          var notificationDict = {
                      content : "Alarm Playing",
                      iconPath : iconPath,
                      soundPath : "ab.mp3", 
                      vibration : true, 
                      thumbnails : "icon.png",
                      ledColor : "#FFFF00",
                      ledOnPeriod: 10000,
                      ledOffPeriod : 5000 ,
                      appId : myappInfo.id };  
          var myNotification = new tizen.StatusNotification("SIMPLE", "Simple notification", notificationDict);
          tizen.notification.post(myNotification);

     } catch (err) {
          alert(err.name + ": " + err.message);
     }
}

文件 ab.mp3 与 js 文件位于同一文件夹中。但它没有播放该音频。任何人都可以帮忙吗?

4

1 回答 1

0

如果它在 js 文件夹中,则路径应为:

soundPath : "js/ab.mp3"

因为默认路径是“项目根”文件夹,你必须添加资源的文件夹名称,就像我们在 index.html 中所做的那样:

<script src="js/main.js"></script>
于 2017-08-04T10:41:43.863 回答