5 package com.google.appinventor.components.runtime;
19 import android.util.Log;
21 import java.io.BufferedInputStream;
23 import java.io.FileInputStream;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.io.UnsupportedEncodingException;
27 import java.nio.ByteBuffer;
28 import java.nio.ByteOrder;
29 import java.util.ArrayList;
30 import java.util.List;
41 @DesignerComponent(version = YaVersion.EV3_SOUND_COMPONENT_VERSION,
42 description =
"A component that provides a high-level interface to " +
43 "sound functionalities on LEGO MINDSTORMS EV3 robot.",
44 category = ComponentCategory.LEGOMINDSTORMS,
46 iconName =
"images/legoMindstormsEv3.png")
48 @UsesPermissions(permissionNames =
"android.permission.INTERNET," +
49 "android.permission.WRITE_EXTERNAL_STORAGE," +
50 "android.permission.READ_EXTERNAL_STORAGE")
56 super(container,
"Ev3Sound");
63 public
void PlayTone(
int volume,
int frequency,
int milliseconds) {
64 String functionName = Thread.currentThread().getStackTrace()[1].getMethodName();
66 if (volume < 0 || volume > 100 || frequency < 250 || frequency > 10000 || milliseconds < 0 || milliseconds > 0xffff) {
79 (
short) milliseconds);
80 sendCommand(functionName, command,
true);
87 public
void StopSound() {
88 String functionName = Thread.currentThread().getStackTrace()[1].getMethodName();
95 sendCommand(functionName, command,
false);