0

i am unfamiliar with JavaScript, and wanted to add an mp3 file to play when the wikitude world starts, however it is not playing. there is no audio,

i used the tutorials on the wikitude website to add wikitude as part of an Android app.

documentation for class sound of wikitude sdk

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

here is the code selection for the audio

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

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

here is the full code for the file 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();
4

1 回答 1

0

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

在桌面浏览器中使用 ADE 检查您的代码会发现:

Uncaught ReferenceError: errorLoadingSound is not defined

如果您只想播放声音:

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

免责声明:我为 Wikitude 工作

于 2013-10-22T07:47:45.183 回答