CS 491 Lecture 18 – Cordova
Before class
A
Before next class:
- Watch http://youtu.be/UgMQcJZC_Wc.
- Read http://docs.phonegap.com/en/2.2.0/cordova_camera_camera.md.html#Camera.
B
Before next class:
- Watch http://youtu.be/yQ8zge-CIFU.
- Read http://docs.phonegap.com/en/2.1.0/guide_plugin-development_index.md.html.
In class
Create a Cordova plugin that plays the RTTTL file. Your jQuery/jQuery Mobile-powered code can be dropped in assets/www in a Cordova project. A blank project named cordova_blank.zip is available on the class folder on the W: drive. You can make your own with the Cordova tools, but the process is annoying.
Android’s MediaPlayer knows about RTTTL, but it has to be stored in a file before it can be played. Assuming you have the RTTTL as a String, it can be played with the following code:
FileOutputStream out = context.openFileOutput("song.rtttl", Context.MODE_WORLD_READABLE);
out.write(rtttl.getBytes());
out.close();
Uri uri = Uri.fromFile(new File(context.getFilesDir(), "song.rtttl"));
MediaPlayer player = MediaPlayer.create(context, uri);
player.start();
Fun!