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


Java VideoView.setOnCompletionListener方法代码示例

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


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

示例1: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@Override

        protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//强制竖屏
            final VideoView vv=new VideoView(this.getContext());
            RelativeLayout rlmain=new RelativeLayout(this.getContext());
            this.setContentView(vv);
            TextView txt=new TextView(rlmain.getContext());
            rlmain.addView(txt);
            txt.setText("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
//            rlmain.setBackgroundColor(Color.RED);
            vv.setVideoPath("/sdcard/mwwyt.mpg");
            vv.start();

            vv.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                @Override
                public void onCompletion(MediaPlayer mp) {
                    vv.start();
                }
            });


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

示例2: init

import android.widget.VideoView; //导入方法依赖的package包/类
private void init(String videoPath) {
    setContentView(R.layout.activity_trim);
    TextView duration = (TextView) findViewById(R.id.duration);
    mPreview = (VideoView) findViewById(R.id.preview);

    mShortVideoTrimmer = new PLShortVideoTrimmer(this, videoPath, Config.TRIM_FILE_PATH);
    mMediaFile = new PLMediaFile(videoPath);

    mSelectedEndMs = mDurationMs = mMediaFile.getDurationMs();
    duration.setText("时长: " + formatTime(mDurationMs));
    Log.i(TAG, "video duration: " + mDurationMs);

    mVideoFrameCount = mMediaFile.getVideoFrameCount(false);
    Log.i(TAG, "video frame count: " + mVideoFrameCount);

    mPreview.setVideoPath(videoPath);
    mPreview.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mediaPlayer) {
            play();
        }
    });

    initVideoFrameList();
}
 
开发者ID:pili-engineering,项目名称:PLDroidShortVideo,代码行数:26,代码来源:VideoTrimActivity.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: initPlayer

import android.widget.VideoView; //导入方法依赖的package包/类
public static void initPlayer(VideoView videoView, OnPreparedListener onPreparedListener,
                              OnCompletionListener onCompletionListener, OnErrorListener
                                      onErrorListener) {
    if (onPreparedListener != null) {
        videoView.setOnPreparedListener(onPreparedListener);
    }
    if (onCompletionListener != null) {
        videoView.setOnCompletionListener(onCompletionListener);
    }
    if (onErrorListener != null) {
        videoView.setOnErrorListener(onErrorListener);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:VideoPlayerManager.java

示例5: onCreate

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

    enableLayoutFullScreen();

    mVideoView = (VideoView) findViewById(R.id.video_view);
    playView = (ImageView) findViewById(R.id.play_view);

    playView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            playView.setVisibility(View.GONE);
            mVideoView.start();
        }
    });

    String videoPath = getIntent().getStringExtra(KEY_VIDEO_PATH);

    mVideoView.setVideoPath(videoPath);
    mVideoView.start();

    mVideoView.setOnCompletionListener(this);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:26,代码来源:VideoPlayActivity.java

示例6: 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

示例7: 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

示例8: onCreate

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

  vv=new VideoView(this, null);
  setContentView(vv,
    new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT,
      Gravity.CENTER));
  vv.setVideoURI(getIntent().getData());
  vv.setOnCompletionListener(this);
  vv.start();

  if (savedInstanceState!=null) {
    vv.seekTo(savedInstanceState.getInt(STATE_OFFSET, 0));
  }
}
 
开发者ID:commonsguy,项目名称:cwac-cam2,代码行数:17,代码来源:VideoPlayerActivity.java

示例9: onShowCustomView

import android.widget.VideoView; //导入方法依赖的package包/类
@Override
public void onShowCustomView(View view, int requestedOrientation, CustomViewCallback callback) {
	if (view == null) {
		return;
	}
	if (mCustomView != null && callback != null) {
		callback.onCustomViewHidden();
		return;
	}
	try {
		view.setKeepScreenOn(true);
	} catch (SecurityException e) {
		Log.e(Constants.TAG, "WebView is not allowed to keep the screen on");
	}
	mOriginalOrientation = getRequestedOrientation();
	FrameLayout decor = (FrameLayout) getWindow().getDecorView();
	mFullscreenContainer = new FullscreenHolder(this);
	mCustomView = view;
	mFullscreenContainer.addView(mCustomView, COVER_SCREEN_PARAMS);
	decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS);
	setFullscreen(true);
	getCurrentWebView().setVisibility(View.GONE);
	if (view instanceof FrameLayout) {
		if (((FrameLayout) view).getFocusedChild() instanceof VideoView) {
			mVideoView = (VideoView) ((FrameLayout) view).getFocusedChild();
			mVideoView.setOnErrorListener(new VideoCompletionListener());
			mVideoView.setOnCompletionListener(new VideoCompletionListener());
		}
	}
	mCustomViewCallback = callback;
}
 
