本文整理汇总了Java中android.media.MediaPlayer.setDisplay方法的典型用法代码示例。如果您正苦于以下问题:Java MediaPlayer.setDisplay方法的具体用法?Java MediaPlayer.setDisplay怎么用?Java MediaPlayer.setDisplay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.setDisplay方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playVideo
import android.media.MediaPlayer; //导入方法依赖的package包/类
private void playVideo(Integer Media) {
doCleanUp();
try {
// Create a new media player and set the listeners
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(path);
mMediaPlayer.setDisplay(holder);
mMediaPlayer.prepareAsync();
mMediaPlayer.setOnBufferingUpdateListener(this);
mMediaPlayer.setOnCompletionListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnVideoSizeChangedListener(this);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
} catch (Exception e) {
Log.e(TAG, "error: " + e.getMessage(), e);
}
}
示例2: initMediaPlayer
import android.media.MediaPlayer; //导入方法依赖的package包/类
private void initMediaPlayer(SurfaceHolder holder){
mediaPlayer = new MediaPlayer();
try {
AssetManager assetMg = getApplicationContext().getAssets();
AssetFileDescriptor fileDescriptor = assetMg.openFd(此处资源asset请从鸿洋大神那获取);
mediaPlayer.setDataSource(fileDescriptor.getFileDescriptor(),
fileDescriptor.getStartOffset(), fileDescriptor.getLength());
mediaPlayer.setDisplay(holder);
mediaPlayer.prepare();
mediaPlayer.setLooping(true);
mediaPlayer.setVolume(0, 0);
mediaPlayer.prepare();
}catch (Exception e){
e.printStackTrace();
}
}
示例3: surfaceCreated
import android.media.MediaPlayer; //导入方法依赖的package包/类
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (bgVideo != 0) {
mp = new MediaPlayer();
AssetFileDescriptor afd = context.getResources().openRawResourceFd(bgVideo);
try {
mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getDeclaredLength());
mp.prepare();
} catch (IOException e) {
e.printStackTrace();
}
int videoWidth = mp.getVideoWidth();
int videoHeight = mp.getVideoHeight();
int screenHeight = getHeight();
android.view.ViewGroup.LayoutParams lp = getLayoutParams();
lp.height = screenHeight;
setLayoutParams(lp);
mp.setDisplay(getHolder());
mp.setLooping(true);
mp.start();
}
}
示例4: bindSurfaceHolder
import android.media.MediaPlayer; //导入方法依赖的package包/类
private void bindSurfaceHolder(MediaPlayer mp, ISurfaceHolder holder) {
if (mp != null) {
if (holder == null) {
mp.setDisplay(null);
return;
}
holder.bindToMediaPlayer(mp);
mp.setScreenOnWhilePlaying(true);
}
}
示例5: bindToMediaPlayer
import android.media.MediaPlayer; //导入方法依赖的package包/类
public void bindToMediaPlayer(MediaPlayer mp) {
if (mp != null) {
mp.setDisplay(this.mSurfaceHolder);
}
}