将mp3声音添加到wikitude AR增强现实中,而不是播放

时间:2013-10-18 01:02:10

标签: javascript augmented-reality wikitude

我不熟悉JavaScript,并希望在wikitude世界开始时添加一个mp3文件,但它不会播放。没有音频,

我使用wikitude网站上的教程添加wikitude作为Android应用程序的一部分。

wikitude sdk课堂声音的文档

http://www.wikitude.com/external/doc/alr/Sound.html

这是音频的代码选择

  streamingSound = new AR.Sound("assets/soundtest.mp3", {
                            onError : errorLoadingSound,
                            onFinishedPlaying : readyToPlay,
                            onLoaded : readyToPlay,
                    });

 streamingSound.load();
 streamingSound.play();

这是文件multiplepois.js的完整代码

 var World = {

  markerDrawable_idle: new AR.ImageResource("assets/lion.png"),

  // New: a second image resource which represents a selected marker
  markerDrawable_selected: new AR.ImageResource("assets/marker_selected.png"),

  // New: a array holding a reference to all marker objects
  markerList: [],

  init: function initFn() {

    AR.context.onLocationChanged = World.onLocationChanged;

    // New: a custom callback which will be invoked when the user taps on an empty  screen space
    AR.context.onScreenClick = World.onScreenClick;
},

  onLocationChanged: function onLocationChangedFn(latitude, longitude, altitude, accuracy) { 

    AR.context.onLocationChanged = null;


    streamingSound = new AR.Sound("assets/soundtest.mp3", {
                            onError : errorLoadingSound,
                            onFinishedPlaying : readyToPlay,
                            onLoaded : readyToPlay,
                    });

  streamingSound.load();
  streamingSound.play();


 }

    // New: Markers are now created using the new operator.
    //      The marker definition is in `marker.js`.
    //      Title, description and location are supplied in the json compatible format
    var poiData = {
        "latitude": 31.580,
        "longitude": 130.545,
        "altitude": altitude,
        "title": "Marker 1",
        "description": "forever office"
    };
    World.markerList.push(new Marker(poiData));

     poiData = {
        "latitude": latitude,
        "longitude": longitude - 0.5,
        "altitude": altitude,
        "title": "Marker 4",
       "description": "West"
    };
   World.markerList.push(new Marker(poiData));
   },

    onScreenClick: function onScreenClickFn() {

    for (var i = World.markerList.length - 1; i >= 0; i--) {
        if (World.markerList[i].isSelected) {
            World.markerList[i].setDeselected(World.markerList[i]);
        }
     }
  }
};

World.init();

1 个答案:

答案 0 :(得分:0)

您可以使用SDK附带的ADE(ade.js)使用桌面浏览器检查任何js错误。 JS错误也将在logcat中在Android上报告。但是根据手机的不同,这可能很难发现。

在桌面浏览器中使用ADE检查代码显示:

Uncaught ReferenceError: errorLoadingSound is not defined

如果您只是想播放声音:

streamingSound = new AR.Sound("assets/soundtest.mp3");
streamingSound.play();

免责声明:我为Wikitude工作