2013-10-18 63 views
0

我對JavaScript不熟悉,並且想要在wikitude世界開始時添加一個mp3文件,但它不會播放。沒有音頻,將mp3音頻添加到wikitude AR增強現實中,不播放

我使用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(); 

回答

0

您可以使用包含ADE(ade.js)與SDK使用桌面瀏覽器檢查任何js錯誤。 JS中的錯誤也會在logcat上的Android上報告。然而,根據手機,這可能很難發現。

檢查與桌面瀏覽器的ADE你的代碼表明:

Uncaught ReferenceError: errorLoadingSound is not defined 

如果你只是想播放的聲音:

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

聲明:我Wikitude

工作