本文整理汇总了Java中android.widget.MediaController.setAnchorView方法的典型用法代码示例。如果您正苦于以下问题:Java MediaController.setAnchorView方法的具体用法?Java MediaController.setAnchorView怎么用?Java MediaController.setAnchorView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.MediaController
的用法示例。
在下文中一共展示了MediaController.setAnchorView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.widget.MediaController; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Find the video view by id so we can use it.
VideoView myVideo = (VideoView) findViewById(R.id.videoView);
// To set the path to the video. Sample.mp4 is in the "raw" folder.
// You can use http://online.path.to.your.video also.
myVideo.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.sample);
// To create the media controller (play, pause, etc.)
MediaController myController = new MediaController(this);
// To link the media controller to the video view.
myController.setAnchorView(myVideo);
// To link the video view to the media controller.
myVideo.setMediaController(myController);
// To autoplay on opening.
myVideo.start();
}
示例2: onPrepared
import android.widget.MediaController; //导入方法依赖的package包/类
@Override
public void onPrepared(MediaPlayer mp) {
if(mHasVideo) {
mediaPlayer.start();
mediaPlayer.setVolume(0,0);
setVideoSize();
vidSurface.bringToFront();
vidSurface.requestFocus();
MediaController mController = new MediaController(context);
mController.setMediaPlayer(this);
mController.setAnchorView(vidSurface);
// mController.show(0);
vidSurface.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
}
}
示例3: onCreate
import android.widget.MediaController; //导入方法依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
// Load the appropriate URL in the VideoView.
final String youtubeId = getIntent().getStringExtra(Keys.YOUTUBE_ID);
final String videoUrl = UrlBuilder.forYoutubeId(youtubeId);
final VideoView videoView = (VideoView) findViewById(R.id.video_view);
videoView.setVideoPath(videoUrl);
videoView.start();
// Add a MediaController, which gives us play/pause, etc.
final MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
}
示例4: onCreate
import android.widget.MediaController; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PreferencesState.getInstance().loadsLanguageInActivity();
setContentView(R.layout.video_activity);
//Displays a video file.
MediaController mediaController = new MediaController(VideoActivity.this);
mVideoView = (VideoView)findViewById(R.id.videoview);
String videoPathParam = getIntent().getStringExtra(VIDEO_PATH_PARAM);
mVideoView.setVideoPath(videoPathParam);
mVideoView.setMediaController(mediaController);
mediaController.setAnchorView(mVideoView);
mVideoView.requestFocus();
if (savedInstanceState != null) {
mVideoView.seekTo(savedInstanceState.getInt("video",0));
}
mVideoView.start();
}
示例5: onCreate
import android.widget.MediaController; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_side_by_side);
//Utils.setActionBarSubtitleEllipsizeMiddle(this);
mAndroidVideoView = (android.widget.VideoView) findViewById(R.id.androidvv);
mItecVideoView = (VideoView) findViewById(R.id.itecvv);
mMediaPlayerControl = new MediaPlayerMultiControl(mAndroidVideoView, mItecVideoView);
mMediaController = new MediaController(this);
mMediaController.setAnchorView(findViewById(R.id.container));
mMediaController.setMediaPlayer(mMediaPlayerControl);
mPath = getIntent().getStringExtra("play");
mTitle = getIntent().getStringExtra("play");
if(StringUtils.isHttp(mPath)) {
if (!checkWifi()) {
ToastUtil.showMessage(getString(R.string.network_waste));
wifiStateDlg();
return;
}
}
loadVideo();
}
示例6: onResume
import android.widget.MediaController; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
// ReceiverをRegister
IntentFilter mIntentFilter = new IntentFilter();
mIntentFilter.addAction(VideoConst.SEND_HOSTDP_TO_VIDEOPLAYER);
registerReceiver(mReceiver, mIntentFilter);
MediaController mMediaController = new MediaController(this);
mMediaController.setVisibility(View.GONE);
mMediaController.setAnchorView(mVideoView);
mVideoView.setMediaController(mMediaController);
mVideoView.setKeepScreenOn(true);
mVideoView.setVideoURI(mUri);
mVideoView.requestFocus();
mVideoView.setOnCompletionListener(this);
mVideoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(final MediaPlayer mp) {
mVideoView.start();
mIsReady = true;
}
});
}
示例7: onCreate
import android.widget.MediaController; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
mVideo = (Video)getIntent().getSerializableExtra(Video.INTENT_EXTRA_VIDEO);
View root = findViewById(R.id.root);
mediaController = new MediaController(this);
//overscan safe on 1980 * 1080 TV
mediaController.setPadding(48, 27, 48, 27);
mediaController.setAnchorView(root);
shutterView = findViewById(R.id.shutter);
surfaceView = (VideoSurfaceView) findViewById(R.id.surface_view);
surfaceView.getHolder().addCallback(this);
preparePlayer();
}
示例8: onCreate
import android.widget.MediaController; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
mVideo = (Video) getIntent().getSerializableExtra(Video.INTENT_EXTRA_VIDEO);
View root = findViewById(R.id.root);
mediaController = new MediaController(this);
//overscan safe on 1980 * 1080 TV
mediaController.setPadding(48, 27, 48, 27);
mediaController.setAnchorView(root);
shutterView = findViewById(R.id.shutter);
surfaceView = (VideoSurfaceView) findViewById(R.id.surface_view);
surfaceView.getHolder().addCallback(this);
preparePlayer();
}
示例9: onCreate
import android.widget.MediaController; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.rsb_activity_video_viewer);
videoView = (AssetVideoView) findViewById(R.id.videoView);
MediaController mediaController = new MediaController(this, false);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
try {
String videoPath = getIntent().getStringExtra(KEY_RELATIVE_PATH);
AssetFileDescriptor afd = getAssets().openFd(videoPath);
videoView.setVideoDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
videoView.start();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例10: onCreate
import android.widget.MediaController; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PreferencesState.getInstance().initalizateActivityDependencies();
setContentView(R.layout.video_activity);
//Displays a video file.
MediaController mediaController = new MediaController(VideoActivity.this);
mVideoView = (VideoView) findViewById(R.id.videoview);
String videoPathParam = getIntent().getStringExtra(VIDEO_PATH_PARAM);
File file = new File(videoPathParam);
if (file.exists()) {
mVideoView.setVideoPath(videoPathParam);
} else {
mVideoView.setVideoURI(FileIOUtils.getRawUri(videoPathParam));
}
mVideoView.setMediaController(mediaController);
mediaController.setAnchorView(mVideoView);
mVideoView.requestFocus();
if (savedInstanceState != null) {
mVideoView.seekTo(savedInstanceState.getInt("video", 0));
}
mVideoView.start();
}
示例11: fromListView
import android.widget.MediaController; //导入方法依赖的package包/类
public void fromListView(String url) {
//VideoView vidView = (VideoView) findViewById(R.id.videoView1);
MediaController vidControl = new MediaController(this);
vidControl.setAnchorView(view);
view.setMediaController(vidControl);
if (url != null) {
//videoPath.setText(url);
view.setVideoPath(url);
} else {
view.setVideoPath("/sdcard/Download/Home/Home.mp4");
}
view.start();
}
示例12: init
import android.widget.MediaController; //导入方法依赖的package包/类
/**
* Initializes the video view. Is called by {@link APWidgetContainer}
* as it is added to it.
*/
public void init(PApplet pApplet) {
this.pApplet = pApplet;
if (view == null) {
view = new MyVideoView(pApplet);
}
((VideoView) view).setZOrderMediaOverlay(true);
if (hasMediaController) {
MediaController mediaController = new MediaController(pApplet);
mediaController.setAnchorView(((VideoView) view));
((VideoView) view).setMediaController(mediaController);
}
if (videoPath != null) {
((VideoView) view).setVideoPath(videoPath);
}
((VideoView) view).setOnCompletionListener(this);
((VideoView) view).setOnPreparedListener(this);
((VideoView) view).setOnErrorListener(this);
super.init(pApplet);
}
示例13: onCreate
import android.widget.MediaController; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_videoview);
Utils.setActionBarSubtitleEllipsizeMiddle(this);
mVideoView = (VideoView) findViewById(R.id.vv);
mProgress = (ProgressBar) findViewById(R.id.progress);
mMediaPlayerControl = mVideoView; //new MediaPlayerDummyControl();
mMediaController = new MediaController(this);
mMediaController.setAnchorView(findViewById(R.id.container));
mMediaController.setMediaPlayer(mMediaPlayerControl);
mMediaController.setEnabled(false);
mProgress.setVisibility(View.VISIBLE);
// Init video playback state (will eventually be overwritten by saved instance state)
mVideoUri = getIntent().getData();
mVideoPosition = 0;
mVideoPlaybackSpeed = 1;
mVideoPlaying = false;
}
示例14: play
import android.widget.MediaController; //导入方法依赖的package包/类
private void play() {
mProgressBar.setVisibility(View.VISIBLE);
Uri videoUri = Uri.parse(mVideoUrl);
try {
mVideoView.setOnCompletionListener(this);
mVideoView.setOnPreparedListener(this);
mVideoView.setOnErrorListener(this);
mVideoView.setVideoURI(videoUri);
mMediaController = new MediaController(this);
mMediaController.setAnchorView(mVideoView);
mMediaController.setMediaPlayer(mVideoView);
if (!mControls) {
mMediaController.setVisibility(View.GONE);
}
mVideoView.setMediaController(mMediaController);
} catch (Throwable t) {
Log.d(TAG, t.toString());
}
}
示例15: onCreate
import android.widget.MediaController; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_simple_video_player);
VideoView videoView =(VideoView)findViewById(R.id.simple_video_player_video_view);
MediaController mediaController= new MediaController(this);
mediaController.setAnchorView(videoView);
// Uri uri= Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.test_video);
// videoView.setMediaController(mediaController);
// videoView.setVideoURI(uri);
// videoView.requestFocus();
//
// videoView.start();
}