To try out the new Version, I run this line:
To try out the new Version, I run this line:
LL.bindClass(android.media.MediaPlayer);
I keep getting an “android”-is-not-defined-Error
Pierre Hébert what is wrong with it?
]]>« Wow (Previous Post)
(Next Post) in a script started on “Position Changed” event.. how to do some actions when the position isn’t changing anymore ? »
< ![CDATA[
you forgot the quotes !!!!
]]>
< ![CDATA[
You’re right, with quotes the bindClass works.
However the resulting class seems to do absolutely nothing…
]]>
< ![CDATA[
what script did you tried ?
]]>
< ![CDATA[
LL.bindClass(“android.media.MediaPlayer”);
MediaPlayer.start();
]]>
< ![CDATA[
Maybe try if(ok = LL.bindClass(“blabla”)) {
alert(ok);
MediaPlayer.start();
}
]]>
< ![CDATA[
If with a defining statement doesn’t make sense, because it’s always true.
However an alert is a good idea
]]>
< ![CDATA[
The statement in the if works in some language… I didn’t remember if it works in js…
]]>
< ![CDATA[
alert(LL.bindClass(“android.media.MediaPlayer”));
MediaPlayer.start();
Returns true for the alert, but start stop throws an error
]]>
< ![CDATA[
You need to create a MediaPlayer instance first… See http://www.tutorialspoint.com/android/android_mediaplayer.htm
]]>
< ![CDATA[
Thanks a lot. Works:
LL.bindClass(“android.media.MediaPlayer”);
mediaPlayer=MediaPlayer.create(LL.getContext(),Uri.parse(“file://path“));
mediaPlayer.start();
]]>
< ![CDATA[
Wow cool!!
]]>
< ![CDATA[
Fun!
Indeed MediaPlayer.start is not enough, it need to follow the full cycle, with a prepare before or some convenience method such as create.
bindClass will return true the first time it is run, then false on next tries (as long as the app is not restarted) because the class will be registered.
]]>
< ![CDATA[
Josh Gray see this post to (maybe) make a built-in player!
]]>