VideoView setOnCompletionListener - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for VideoView setOnCompletionListener method.

This code example shows how to use the following methods:setOnCompletionListener, setOnErrorListener
    public RhoVideoView(ViewGroup view, CustomViewCallback viewCallback) {
        mCustomView = view;
        mVideoView = (VideoView)view.getFocusedChild();
        mCustomViewCallback = viewCallback;
         
        mVideoView.setOnCompletionListener(this);
        mVideoView.setOnErrorListener(this);
    } 
     
    @Override 
    public boolean onError(MediaPlayer mp, int what, int extra) {
        Logger.E(TAG, "Media player error: " + ((what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) ? "media server died" : "unknown"));
        return false; 
    } 
 
    @Override 
    public void onCompletion(MediaPlayer player) {
        player.stop();
    } 
 
7
CodeRank
This code example shows how to use the following methods:requestFocus, setOnCompletionListener, setOnPreparedListener, setVideoURI
		sMovie = this;
		 
		RelativeLayout layout = new RelativeLayout ( this );
		layout.setGravity ( Gravity.CENTER );
		 
		mVideoView = new VideoView ( this );
		mVideoView.setOnPreparedListener ( this );
        mVideoView.setOnCompletionListener ( this );
 
		layout.addView ( mVideoView, new RelativeLayout.LayoutParams ( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT ));
		setContentView ( layout );		
		 
		String url = this.getIntent ().getStringExtra ( "url" );
		 
		MoaiLog.i ( "MoaiMoviePlayer onCreate: Initializing video player with media URL " + url );
 
		mVideoView.setVideoURI ( Uri.parse ( url ));
		mVideoView.requestFocus ();
	}	 
 

9
CodeRank
This code example shows how to use the following methods:setOnCompletionListener, setVideoPath
			v.start();
		} 
	} 
	 
	public View createView(Context c) {
		v = new VideoView(c);
		v.setOnCompletionListener(this);
		v.setVideoPath(this.getResource() );
		this.layout = new RelativeLayout(c);
		this.layout.setPadding(getLeft(), getTop(), 0, 0);
		this.layout.addView(this.v, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT) );
		this.layout.setVisibility(View.GONE);
		return layout;
	} 
	 
	public View getView() {
		return layout;
	} 
	 
	public void onCompletion(MediaPlayer arg0) {
5
CodeRank
This code example shows how to use the following methods:setMediaController, setOnCompletionListener, setOnErrorListener, setOnPreparedListener
  public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.video_surface, container, false);
    this.progress = view.findViewById(R.id.progress);
    final VideoView videoView = (VideoView)view.findViewById(R.id.video);
    this.videoView = videoView;
    videoView.setOnPreparedListener(this);
    videoView.setOnErrorListener(this);
    videoView.setOnCompletionListener(this);
    this.controller = new MediaController(getOwnerActivity());
    videoView.setMediaController(controller);
    return view;
  } 
 
  @Override 
  public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    openVideo(); 
  } 
 
  @Override 
