Prof. Christopher Rasmussen
May 13, 2015
CISC 181
Android:
Multimedia
News
News
News
News
Sounds
Sounds
Sounds
Sounds
MediaPlayer MP =
MediaPlayer.create(getApplicationContext(),
R.raw.music); // music.mp3, etc.
try { MP.prepare(); } catch (Exception e) { }
MediaPlayer
MediaPlayer MP =
MediaPlayer.create(getApplicationContext(),
R.raw.music); // music.mp3, etc.
try { MP.prepare(); } catch (Exception e) { }
MP.setVolume(.5f, .5f);�MP.setLooping(true);
MP.start();�
MediaPlayer
MediaPlayer MP =
MediaPlayer.create(getApplicationContext(),
R.raw.music); // music.mp3, etc.
try { MP.prepare(); } catch (Exception e) { }
MP.setVolume(.5f, .5f);�MP.setLooping(true);
MP.start();�…
MP.pause(); // stop() requires prepare() to start() again
Text To Speech
TextToSpeech mTTS;
mTTS = new TextToSpeech(
getApplicationContext(),
new TextToSpeech.OnInitListener() {� public void onInit(int status) { }� });
Text To Speech
TextToSpeech mTTS;
mTTS = new TextToSpeech(
getApplicationContext(),
new TextToSpeech.OnInitListener() {� public void onInit(int status) { }� });
…
mTTS.speak(
myTextString,
TextToSpeech.QUEUE_FLUSH, // vs. QUEUE_ADD
null);
Text To Speech: Extras
Text To Speech: Extras
mTTS.addSpeech(String,
package name,
sound resource ID)
Text To Speech: Extras
mTTS.addSpeech(String,
package name,
sound resource ID)
List<Sensor> getSensorList(Sensor.TYPE_ALL)
List<Sensor> getSensorList(Sensor.TYPE_ALL)
Sensors: Accelerometer
SensorManager SM = (SensorManager)
getApplicationContext().getSystemService(Context.SENSOR_SERVICE);�SM.registerListener(
new SensorListener(), // this is our custom class
SM.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
SM.SENSOR_DELAY_NORMAL);
Sensors: Accelerometer
SensorManager SM = (SensorManager)
getApplicationContext().getSystemService(Context.SENSOR_SERVICE);�SM.registerListener(
new SensorListener(), // this is our custom class
SM.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
SM.SENSOR_DELAY_NORMAL);
class SensorListener implements SensorEventListener {� public void onSensorChanged(SensorEvent event) {� if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {� aX = event.values[0]; aY = event.values[1];� aZ = event.values[2]; haveAccel = true;� }� }
� public void onAccuracyChanged(Sensor sensor, int accuracy) { }
}
And if you're really bored...
And if you're really bored...
VIBRATION!!!