1717package android .media ;
1818
1919import android .content .ComponentName ;
20- import android .content .SharedPreferences .Editor ;
2120import android .graphics .Bitmap ;
2221import android .graphics .Canvas ;
2322import android .graphics .Paint ;
3130import android .util .Log ;
3231
3332import java .lang .IllegalArgumentException ;
34- import java .util .HashMap ;
3533
3634/**
37- * @hide
38- * CANDIDATE FOR SDK
3935 * RemoteControlClient enables exposing information meant to be consumed by remote controls
40- * capable of displaying metadata, album art and media transport control buttons.
41- * A remote control client object is associated with a media button event receiver
42- * when registered through
36+ * capable of displaying metadata, artwork and media transport control buttons.
37+ * A remote control client object is associated with a media button event receiver. This
38+ * event receiver must have been previously registered with
39+ * {@link AudioManager#registerMediaButtonEventReceiver(ComponentName)} before the
40+ * RemoteControlClient can be registered through
4341 * {@link AudioManager#registerRemoteControlClient(RemoteControlClient)}.
4442 */
4543public class RemoteControlClient
@@ -110,7 +108,8 @@ public class RemoteControlClient
110108 public final static int PLAYSTATE_ERROR = 9 ;
111109 /**
112110 * @hide
113- * The value of a playback state when none has been declared
111+ * The value of a playback state when none has been declared.
112+ * Intentionally hidden as an application shouldn't set such a playback state value.
114113 */
115114 public final static int PLAYSTATE_NONE = 0 ;
116115
@@ -122,7 +121,7 @@ public class RemoteControlClient
122121 */
123122 public final static int FLAG_KEY_MEDIA_PREVIOUS = 1 << 0 ;
124123 /**
125- * Flag indicating a RemoteControlClient makes use of the "rewing " media key.
124+ * Flag indicating a RemoteControlClient makes use of the "rewind " media key.
126125 *
127126 * @see #setTransportControlFlags(int)
128127 * @see android.view.KeyEvent#KEYCODE_MEDIA_REWIND
@@ -173,7 +172,9 @@ public class RemoteControlClient
173172
174173 /**
175174 * @hide
176- * The flags for when no media keys are declared supported
175+ * The flags for when no media keys are declared supported.
176+ * Intentionally hidden as an application shouldn't set the transport control flags
177+ * to this value.
177178 */
178179 public final static int FLAGS_KEY_MEDIA_NONE = 0 ;
179180
@@ -184,29 +185,29 @@ public class RemoteControlClient
184185 public final static int FLAG_INFORMATION_REQUEST_METADATA = 1 << 0 ;
185186 /**
186187 * @hide
187- * FIXME doc not valid
188188 * Flag used to signal that the transport control buttons supported by the
189- * RemoteControlClient have changed .
189+ * RemoteControlClient are requested .
190190 * This can for instance happen when playback is at the end of a playlist, and the "next"
191191 * operation is not supported anymore.
192192 */
193193 public final static int FLAG_INFORMATION_REQUEST_KEY_MEDIA = 1 << 1 ;
194194 /**
195195 * @hide
196- * FIXME doc not valid
197- * Flag used to signal that the playback state of the RemoteControlClient has changed.
196+ * Flag used to signal that the playback state of the RemoteControlClient is requested.
198197 */
199198 public final static int FLAG_INFORMATION_REQUEST_PLAYSTATE = 1 << 2 ;
200199 /**
201200 * @hide
202- * FIXME doc not valid
203- * Flag used to signal that the album art for the RemoteControlClient has changed.
201+ * Flag used to signal that the album art for the RemoteControlClient is requested.
204202 */
205203 public final static int FLAG_INFORMATION_REQUEST_ALBUM_ART = 1 << 3 ;
206204
207205 /**
208206 * Class constructor.
209- * @param mediaButtonEventReceiver the receiver for the media button events.
207+ * @param mediaButtonEventReceiver The receiver for the media button events. It needs to have
208+ * been registered with {@link AudioManager#registerMediaButtonEventReceiver(ComponentName)}
209+ * before this new RemoteControlClient can itself be registered with
210+ * {@link AudioManager#registerRemoteControlClient(RemoteControlClient)}.
210211 * @see AudioManager#registerMediaButtonEventReceiver(ComponentName)
211212 * @see AudioManager#registerRemoteControlClient(RemoteControlClient)
212213 */
@@ -227,8 +228,11 @@ public RemoteControlClient(ComponentName mediaButtonEventReceiver) {
227228 /**
228229 * Class constructor for a remote control client whose internal event handling
229230 * happens on a user-provided Looper.
230- * @param mediaButtonEventReceiver the receiver for the media button events.
231- * @param looper the Looper running the event loop.
231+ * @param mediaButtonEventReceiver The receiver for the media button events. It needs to have
232+ * been registered with {@link AudioManager#registerMediaButtonEventReceiver(ComponentName)}
233+ * before this new RemoteControlClient can itself be registered with
234+ * {@link AudioManager#registerRemoteControlClient(RemoteControlClient)}.
235+ * @param looper The Looper running the event loop.
232236 * @see AudioManager#registerMediaButtonEventReceiver(ComponentName)
233237 * @see AudioManager#registerRemoteControlClient(RemoteControlClient)
234238 */
@@ -257,11 +261,28 @@ public RemoteControlClient(ComponentName mediaButtonEventReceiver, Looper looper
257261
258262 /**
259263 * Class used to modify metadata in a {@link RemoteControlClient} object.
264+ * Use {@link RemoteControlClient#editMetadata(boolean)} to create an instance of an editor,
265+ * on which you set the metadata for the RemoteControlClient instance. Once all the information
266+ * has been set, use {@link #apply()} to make it the new metadata that should be displayed
267+ * for the associated client. Once the metadata has been "applied", you cannot reuse this
268+ * instance of the MetadataEditor.
260269 */
261270 public class MetadataEditor {
271+ /**
272+ * @hide
273+ */
262274 protected boolean mMetadataChanged ;
275+ /**
276+ * @hide
277+ */
263278 protected boolean mArtworkChanged ;
279+ /**
280+ * @hide
281+ */
264282 protected Bitmap mEditorArtwork ;
283+ /**
284+ * @hide
285+ */
265286 protected Bundle mEditorMetadata ;
266287 private boolean mApplied = false ;
267288
@@ -277,13 +298,18 @@ public Object clone() throws CloneNotSupportedException {
277298 /**
278299 * The metadata key for the content artwork / album art.
279300 */
280- public final static int METADATA_KEY_ARTWORK = 100 ;
301+ public final static int BITMAP_KEY_ARTWORK = 100 ;
302+ /**
303+ * @hide
304+ * TODO(jmtrivi) have lockscreen and music move to the new key name
305+ */
306+ public final static int METADATA_KEY_ARTWORK = BITMAP_KEY_ARTWORK ;
281307
282308 /**
283309 * Adds textual information to be displayed.
284310 * Note that none of the information added after {@link #apply()} has been called,
285311 * will be displayed.
286- * @param key the identifier of a the metadata field to set. Valid values are
312+ * @param key The identifier of a the metadata field to set. Valid values are
287313 * {@link android.media.MediaMetadataRetriever#METADATA_KEY_ALBUM},
288314 * {@link android.media.MediaMetadataRetriever#METADATA_KEY_ALBUMARTIST},
289315 * {@link android.media.MediaMetadataRetriever#METADATA_KEY_TITLE},
@@ -294,11 +320,11 @@ public Object clone() throws CloneNotSupportedException {
294320 * {@link android.media.MediaMetadataRetriever#METADATA_KEY_DATE},
295321 * {@link android.media.MediaMetadataRetriever#METADATA_KEY_GENRE},
296322 * {@link android.media.MediaMetadataRetriever#METADATA_KEY_TITLE},
297- * {@link android.media.MediaMetadataRetriever#METADATA_KEY_WRITER},
298- * .
299- * @param value the text for the given key, or {@code null} to signify there is no valid
323+ * {@link android.media.MediaMetadataRetriever#METADATA_KEY_WRITER}.
324+ * @param value The text for the given key, or {@code null} to signify there is no valid
300325 * information for the field.
301- * @return FIXME description
326+ * @return Returns a reference to the same MetadataEditor object, so you can chain put
327+ * calls together.
302328 */
303329 public synchronized MetadataEditor putString (int key , String value )
304330 throws IllegalArgumentException {
@@ -315,15 +341,18 @@ public synchronized MetadataEditor putString(int key, String value)
315341 }
316342
317343 /**
318- * FIXME javadoc
344+ * Adds numerical information to be displayed.
345+ * Note that none of the information added after {@link #apply()} has been called,
346+ * will be displayed.
319347 * @param key the identifier of a the metadata field to set. Valid values are
320348 * {@link android.media.MediaMetadataRetriever#METADATA_KEY_CD_TRACK_NUMBER},
321349 * {@link android.media.MediaMetadataRetriever#METADATA_KEY_DISC_NUMBER},
322350 * {@link android.media.MediaMetadataRetriever#METADATA_KEY_DURATION} (with a value
323351 * expressed in milliseconds),
324352 * {@link android.media.MediaMetadataRetriever#METADATA_KEY_YEAR}.
325- * @param value FIXME javadoc
326- * @return FIXME javadoc
353+ * @param value The long value for the given key
354+ * @return Returns a reference to the same MetadataEditor object, so you can chain put
355+ * calls together.
327356 * @throws IllegalArgumentException
328357 */
329358 public synchronized MetadataEditor putLong (int key , long value )
@@ -342,9 +371,11 @@ public synchronized MetadataEditor putLong(int key, long value)
342371
343372 /**
344373 * Sets the album / artwork picture to be displayed on the remote control.
345- * @param key FIXME description
346- * @param bitmap the bitmap for the artwork, or null if there isn't any.
347- * @return FIXME description
374+ * @param key the identifier of the bitmap to set. The only valid value is
375+ * {@link #BITMAP_KEY_ARTWORK}
376+ * @param bitmap The bitmap for the artwork, or null if there isn't any.
377+ * @return Returns a reference to the same MetadataEditor object, so you can chain put
378+ * calls together.
348379 * @throws IllegalArgumentException
349380 * @see android.graphics.Bitmap
350381 */
@@ -354,7 +385,7 @@ public synchronized MetadataEditor putBitmap(int key, Bitmap bitmap)
354385 Log .e (TAG , "Can't edit a previously applied MetadataEditor" );
355386 return this ;
356387 }
357- if (key != METADATA_KEY_ARTWORK ) {
388+ if (key != BITMAP_KEY_ARTWORK ) {
358389 throw (new IllegalArgumentException ("Invalid type 'Bitmap' for key " + key ));
359390 }
360391 if ((mArtworkExpectedWidth > 0 ) && (mArtworkExpectedHeight > 0 )) {
@@ -369,7 +400,8 @@ public synchronized MetadataEditor putBitmap(int key, Bitmap bitmap)
369400 }
370401
371402 /**
372- * FIXME description
403+ * Clears all the metadata that has been set since the MetadataEditor instance was
404+ * created with {@link RemoteControlClient#editMetadata(boolean)}.
373405 */
374406 public synchronized void clear () {
375407 if (mApplied ) {
@@ -381,7 +413,10 @@ public synchronized void clear() {
381413 }
382414
383415 /**
384- * FIXME description
416+ * Associates all the metadata that has been set since the MetadataEditor instance was
417+ * created with {@link RemoteControlClient#editMetadata(boolean)}, or since
418+ * {@link #clear()} was called, with the RemoteControlClient. Once "applied",
419+ * this MetadataEditor cannot be reused to edit the RemoteControlClient's metadata.
385420 */
386421 public synchronized void apply () {
387422 if (mApplied ) {
@@ -408,9 +443,10 @@ public synchronized void apply() {
408443 }
409444
410445 /**
411- * FIXME description
412- * @param startEmpty
413- * @return
446+ * Creates a {@link MetadataEditor}.
447+ * @param startEmpty Set to false if you want the MetadataEditor to contain the metadata that
448+ * was previously applied to the RemoteControlClient, or true if it is to be created empty.
449+ * @return a new MetadataEditor instance.
414450 */
415451 public MetadataEditor editMetadata (boolean startEmpty ) {
416452 MetadataEditor editor = new MetadataEditor ();
@@ -430,7 +466,7 @@ public MetadataEditor editMetadata(boolean startEmpty) {
430466
431467 /**
432468 * Sets the current playback state.
433- * @param state the current playback state, one of the following values:
469+ * @param state The current playback state, one of the following values:
434470 * {@link #PLAYSTATE_STOPPED},
435471 * {@link #PLAYSTATE_PAUSED},
436472 * {@link #PLAYSTATE_PLAYING},
@@ -453,7 +489,7 @@ public void setPlaybackState(int state) {
453489
454490 /**
455491 * Sets the flags for the media transport control buttons that this client supports.
456- * @param a combination of the following flags:
492+ * @param transportControlFlags A combination of the following flags:
457493 * {@link #FLAG_KEY_MEDIA_PREVIOUS},
458494 * {@link #FLAG_KEY_MEDIA_REWIND},
459495 * {@link #FLAG_KEY_MEDIA_PLAY},
0 commit comments