6
CodeRank
This code example shows how to use the following methods:setZOrderOnTop, setMediaController, setOnCompletionListener
	 
	public VideoView getVideoView()
	{ 
		if (_videoView == null)
		{ 
			_videoView = new VideoView(getActivity());
			_videoView.setZOrderOnTop(true);
			_videoView.setMediaController(new MediaController(getActivity()));
			_videoView.setOnCompletionListener(this);
		} 
		 
		return _videoView;
	} 
	 
	public void onCompletion(MediaPlayer mp)
	{ 
		dispatchStatusEventAsync("PLAYBACK_DID_FINISH", "OK"); 
	} 
} 
6
CodeRank
This code example shows how to use the following methods:setMediaController, setOnCompletionListener, setVideoURI, start
	Uri location;
	private EpicClickListener listener;
 
	public EpicNativeVideoWidget(String stringLocation, EpicClickListener l) {
		this.listener = l;
		t = new VideoView(EpicAndroidActivity.getCurrentAndroidActivity());
		t.setOnCompletionListener(this);
		this.location = Uri.parse(stringLocation);
		t.setVideoURI(this.location);
        t.setMediaController(new MediaController(EpicAndroidActivity.getCurrentAndroidActivity()));
//      t.requestFocus(); 
        t.start();
	} 
 
	View getAndroidView() {
		return t;
	} 
 
	public void onCompletion(MediaPlayer arg0) {
		this.listener.onClick();
6
CodeRank
This code example shows how to use the following methods:setOnTouchListener, setOnCompletionListener, stopPlayback
	 * Release media player, assets, listeners, etc. Load up the Caster activity 
	 */ 
	private void loadNextLevel() { 
		Log.e(TAG, "finished. Loading Caster");
		try { 
			travel.stopPlayback();
        	Intent ourIntent = new Intent(TravelScene.this, Class.forName("org.MAG.Caster"));
        	travel.setOnTouchListener(null);
        	travel.setOnCompletionListener(null);
        	ourIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(ourIntent);
			finish();
		} catch (ClassNotFoundException ex) {
			Log.e(TAG, "Failed to jump to another activity");
		} 
	} 
 
	public void onCompletion(MediaPlayer mp) {
		loadNextLevel(); 
	} 
6
CodeRank
This code example shows how to use the following methods:setOnCompletionListener, setVideoURI
        } 
    } 
    public VideoView createVideoView(String resourcePath) {
        if(video==null){
            Log.i(TAG, "Creating video view");
            video = new VideoView(GameActivity.getContext());
            video.setOnCompletionListener(this);
            Log.i(TAG, "Setting...");
			try{ 
				GameActivity.pushView(video);
			}catch(Exception e){
				Log.e(TAG,"Ruh roh");
			} 
            Log.i(TAG, "Video view set as current");
        }else{ 
            video.stopPlayback();
        } 
        Log.i(TAG, "Setting video uri");
        video.setVideoURI(Utils.buildResourceUri(GameActivity.getContext(), GameActivity.getResourceID(resourcePath)));
        return video;

6
CodeRank
This code example shows how to use the following methods:setMediaController, setOnCompletionListener, setOnPreparedListener, setVideoPath
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		appMediaPlayerFunctionLayoutParams = new AppMediaPlayerFunctionLayoutParams(this);
		appMediaPlayerFunctionLayoutParams.initParams();
		initLayoutAndCompont(); 
		mVideoView.setOnCompletionListener(this);
		mVideoView.setOnPreparedListener(this);
		if(!(getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_VIEW ))){
			 mVideoFileName = getIntent().getExtras().getString("file_name");
			 AppLog.e("mVideoFileName", mVideoFileName);
			 mVideoFilePosition = getIntent().getExtras().getInt("file_position");
		} 
		if (mVideoFileName == null)
		{ 
			mVideoFileName = getRealPath(getIntent().getData());
		} 
		mVideoView.setVideoPath(mVideoFileName);
		mVideoView.setMediaController(mController);
	} 
	AppMediaPlayerFunctionLayoutParams appMediaPlayerFunctionLayoutParams;

8
CodeRank
This code example shows how to use the following methods:setOnCompletionListener, setVideoPath, start
	 */ 
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
		VideoView videoView = new VideoView(this);
		videoView.setOnCompletionListener(new OnCompletionListener() {
			@Override 
			public void onCompletion(MediaPlayer mp) {
				finish();
			} 
		}); 
 
		setContentView(videoView);
 
		String path = findVideo();
		if (path != null) {
			videoView.setVideoPath(path);
			videoView.start();
		} else { 

6
CodeRank

Related VideoView setOnCompletionListener Questions & Answers:

setOnCompletionListener Method Overview
Register a callback to be invoked when the end of a media file has been reached during playback.
See Code Examples for other Android VideoView Methods: