共用方式為


MediaPlayer.SelectTrack(Int32) Method

Definition

Selects a track.

[Android.Runtime.Register("selectTrack", "(I)V", "GetSelectTrack_IHandler")]
public virtual void SelectTrack (int index);
[<Android.Runtime.Register("selectTrack", "(I)V", "GetSelectTrack_IHandler")>]
abstract member SelectTrack : int -> unit
override this.SelectTrack : int -> unit

Parameters

index
Int32

the index of the track to be selected. The valid range of the index is 0..total number of track - 1. The total number of tracks as well as the type of each individual track can be found by calling #getTrackInfo() method.

Attributes

Exceptions

if called in an invalid state.

Remarks

Selects a track.

If a MediaPlayer is in invalid state, it throws an IllegalStateException exception. If a MediaPlayer is in <em>Started</em> state, the selected track is presented immediately. If a MediaPlayer is not in Started state, it just marks the track to be played.

In any valid state, if it is called multiple times on the same type of track (ie. Video, Audio, Timed Text), the most recent one will be chosen.

The first audio and video tracks are selected by default if available, even though this method is not called. However, no timed text track will be selected until this function is called.

Currently, only timed text, subtitle or audio tracks can be selected via this method. In addition, the support for selecting an audio track at runtime is pretty limited in that an audio track can only be selected in the <em>Prepared</em> state.

Java documentation for android.media.MediaPlayer.selectTrack(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also