Problems under android 5.0

  • 1
  • Question
  • Updated 4 years ago
I have made a game for android using html, css and javascript, whit phonegap build.
It runs really well in android 5.0+ but under that versions, it has some problems like dont play the mp3 files, dont positioning correctly some elements that Iposition with javascript, and dont create an element to add a click event that I create with javascript too.
It seems like my javascript file doesnt work well under android 5.0.
any help?
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes
how can I do that?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
function goLoop(status) { 

if (status === Media.MEDIA_STOPPED) {
my_media2.play();
}
}

var my_media1 = new Media(firstAudioUrl, false, false, goLoop);
var my_media2 = new Media(secondAudioUrl, false, false, goLoop);
my_media1.play();
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes
it doesnt even play a sound

var my_media = null;
var my_media2 = null;
// Wait for PhoneGap to load
document.addEventListener("deviceready", goLoop, false);

function goLoop(status) {
if (status === Media.MEDIA_STOPPED) {
my_media2.play();
}
}
var my_media = new Media("/android_asset/www/sounds/indexstart.mp3", null, null, goLoop);
var my_media2 = new Media("/android_asset/www/sounds/indexloop.mp3", null, null, goLoop);
my_media.play();
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes
I change that "false" parameters to "null" as you can see and it doesnt work either.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Sorry. I thought the snippet would be sufficient for you to understand the intention of the loop and its callback.

Here is the full example:



document.addEventListener("deviceready", onDeviceReady, false);

var my_media;
var my_media2;

function goLoop(status) {
if (status === Media.MEDIA_STOPPED) {
my_media2.play();
}
}

function onDeviceReady() {
firstAudioUrl= "/android_asset/www/sounds/indexstart.mp3";
secondAudioUrl= "/android_asset/www/sounds/indexstart.mp3";

my_media = new Media(firstAudioUrl, null, null, goLoop);
my_media2 = new Media(secondAudioUrl, null, null, goLoop);
my_media.play();
}
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes
ok, that works perfectly, thank you so much, and sorry but I am so rookie with this.
Right now, the only problem is than in the next page, game.html, it doesnt fire the main function of my js file, < body onLoad="main_loop"> doesnt work and document.addEventListener("deviceready", main_loop, false); doesnt work either.
Too weird :S