MediaExtractor Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
MediaExtractor facilitates extraction of demuxed, typically encoded, media data from a data source.
[Android.Runtime.Register("android/media/MediaExtractor", DoNotGenerateAcw=true)]
public sealed class MediaExtractor : Java.Lang.Object
[<Android.Runtime.Register("android/media/MediaExtractor", DoNotGenerateAcw=true)>]
type MediaExtractor = class
inherit Object
- Inheritance
- Attributes
Remarks
MediaExtractor facilitates extraction of demuxed, typically encoded, media data from a data source.
It is generally used like this:
MediaExtractor extractor = new MediaExtractor();
extractor.setDataSource(...);
int numTracks = extractor.getTrackCount();
for (int i = 0; i < numTracks; ++i) {
MediaFormat format = extractor.getTrackFormat(i);
String mime = format.getString(MediaFormat.KEY_MIME);
if (weAreInterestedInThisTrack) {
extractor.selectTrack(i);
}
}
ByteBuffer inputBuffer = ByteBuffer.allocate(...)
while (extractor.readSampleData(inputBuffer, ...) >= 0) {
int trackIndex = extractor.getSampleTrackIndex();
long presentationTimeUs = extractor.getSampleTime();
...
extractor.advance();
}
extractor.release();
extractor = null;
This class requires the android.Manifest.permission#INTERNET
permission when used with network-based content.
Java documentation for android.media.MediaExtractor
.
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.
Constructors
MediaExtractor() |
Fields
SampleFlagEncrypted |
Obsolete.
The sample is (at least partially) encrypted, see also the documentation
for |
SampleFlagPartialFrame |
Obsolete.
This indicates that the buffer only contains part of a frame, and the decoder should batch the data until a buffer without this flag appears before decoding the frame. |
SampleFlagSync |
Obsolete.
The sample is a sync sample (or in |
SeekToClosestSync |
Obsolete.
If possible, seek to the sync sample closest to the specified time |
SeekToNextSync |
Obsolete.
If possible, seek to a sync sample at or after the specified time |
SeekToPreviousSync |
Obsolete.
If possible, seek to a sync sample at or before the specified time |
Properties
CachedDuration |
Returns an estimate of how much data is presently cached in memory expressed in microseconds. |
Class |
Returns the runtime class of this |
DrmInitData |
Extract DRM initialization data if it exists |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
HasCacheReachedEndOfStream |
Returns true iff we are caching data and the cache has reached the end of the data stream (for now, a future seek may of course restart the fetching of data). |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
LogSessionId |
Returns the |
Metrics |
Return Metrics data about the current media container. |
PeerReference | (Inherited from Object) |
PsshInfo |
Get the PSSH info if present. |
SampleFlags |
Returns the current sample's flags. |
SampleSize | |
SampleTime |
Returns the current sample's presentation time in microseconds. |
SampleTrackIndex |
Returns the track index the current sample originates from (or -1 if no more samples are available) |
ThresholdClass |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. (Inherited from Object) |
ThresholdType |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. (Inherited from Object) |
TrackCount |
Count the number of tracks found in the data source. |
Methods
Advance() |
Advance to the next sample. |
AdvanceAsync() | |
Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
GetAudioPresentations(Int32) |
Get the list of available audio presentations for the track. |
GetCasInfo(Int32) |
Retrieves the information about the conditional access system used to scramble a track. |
GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
GetSampleCryptoInfo(MediaCodec+CryptoInfo) |
If the sample flags indicate that the current sample is at least partially encrypted, this call returns relevant information about the structure of the sample data required for decryption. |
GetTrackFormat(Int32) |
Get the track format at the specified index. |
JavaFinalize() |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. (Inherited from Object) |
Notify() |
Wakes up a single thread that is waiting on this object's monitor. (Inherited from Object) |
NotifyAll() |
Wakes up all threads that are waiting on this object's monitor. (Inherited from Object) |
ReadSampleData(ByteBuffer, Int32) |
Retrieve the current encoded sample and store it in the byte buffer starting at the given offset. |
ReadSampleDataAsync(ByteBuffer, Int32) | |
Release() |
Make sure you call this when you're done to free up any resources instead of relying on the garbage collector to do this for you at some point in the future. |
SeekTo(Int64, MediaExtractorSeekTo) |
All selected tracks seek near the requested time according to the specified mode. |
SelectTrack(Int32) |
Subsequent calls to |
SetDataSource(AssetFileDescriptor) |
Sets the data source (AssetFileDescriptor) to use. |
SetDataSource(Context, Uri, IDictionary<String,String>) |
Sets the data source as a content Uri. |
SetDataSource(FileDescriptor, Int64, Int64) |
Sets the data source (FileDescriptor) to use. |
SetDataSource(FileDescriptor) |
Sets the data source (FileDescriptor) to use. |
SetDataSource(MediaDataSource) |
Sets the data source (MediaDataSource) to use. |
SetDataSource(String, IDictionary<String,String>) |
Sets the data source (file-path or http URL) to use. |
SetDataSource(String) |
Sets the data source (file-path or http URL) to use. |
SetDataSourceAsync(AssetFileDescriptor) | |
SetDataSourceAsync(Context, Uri, IDictionary<String,String>) | |
SetDataSourceAsync(FileDescriptor, Int64, Int64) | |
SetDataSourceAsync(FileDescriptor) | |
SetDataSourceAsync(MediaDataSource) | |
SetDataSourceAsync(String, IDictionary<String,String>) | |
SetDataSourceAsync(String) | |
SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
SetMediaCas(MediaCas) |
Sets the MediaCas instance to use. |
ToArray<T>() | (Inherited from Object) |
ToString() |
Returns a string representation of the object. (Inherited from Object) |
UnregisterFromRuntime() | (Inherited from Object) |
UnselectTrack(Int32) |
Subsequent calls to |
Wait() |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>. (Inherited from Object) |
Wait(Int64, Int32) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Wait(Int64) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Explicit Interface Implementations
IJavaPeerable.Disposed() | (Inherited from Object) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Object) |
IJavaPeerable.Finalized() | (Inherited from Object) |
IJavaPeerable.JniManagedPeerState | (Inherited from Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Object) |
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |