本文整理匯總了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);
}
}