本文整理了Java中android.media.MediaExtractor.setDataSource()
方法的一些代码示例,展示了MediaExtractor.setDataSource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MediaExtractor.setDataSource()
方法的具体详情如下:
包路径:android.media.MediaExtractor
类名称:MediaExtractor
方法名:setDataSource
暂无
代码示例来源:origin: TeamNewPipe/NewPipe
private MediaExtractor getMediaExtractor(FileInputStream source, long offset, long length) throws IOException {
MediaExtractor extractor = new MediaExtractor();
extractor.setDataSource(source.getFD(), offset, length);
extractor.selectTrack(0);
return extractor;
}
}
代码示例来源:origin: Naoki2015/CircleDemo
mediaExtractor.setDataSource(mContext, mUri, null);
MediaFormat format;
mHasAudio = false;
代码示例来源:origin: waynell/VideoListPlayer
try {
MediaExtractor mediaExtractor = new MediaExtractor();
mediaExtractor.setDataSource(mContext, mUri, null);
MediaFormat format;
for (int i = 0; i < mediaExtractor.getTrackCount(); i++) {
代码示例来源:origin: pili-engineering/PLDroidShortVideo
private boolean getSourceVideoParameters() {
mSrcMediaExtractor = new MediaExtractor();
try {
mSrcMediaExtractor.setDataSource(SRC_VIDEO_FILE_PATH);
} catch (IOException e) {
Log.e(TAG, "file video setDataSource failed: " + e.getMessage());
代码示例来源:origin: guoxiaoxing/phoenix
mExtractor.setDataSource(mInputFileDescriptor);
mMuxer = new MediaMuxer(outputPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
setupMetadata();
代码示例来源:origin: stackoverflow.com
MediaExtractor extractor= new MediaExtractor();
File file = new File(this.fileName);
extractor.setDataSource(this.fileName);
int tracks = extractor.getTrackCount();
extractor.selectTrack(0); ..
代码示例来源:origin: stackoverflow.com
MediaExtractor extractor = new MediaExtractor();
extractor.setDataSource(path);
//where path is a String variable and points to the data source
MediaFormat format = extractor.getTrackFormat(i);
//where i is an int variable and denotes the index value of a track.
//For the first track: i = 0;
int count = format.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
代码示例来源:origin: stackoverflow.com
MediaExtractor mex = new MediaExtractor();
try {
mex.setDataSource(path);// the adresss location of the sound on sdcard.
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
MediaFormat mf = mex.getTrackFormat(0);
int bitRate = mf.getInteger(MediaFormat.KEY_BIT_RATE);
int sampleRate = mf.getInteger(MediaFormat.KEY_SAMPLE_RATE);
代码示例来源:origin: stackoverflow.com
// Assuming a raw resource located at "res/raw/test_audio.mp3"
MediaExtractor extractor = new MediaExtractor();
AssetFileDescriptor afd = getResources().openRawResourceFd(R.raw.test_audio);
try {
extractor.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
} catch (IOException e) {
e.printStackTrace();
}
代码示例来源:origin: ywwynm/EverythingDone
public static int getAudioSampleRate(String pathName) {
MediaExtractor extractor = new MediaExtractor();
try {
extractor.setDataSource(pathName);
MediaFormat mf = extractor.getTrackFormat(0);
return mf.getInteger(MediaFormat.KEY_SAMPLE_RATE);
} catch (Exception e) {
e.printStackTrace();
return -1;
} finally {
extractor.release();
}
}
代码示例来源:origin: stackoverflow.com
MediaExtractor mex = new MediaExtractor();
try {
mex.setDataSource(path);// the adresss location of the sound on sdcard.
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
MediaFormat mf = mex.getTrackFormat(0);
int bitRate = mf.getInteger(MediaFormat.KEY_BIT_RATE);
int sampleRate = mf.getInteger(MediaFormat.KEY_SAMPLE_RATE);
int channelCount = mf.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
代码示例来源:origin: stackoverflow.com
MediaExtractor extractor = new MediaExtractor();
extractor.setDataSource(MEDIA_PATH);//MEDIA_PATH is your http path of mpeg ts file
for (i = 0; i < extractor.getTrackCount(); i++) {
MediaFormat format = extractor.getTrackFormat(i);
String mime = format.getString(MediaFormat.KEY_MIME);
/*if (mime.startsWith("audio/")) {
extractor.selectTrack(i);
decoder = MediaCodec.createDecoderByType(mime);
if(decoder != null)
{
decoder.configure(format, null /*surface*/ , null /*crypto*/ , 0 /*flags*/ );
}
break;
}*/ //this commented code may not useful for you. If you wanna you can use..
}
代码示例来源:origin: aserbao/AndroidCamera
/**
* Creates an extractor that reads its frames from {@link #mSourceResId}.
*/
private MediaExtractor createExtractor() throws IOException {
MediaExtractor extractor;
AssetFileDescriptor srcFd = getResources().openRawResourceFd(mSourceResId);
extractor = new MediaExtractor();
extractor.setDataSource(srcFd.getFileDescriptor(), srcFd.getStartOffset(),
srcFd.getLength());
return extractor;
}
代码示例来源:origin: windrunnerlihuan/DogCamera
private boolean createSugarExtractor() {
releaseSugarExtractor();
mSugarExtractor = new MediaExtractor();
AssetFileDescriptor afd;
try {
afd = DogApplication.getInstance().getAssets().openFd(mRenderConfig.audioPath);
mSugarExtractor.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
} catch (IOException e) {
e.printStackTrace();
releaseSugarExtractor();
return false;
}
return true;
}
代码示例来源:origin: saki4510t/libcommon
public void setDataSource(final FileDescriptor fd) throws IOException {
release();
try {
mMediaMetadataRetriever = new MediaMetadataRetriever();
mMediaMetadataRetriever.setDataSource(fd);
updateMovieInfo(mMediaMetadataRetriever);
mMediaExtractor = new MediaExtractor();
mMediaExtractor.setDataSource(fd);
mState = STATE_INITIALIZED;
} catch (IOException e) {
internal_release();
if (!callErrorHandler(e))
throw e;
}
}
代码示例来源:origin: saki4510t/libcommon
public void setDataSource(final String path) throws IOException {
release();
try {
mMediaMetadataRetriever = new MediaMetadataRetriever();
mMediaMetadataRetriever.setDataSource(path);
updateMovieInfo(mMediaMetadataRetriever);
mMediaExtractor = new MediaExtractor();
mMediaExtractor.setDataSource(path);
mState = STATE_INITIALIZED;
} catch (IOException e) {
internal_release();
if (!callErrorHandler(e))
throw e;
}
}
代码示例来源:origin: saki4510t/libcommon
public void setDataSource(Context context, Uri uri) throws IOException {
release();
mMediaMetadataRetriever = new MediaMetadataRetriever();
try {
mMediaMetadataRetriever.setDataSource(context, uri);
updateMovieInfo(mMediaMetadataRetriever);
mMediaExtractor = new MediaExtractor();
mMediaExtractor.setDataSource(context, uri, null);
mState = STATE_INITIALIZED;
} catch (IOException e) {
release();
if (!callErrorHandler(e))
throw e;
}
}
代码示例来源:origin: saki4510t/libcommon
public void setDataSource(final String path, final Map<String, String> headers)
throws IOException {
release();
try {
mMediaMetadataRetriever = new MediaMetadataRetriever();
mMediaMetadataRetriever.setDataSource(path, headers);
updateMovieInfo(mMediaMetadataRetriever);
mMediaExtractor = new MediaExtractor();
mMediaExtractor.setDataSource(path, headers);
mState = STATE_INITIALIZED;
} catch (IOException e) {
internal_release();
if (!callErrorHandler(e))
throw e;
}
}
代码示例来源:origin: saki4510t/libcommon
public void setDataSource(final Context context, final Uri uri,
final Map<String, String> headers) throws IOException {
release();
try {
mMediaMetadataRetriever = new MediaMetadataRetriever();
mMediaMetadataRetriever.setDataSource(context, uri);
updateMovieInfo(mMediaMetadataRetriever);
mMediaExtractor = new MediaExtractor();
mMediaExtractor.setDataSource(context, uri, headers);
mState = STATE_INITIALIZED;
} catch (IOException e) {
internal_release();
if (!callErrorHandler(e))
throw e;
}
}
代码示例来源:origin: saki4510t/libcommon
public void setDataSource(final FileDescriptor fd, final long offset, final long length)
throws IOException {
release();
try {
mMediaMetadataRetriever = new MediaMetadataRetriever();
mMediaMetadataRetriever.setDataSource(fd, offset, length);
updateMovieInfo(mMediaMetadataRetriever);
mMediaExtractor = new MediaExtractor();
mMediaExtractor.setDataSource(fd, offset, length);
mState = STATE_INITIALIZED;
} catch (IOException e) {
internal_release();
if (!callErrorHandler(e))
throw e;
}
}
内容来源于网络,如有侵权,请联系作者删除!