|
Post by autumnman on Sept 7, 2019 6:56:23 GMT
Hello everyone,
It seems Monkey2 needs to be updated as it comes to sound on Android platform (64-bit).
On my one of my relative's Honor 6X with Android 7.0 the following program compiled to Android 64-bit doesn't start on his phone:
Namespace myapp
#Import "<std>"
#Import "<mojo>"
#Import "snd/music.ogg"
Using std..
Using mojo..
Class MyWindow Extends Window
Field angle:Float
Field x:Float
Field y:Float
Field music:Sound
Field ch:Channel
Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )
Super.New( title,width,height,flags )
music = Sound.Load("asset::music.ogg")
ch = music.Play(True)
End
Method OnRender( canvas:Canvas ) Override
App.RequestRender()
angle = angle + (Pi / 180.0) * 0.5
x = 640 / 2 + Cos(angle) * 200
y = 480 / 2 + Sin(angle) * 160
canvas.DrawCircle(x,y,20)
End
End
The code was compiled with Monkey2 v2018.09.
It seems it has something to do with the sound.
There seems to be other kind of problems with apps using sound too. On one of my friend's phone one of my games started, but mystically crashed while the app was using music and sound effects. Her Android version is 8. The same game didn't start at all on Honor 6x with Android 7.0. When I removed the sounds from the game, the game worked fine on Android 8.
As long as the game was 32-bit it worked fine on Android 8, after 64-bit version it crashed mystically.
On my Samsung Galaxy A6+ with Android 9 there seems to be no problems with Monkey2's sound with 64-bit compilations.
Apps using sound on Android seemed to work fine as long as they were 32-bit.
Anyone else noticed any problems on 64-bit Android platform using sound?
|
|
|
Post by Danilo on Sept 8, 2019 11:42:27 GMT
Could you test again on your friends phone and check the return value of "Sound.Load()"?
If Sound.Load() can't find/load the sound, it returns Null. If you call music.Play() then, it just crashes because of a Null-Pointer.
Namespace myapp
#Import "<std>" #Import "<mojo>" #Import "<mojox>"
#Import "snd/music.ogg"
Using std.. Using mojo.. Using mojox..
Class MyWindow Extends Window
Field angle:Float Field x:Float Field y:Float Field music:Sound Field ch:Channel
Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null ) Super.New( title,width,height,flags )
music = Sound.Load("asset::music.ogg")
If music = Null Alert("MyWindow::New(): music = Null") Else ch = music.Play(True) End End
Method OnRender( canvas:Canvas ) Override App.RequestRender()
angle = angle + (Pi / 180.0) * 0.5
x = 640 / 2 + Cos(angle) * 200 y = 480 / 2 + Sin(angle) * 160
canvas.DrawCircle(x,y,20) End End
Function Main() New AppInstance New MyWindow App.Run() End
Alternatively, or in addition, you could also use the '?' operator like: `music?.Play()`. Using '?' Monkey2 checks for Null-Pointer and only accesses the object if it is not Null:
Namespace myapp
#Import "<std>" #Import "<mojo>" #Import "<mojox>"
#Import "snd/music.ogg"
Using std.. Using mojo.. Using mojox..
Class MyWindow Extends Window
Field angle:Float Field x:Float Field y:Float Field music:Sound Field ch:Channel
Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null ) Super.New( title,width,height,flags )
music = Sound.Load("asset::musics.ogg")
If music = Null Then Alert("MyWindow::New(): music = Null")
ch = music?.Play(True) End
Method OnRender( canvas:Canvas ) Override App.RequestRender()
angle = angle + (Pi / 180.0) * 0.5
x = 640 / 2 + Cos(angle) * 200 y = 480 / 2 + Sin(angle) * 160
canvas.DrawCircle(x,y,20) End End
Function Main() New AppInstance New MyWindow App.Run() End
|
|
|
Post by autumnman on Sept 12, 2019 10:32:54 GMT
The latter code was tested on Honor 6X with Android 7. The app didn't start.
|
|