Java 类android.widget.MediaController 实例源码
项目:apps_small
文件:MainActivity.java
@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();
}
项目:AndroidFFmpegCompress
文件:VideoPlayerActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
VideoView videoView = new VideoView(this);
setContentView(videoView);
videoView.setMediaController(new MediaController(this));
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
Toast.makeText( VideoPlayerActivity.this, "播放完成了", Toast.LENGTH_SHORT).show();
}
});
String videoPath = getIntent().getStringExtra("videoPath");
try {
videoView.setVideoPath(videoPath);
videoView.start();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(VideoPlayerActivity.this, "视频不存在", Toast.LENGTH_SHORT).show();
}
}
项目:Simpler
文件:VideoPlayerActivity.java
private void init() {
BaseConfig.sPositionWhenPaused = -1;
// Create media controller
MediaController mediaController = new MediaController(this);
// 设置MediaController
mVideoView.setMediaController(mediaController);
mVideoView.setOnCompletionListener(this);
mVideoView.setOnErrorListener(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
mVideoView.setOnInfoListener(this);
} else {
mLoadingView.setVisibility(View.GONE);
}
mVideoView.setOnPreparedListener(this);
mGestureDetector = new GestureDetector(this, new MyGestureListener());
Uri uri = Uri.parse(mVideoUrl);
mVideoView.setVideoURI(uri);
}
项目:YCGallery
文件:VideoPlayerActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String url = getIntent().getExtras().getString(Constants.URL);
setContentView(R.layout.fragment_video_gallery);
final VideoView videoView = (VideoView) findViewById(R.id.videoView);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
View progress = findViewById(R.id.videoProgress);
progress.setVisibility(View.GONE);
videoView.requestFocus();
MediaController vidControl = new MediaController(VideoPlayerActivity.this);
vidControl.setAnchorView(videoView);
videoView.setMediaController(vidControl);
videoView.start();
}
});
videoView.setVideoURI(Uri.parse(url));
}
项目:appinventor-extensions
文件:VideoPlayer.java
/**
* Creates a new VideoPlayer component.
*
* @param container
*/
public VideoPlayer(ComponentContainer container) {
super(container);
container.$form().registerForOnDestroy(this);
videoView = new ResizableVideoView(container.$context());
videoView.setMediaController(new MediaController(container.$context()));
videoView.setOnCompletionListener(this);
videoView.setOnErrorListener(this);
videoView.setOnPreparedListener(this);
// add the component to the designated container
container.$add(this);
// set a default size
container.setChildWidth(this,
ComponentConstants.VIDEOPLAYER_PREFERRED_WIDTH);
container.setChildHeight(this,
ComponentConstants.VIDEOPLAYER_PREFERRED_HEIGHT);
// Make volume buttons control media, not ringer.
container.$form().setVolumeControlStream(AudioManager.STREAM_MUSIC);
sourcePath = "";
}
项目:youtube_background_android
文件:DownloadedFragment.java
@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;
}
});
}
}
项目:AC2RD
文件:ThemeManager.java
public void setMediaController(Context context, View view)
{
if (view instanceof MediaController) {
MediaController v = (MediaController) view;
for (int i = 0; i < v.getChildCount(); i++)
{
this.setMediaController(context, v.getChildAt(i));
}
}
else if (view instanceof LinearLayout)
{
LinearLayout ll = (LinearLayout) view;
for (int i = 0; i < ll.getChildCount(); i++)
{
this.setMediaController(context, ll.getChildAt(i));
}
}
else if (view instanceof SeekBar)
{
((SeekBar) view).getProgressDrawable().mutate().setColorFilter(context.getResources().getColor(getColorTheme(context)),PorterDuff.Mode.SRC_IN);
}
}
项目:FBVideoUploader
文件:UploadVideoActivity.java
private void onVideoReady() {
MediaController mediaController = new MediaController(this);
videoViewPreview.setVisibility(View.VISIBLE);
videoViewPreview.setVideoPath(videoFileName);
videoViewPreview.setMediaController(mediaController);
videoViewPreview.requestFocus();
videoViewPreview.start();
videoViewPreview.pause();
textViewFilePath.setText(videoFileName);
editTextVideoTitle.setText("");
editTextVideoDescription.setText("");
textViewVideoUrl.setText(getString(R.string.noUrlYet));
Toast.makeText(this, R.string.pressVideoToPreview, Toast.LENGTH_LONG).show();
}
项目:YouTubeUploader
文件:UploadVideoActivity.java
private void onVideoReady() {
MediaController mediaController = new MediaController(this);
videoViewPreview.setVisibility(View.VISIBLE);
videoViewPreview.setVideoPath(videoFileName);
videoViewPreview.setMediaController(mediaController);
videoViewPreview.requestFocus();
videoViewPreview.start();
videoViewPreview.pause();
imageButtonUploadVideo.setEnabled(true);
imageButtonUploadVideo.setImageResource(R.drawable.upload);
textViewFilePath.setText(videoFileName);
editTextVideoTitle.setText("");
editTextVideoDescription.setText("");
textViewVideoUrl.setText(getString(R.string.noUrlYet));
Toast.makeText(this, R.string.pressVideoToPreview, Toast.LENGTH_LONG).show();
}
项目:android-lite
文件:VideoActivity.java
@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);
}
项目:audiolibros
文件:DetalleFragment.java
private void ponInfoLibro(int id, View vista) {
/*Libro*/ libro = ((Aplicacion) getActivity().getApplication())
.getVectorLibros().elementAt(id);
((TextView) vista.findViewById(R.id.titulo)).setText(libro.titulo);
((TextView) vista.findViewById(R.id.autor)).setText(libro.autor);
((ImageView) vista.findViewById(R.id.portada))
.setImageResource(libro.recursoImagen);
vista.setOnTouchListener(this);
if (mediaPlayer != null){
mediaPlayer.release();
}
mediaPlayer = new MediaPlayer();
mediaPlayer.setOnPreparedListener(this);
mediaController = new MediaController(getActivity());
Uri audio = Uri.parse(libro.urlAudio);
try {
mediaPlayer.setDataSource(getActivity(), audio);
mediaPlayer.prepareAsync();
} catch (IOException e) {
Log.e("Audiolibros", "ERROR: No se puede reproducir "+audio,e);
}
}
项目:android-oss
文件:VideoActivity.java
@Override
public void onCreate(final @Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_player_layout);
ButterKnife.bind(this);
this.viewModel.outputs.preparePlayerWithUrl()
.compose(Transformers.takeWhen(lifecycle().filter(ActivityEvent.RESUME::equals)))
.compose(bindToLifecycle())
.subscribe(this::preparePlayer);
this.mediaController = new MediaController(this);
this.mediaController.setAnchorView(this.rootView);
RxView.clicks(this.rootView)
.compose(bindToLifecycle())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(__ -> toggleControlsVisibility());
}
项目:Marv
文件:VideoFull.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_full);
videofull=(VideoView)findViewById(R.id.videofull);
videofull.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video));
videofull.setMediaController(new MediaController(VideoFull.this));
videofull.start();
videofull.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
videofull.requestFocus();
}
项目:StraaS-android-sdk-sample
文件:PlayerControl.java
public PlayerControl(@NonNull MediaControllerCompat mediaControllerCompat, final MediaController mediaController) {
mMediaControllerCompat = mediaControllerCompat;
mCallback = new MediaControllerCompat.Callback() {
@Override
public void onPlaybackStateChanged(PlaybackStateCompat state) {
processPlaybackState(state, mediaController);
}
@Override
public void onMetadataChanged(MediaMetadataCompat metadata) {
mLastMediaMetadataCompat = metadata;
}
};
mMediaControllerCompat.registerCallback(mCallback);
mLastMediaMetadataCompat = mMediaControllerCompat.getMetadata();
processPlaybackState(mMediaControllerCompat.getPlaybackState(), mediaController);
}
项目:ScrollGallery-android
文件:VideoPlayerActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String url = getIntent().getExtras().getString(Constants.URL);
setContentView(R.layout.video_fragment);
final VideoView videoView = (VideoView) findViewById(R.id.videoView);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
View progress = findViewById(R.id.videoProgress);
progress.setVisibility(View.GONE);
videoView.requestFocus();
MediaController vidControl = new MediaController(VideoPlayerActivity.this);
vidControl.setAnchorView(videoView);
videoView.setMediaController(vidControl);
videoView.start();
}
});
videoView.setVideoURI(Uri.parse(url));
}
项目:EDSApp
文件:VideoActivity.java
@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();
}
项目:youkes_vr
文件:SideBySideVideoPlayActivity.java
@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();
}
项目:galactic-tavern-android
文件:VideoPlayerActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String url = getIntent().getExtras().getString(Constants.URL);
setContentView(R.layout.video_fragment);
final VideoView videoView = (VideoView) findViewById(R.id.videoView);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
View progress = findViewById(R.id.videoProgress);
progress.setVisibility(View.GONE);
videoView.requestFocus();
MediaController vidControl = new MediaController(VideoPlayerActivity.this);
vidControl.setAnchorView(videoView);
videoView.setMediaController(vidControl);
videoView.start();
}
});
videoView.setVideoURI(Uri.parse(url));
}
项目:DeviceConnect-Android
文件:VideoPlayer.java
@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;
}
});
}
项目:alternate-java-bridge-library
文件:VideoPlayer.java
/**
* Creates a new VideoPlayer component.
*
* @param container
*/
public VideoPlayer(ComponentContainer container) {
super(container);
videoView = new VideoView(container.$context());
videoView.setMediaController(new MediaController(container.$context()));
videoView.setOnCompletionListener(this);
videoView.setOnErrorListener(this);
// add the component to the designated container
container.$add(this);
// set a default size
container.setChildWidth(this, ComponentConstants.VIDEOPLAYER_PREFERRED_WIDTH);
container.setChildHeight(this, ComponentConstants.VIDEOPLAYER_PREFERRED_HEIGHT);
container.$form().registerForOnInitialize(this);
sourcePath = "";
}
项目:AudioVideo
文件:MainFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View myView = inflater.inflate(R.layout.fragment_main, container, false);
mVideoView = (VideoView)myView.findViewById(R.id.videoView1);
mVideoView.setMediaController(new MediaController(getActivity()));
//setup the button take a video.
Button btn1 = (Button)myView.findViewById(R.id.button1);
btn1.setOnClickListener( new View.OnClickListener(){
@Override
public void onClick(View v) {
//create an intent to have the default video record take a video.
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (takeVideoIntent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivityForResult(takeVideoIntent, MainActivity.REQUEST_VIDEO_CAPTURE);
}
}
});
return myView;
}
项目:AudioVideo
文件:MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mVideoView = (VideoView)findViewById(R.id.videoView1);
mVideoView.setMediaController(new MediaController(this));
//setup the button take a video.
Button btn1 = (Button)findViewById(R.id.button1);
btn1.setOnClickListener( new View.OnClickListener(){
@Override
public void onClick(View v) {
//create an intent to have the default video record take a video.
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
}
}
});
}
项目:AudioVideo
文件:videoPlay.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Get the ViewView
vv = (VideoView) this.findViewById( R.id.videoView);
//add media controls to it.
vv.setMediaController(new MediaController(this));
//Setup where the file to play is
//on the SDcard in the root directory. Not you need permissions to read the external storage.
//Uri videoUri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/the-empire.3gp");
//Log.v("path",Environment.getExternalStorageDirectory().getPath() );
//via the web. Note you need Internet permissions.
Uri videoUri = Uri.parse("http://www.cs.uwyo.edu/~seker/courses/4730/example/the-empire.3gp");
vv.setVideoURI(videoUri);
//play the video
vv.start();
}
项目:AudioVideo
文件:MainFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View myView = inflater.inflate(R.layout.fragment_main, container, false);
//Get the ViewView
vv = (VideoView) myView.findViewById( R.id.videoView);
//add media controls to it. //note, in a fragment, this dies... don't know why.
// in both frag and activity these are are wrong: getApplicationContext() and getBaseContext()
//It's not context, actually needs the activity, so it can display the controls to the screen.
vv.setMediaController(new MediaController(getActivity()));
//Setup where the file to play is
//on the SDcard in the root directory. Now you need permissions to read the external storage.
//Uri videoUri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/the-empire.3gp");
//Log.v("path",Environment.getExternalStorageDirectory().getPath() );
//via the web. Note you need Internet permissions.
Uri videoUri = Uri.parse("http://www.cs.uwyo.edu/~seker/courses/4730/example/the-empire.3gp");
vv.setVideoURI(videoUri);
//play the video
vv.start();
return myView;
}
项目:android-tv-leanback
文件:PlayerActivity.java
@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();
}
项目:android-tv-leanback
文件:PlayerActivity.java
@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();
}
项目:android-tv-leanback
文件:PlayerActivity.java
@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();
}
项目:android-tv-leanback
文件:PlayerActivity.java
@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();
}
项目:ResearchStack
文件:ViewVideoActivity.java
@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);
}
}
项目:malariapp
文件:VideoActivity.java
@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();
}
项目:ScrollGalleryView
文件:VideoPlayerActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String url = getIntent().getExtras().getString(Constants.URL);
setContentView(R.layout.video_fragment);
final VideoView videoView = (VideoView) findViewById(R.id.videoView);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
View progress = findViewById(R.id.videoProgress);
progress.setVisibility(View.GONE);
videoView.requestFocus();
MediaController vidControl = new MediaController(VideoPlayerActivity.this);
vidControl.setAnchorView(videoView);
videoView.setMediaController(vidControl);
videoView.start();
}
});
videoView.setVideoURI(Uri.parse(url));
}
项目:goprohero
文件:LiveStuff.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_live_stuff);
myVideoView = (VideoView)this.findViewById(R.id.videoView);
MediaController mc = new MediaController(this);
myVideoView.setMediaController(mc);
urlStream = "http://10.5.5.9:8080/live/amba.m3u8";
runOnUiThread(new Runnable() {
@Override
public void run() {
myVideoView.setVideoURI(Uri.parse(urlStream));
myVideoView.start();
}
});
}
项目:BrillaMXAndroid
文件:VideoBMX.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_bmx);
String uriPath = "android.resource://mx.ambmultimedia.brillamexico/raw/bmx_video";
Uri uri = Uri.parse(uriPath);
video = (VideoView) findViewById(R.id.videoView);
video.setVideoURI(uri);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(video);
video.setMediaController(mediaController);
video.start();
video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer vmp) {
Intent intent = new Intent(VideoBMX.this, LoginStep1.class);
startActivity(intent);
}
});
}
项目:Weedsim
文件:TutorialFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_tutorial, container,
false);
this.view = rootView;
getActivity().runOnUiThread(new Runnable() {
public void run() {
String mUrl = "android.resource://" + getActivity().getPackageName() + "/" + R.raw.bbb;
VideoView mVideoView = (VideoView) view
.findViewById(R.id.videoView1);
MediaController videoMediaController = new MediaController(getActivity());
mVideoView.setVideoPath(mUrl);
mVideoView.setKeepScreenOn(true);
videoMediaController.setMediaPlayer(mVideoView);
mVideoView.setMediaController(videoMediaController);
mVideoView.requestFocus();
mVideoView.start();
}
});
return rootView;
}
项目:message-samples-android
文件:VideoViewActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_view);
ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setDisplayHomeAsUpEnabled(true);
}
String imageUrl = getIntent().getStringExtra("videoUrl");
Uri uri = Uri.parse(imageUrl);
vidMessageVideo = (VideoView)findViewById(R.id.vidMessageVideo);
vidMessageVideo.setMediaController(new MediaController(this));
vidMessageVideo.setVideoURI(uri);
vidMessageVideo.requestFocus();
vidMessageVideo.start();
}
项目:android-course
文件:Main.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView v = (VideoView) findViewById(R.id.videoView);
// v.setVideoPath("/sdcard/video.mp4");
v.setVideoURI(Uri.parse(String.format(
"android.resource://%s/%s",
getPackageName(),
R.raw.video
)));
v.setMediaController(new MediaController(this));
v.requestFocus();
v.start();
}
项目:kolabnotes-android
文件:PreviewFragment.java
void displayAudio(ActiveAccount account, String noteUID,Attachment attachment){
musicView.setVisibility(View.VISIBLE);
try {
nowPlayingView.setText(attachment.getFileName());
mediaPlayer = new MediaPlayer();
mediaPlayer.setOnPreparedListener(this);
mediaController = new MediaController(getActivity());
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(getActivity(), attachmentRepository.getUriFromAttachment(account.getAccount(), account.getRootFolder(), noteUID, attachment));
mediaPlayer.prepare();
mediaController.show(0);
}catch (IOException e){
Toast.makeText(getActivity(), R.string.attachment_not_previewable, Toast.LENGTH_LONG).show();
}
}
项目:learn-android-examples
文件:VideoManager.java
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();
}
项目:4pdaClient-plus
文件:PlayerActivity.java
private void playVideo(VideoItem parseResult, Uri pResult) {
try {
createActionMenu(parseResult);
mSeekTo = mVideoView.getCurrentPosition();
Log.e("TEST", "URI " + pResult);
mVideoView.setVideoURI(pResult);
mVideoView.setMediaController(new MediaController(this));
mVideoView.setKeepScreenOn(true);
mVideoView.requestFocus();
mVideoView.start();
} catch (Throwable ex) {
AppLog.toastE(getContext(), ex);
}
}
项目:apwidgets
文件:APVideoView.java
/**
* 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);
}