当前位置: 首页>>代码示例>>Java>>正文


Java VideoView.setMediaController方法代码示例

本文整理汇总了Java中android.widget.VideoView.setMediaController方法的典型用法代码示例。如果您正苦于以下问题:Java VideoView.setMediaController方法的具体用法?Java VideoView.setMediaController怎么用?Java VideoView.setMediaController使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.VideoView的用法示例。


在下文中一共展示了VideoView.setMediaController方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@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();
}
 
开发者ID:siddhantvinchurkar,项目名称:Marv,代码行数:17,代码来源:VideoFull.java

示例2: onCreate

import android.widget.VideoView; //导入方法依赖的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();

}
 
开发者ID:alaskalinuxuser,项目名称:apps_small,代码行数:26,代码来源:MainActivity.java

示例3: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@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();
    }
}
 
开发者ID:mChenys,项目名称:AndroidFFmpegCompress,代码行数:22,代码来源:VideoPlayerActivity.java

示例4: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);

    mVideoPath = getIntent().getStringExtra("videoPath");

    if (!TextUtils.isEmpty(mVideoPath)) {
        new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
    }

    videoView = (VideoView) findViewById(R.id.view_video);

    android.widget.MediaController mediaController = new android.widget.MediaController(this);
    videoView.setMediaController(mediaController);
    videoView.setVideoPath(mVideoPath);
    videoView.start();
}
 
开发者ID:tryBetter,项目名称:minVideo,代码行数:19,代码来源:VideoActivity.java

示例5: onCreate

import android.widget.VideoView; //导入方法依赖的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);
}
 
开发者ID:crm416,项目名称:android-lite,代码行数:18,代码来源:VideoActivity.java

示例6: onCreate

import android.widget.VideoView; //导入方法依赖的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();
}
 
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:21,代码来源:VideoActivity.java

示例7: VideoPlayer

import android.widget.VideoView; //导入方法依赖的package包/类
/**
 * 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 = "";
}
 
开发者ID:roadlabs,项目名称:alternate-java-bridge-library,代码行数:22,代码来源:VideoPlayer.java

示例8: onCreateView

import android.widget.VideoView; //导入方法依赖的package包/类
@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;
}
 
开发者ID:JimSeker,项目名称:AudioVideo,代码行数:24,代码来源:MainFragment.java

示例9: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@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();

}
 
开发者ID:JimSeker,项目名称:AudioVideo,代码行数:22,代码来源:videoPlay.java

示例10: onCreateView

import android.widget.VideoView; //导入方法依赖的package包/类
@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;
}
 
开发者ID:JimSeker,项目名称:AudioVideo,代码行数:25,代码来源:MainFragment.java

示例11: onCreate

import android.widget.VideoView; //导入方法依赖的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();
}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:26,代码来源:VideoActivity.java

示例12: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@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();
        }

    });

}
 
开发者ID:KonradIT,项目名称:goprohero,代码行数:19,代码来源:LiveStuff.java

示例13: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@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);
        }
    });
}
 
开发者ID:dannegm,项目名称:BrillaMXAndroid,代码行数:25,代码来源:VideoBMX.java

示例14: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@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();
}
 
开发者ID:magnetsystems,项目名称:message-samples-android,代码行数:20,代码来源:VideoViewActivity.java

示例15: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@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();
    }
 
开发者ID:acelaya,项目名称:android-course,代码行数:17,代码来源:Main.java


注:本文中的android.widget.VideoView.setMediaController方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。