开发者ID:NewCasino,项目名称:browser,代码行数:32,代码来源:BrowserActivity.java

示例10: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
/**
 *  Called when the activity is first created.
 *
 *  Searches for an {@link OCFile} and ownCloud {@link Account} holding it in the starting {@link Intent}.
 *
 *  The {@link Account} is unnecessary if the file is downloaded; else, the {@link Account} is used to
 *  try to stream the remote file - TODO get the streaming works
 *
 *  {@inheritDoc}
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log_OC.v(TAG, "onCreate");

    setContentView(R.layout.video_layout);

    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        mSavedPlaybackPosition = extras.getInt(EXTRA_START_POSITION);
        mAutoplay = extras.getBoolean(EXTRA_AUTOPLAY);

    } else {
        mSavedPlaybackPosition = savedInstanceState.getInt(EXTRA_START_POSITION);
        mAutoplay = savedInstanceState.getBoolean(EXTRA_AUTOPLAY);
    }

    mVideoPlayer = (VideoView) findViewById(R.id.videoPlayer);

    // set listeners to get more contol on the playback
    mVideoPlayer.setOnPreparedListener(this);
    mVideoPlayer.setOnCompletionListener(this);
    mVideoPlayer.setOnErrorListener(this);

    // keep the screen on while the playback is performed (prevents screen off by battery save)
    mVideoPlayer.setKeepScreenOn(true);
}
 
开发者ID:skymania,项目名称:Cirrus,代码行数:38,代码来源:PreviewVideoActivity.java

示例11: onShowCustomView

import android.widget.VideoView; //导入方法依赖的package包/类
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
    if (view == null) {
        return;
    }
    if (mCustomView != null && callback != null) {
        callback.onCustomViewHidden();
        return;
    }
    try {
        view.setKeepScreenOn(true);
    } catch (SecurityException e) {
        Log.e(Constants.TAG, "WebView is not allowed to keep the screen on");
    }
    mOriginalOrientation = getRequestedOrientation();
    FrameLayout decor = (FrameLayout) getWindow().getDecorView();
    mFullscreenContainer = new FrameLayout(this);
    mFullscreenContainer.setBackgroundColor(ContextCompat.getColor(this, android.R.color.black));
    mCustomView = view;
    mFullscreenContainer.addView(mCustomView, COVER_SCREEN_PARAMS);
    decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS);
    setFullscreen(true, true);
    mCurrentView.setVisibility(View.GONE);
    if (view instanceof FrameLayout) {
        if (((FrameLayout) view).getFocusedChild() instanceof VideoView) {
            mVideoView = (VideoView) ((FrameLayout) view).getFocusedChild();
            mVideoView.setOnErrorListener(new VideoCompletionListener());
            mVideoView.setOnCompletionListener(new VideoCompletionListener());
        }
    }
    mCustomViewCallback = callback;
}
 
开发者ID:javadtaghia,项目名称:DeeBrowser,代码行数:33,代码来源:BrowserActivity.java

示例12: MraidVideoViewController

import android.widget.VideoView; //导入方法依赖的package包/类
public MraidVideoViewController(final Context context,
        final Bundle intentExtras,
        final Bundle savedInstanceState,
        final BaseVideoViewControllerListener baseVideoViewControllerListener) {
    // No broadcast identifiers are used by MraidVideoViews.
    super(context, null, baseVideoViewControllerListener);

    mVideoView = new VideoView(context);
    mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mp) {
            mCloseButton.setVisibility(VISIBLE);
            videoCompleted(true);
        }
    });

    mVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
        @Override
        public boolean onError(MediaPlayer mediaPlayer, int what, int extra) {
            mCloseButton.setVisibility(VISIBLE);
            videoError(false);

            return false;
        }
    });

    mVideoView.setVideoPath(intentExtras.getString(VIDEO_URL));
}
 
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:29,代码来源:MraidVideoViewController.java

示例13: initViews

import android.widget.VideoView; //导入方法依赖的package包/类
protected void initViews() {
	mSpinningProgressBar = (ProgressBar) findViewById( R.id.progress_spinner );

	mVideoView = (VideoView) findViewById( R.id.video_view );
	mVideoView.setOnCompletionListener( onCompletionListener );
	mVideoView.setOnErrorListener( onErrorListener );
	mVideoView.setOnPreparedListener( onPreparedListener );

	if( mVideoView == null ) {
		throw new IllegalArgumentException( "Layout must contain a video view with ID video_view" );
	}

	mUri = Uri.parse( getIntent().getExtras().getString( EXTRA_VIDEO_URL ) );
	mVideoView.setVideoURI( mUri );
}
 
开发者ID:Lakkichand,项目名称:AndroidDemoProjects,代码行数:16,代码来源:VideoPlayerActivity.java

示例14: loadVideo

import android.widget.VideoView; //导入方法依赖的package包/类
private void loadVideo() {
	// ~~~ 获取播放地址和标题
	Intent intent = getIntent();
	mPath = intent.getStringExtra("play");
	mTitle = intent.getStringExtra("title");
	if(mTitle==null){
		mTitle="";
	}
	if (mPath==null||TextUtils.isEmpty(mPath)) {
		return;
		//mPath = "http://youkes.oss.aliyuncs.com/video/01_llama_drama_1080p.mp4";
	} else if (intent.getData() != null) {
		//mPath = intent.getData().toString();
	}

	//mPath = "http://youkes.oss.aliyuncs.com/video/01_llama_drama_1080p.mp4";
	
	// ~~~ 绑定控件
	setContentView(R.layout.videoview);
	mVideoView = (VideoView) findViewById(R.id.surface_view);

	mVolumeBrightnessLayout = findViewById(R.id.operation_volume_brightness);
	mOperationBg = (ImageView) findViewById(R.id.operation_bg);
	mOperationPercent = (ImageView) findViewById(R.id.operation_percent);
	mLoadingView = findViewById(R.id.video_loading);

	// ~~~ 绑定事件
	mVideoView.setOnCompletionListener(this);
	mVideoView.setOnInfoListener(this);
	mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
		@Override
		public void onPrepared(MediaPlayer mp) {

			mLoadingView.setVisibility(View.GONE);
			startPlayer();

		}
	});

	// ~~~ 绑定数据
	mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
	mMaxVolume = mAudioManager
			.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
	if (mPath.startsWith("http:"))
		mVideoView.setVideoURI(Uri.parse(mPath));
	else
		mVideoView.setVideoPath(mPath);

	// 设置显示名称
	mMediaController = new MediaController(this);

	//mMediaController.setFileName(mTitle);
	mVideoView.setMediaController(mMediaController);
	mVideoView.requestFocus();

	mGestureDetector = new GestureDetector(this, new MyGestureListener());
	setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

}
 
开发者ID:zhangjingpu,项目名称:youkes_vr,代码行数:60,代码来源:VideoPlayerActivity.java

示例15: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    mContext = getApplicationContext();
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

    ActionBar actionBar = getActionBar();
    int displayOptions = ActionBar.DISPLAY_SHOW_HOME;
    actionBar.setDisplayOptions(0, displayOptions);
    displayOptions = ActionBar.DISPLAY_SHOW_CUSTOM;
    actionBar.setDisplayOptions(displayOptions, displayOptions);
    actionBar.setCustomView(R.layout.trim_menu);

    mSaveVideoTextView = (TextView) findViewById(R.id.start_trim);
    mSaveVideoTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            trimVideo();
        }
    });
    mSaveVideoTextView.setEnabled(false);

    Intent intent = getIntent();
    mUri = intent.getData();
    mSrcVideoPath = intent.getStringExtra(PhotoPage.KEY_MEDIA_ITEM_PATH);
    setContentView(R.layout.trim_view);
    View rootView = findViewById(R.id.trim_view_root);

    mVideoView = (VideoView) rootView.findViewById(R.id.surface_view);

    mController = new TrimControllerOverlay(mContext);
    ((ViewGroup) rootView).addView(mController.getView());
    mController.setListener(this);
    mController.setCanReplay(true);

    mVideoView.setOnErrorListener(this);
    mVideoView.setOnCompletionListener(this);
    mVideoView.setVideoURI(mUri);

    playVideo();
}
 
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:44,代码来源:TrimVideo.java


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