List of usage examples for android.widget VideoView getParent
public final ViewParent getParent()
From source file:im.vector.adapters.VectorMediasViewerAdapter.java
/** * Load the video items//from w ww . j a v a 2 s .co m * @param view the page view * @param thumbnailUrl the thumbnail URL * @param videoUrl the video Url * @param videoMimeType the video mime type */ private void loadVideo(final int position, final View view, final String thumbnailUrl, final String videoUrl, final String videoMimeType) { final VideoView videoView = (VideoView) view.findViewById(R.id.media_slider_videoview); final ImageView thumbView = (ImageView) view.findViewById(R.id.media_slider_video_thumbnail); final ImageView playView = (ImageView) view.findViewById(R.id.media_slider_video_playView); displayVideoThumbnail(view, !videoView.isPlaying()); videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mPlayingVideoView = null; displayVideoThumbnail(view, true); } }); // the video is renderer in DSA so trap the on click on the video view parent ((View) videoView.getParent()).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { stopPlayingVideo(); displayVideoThumbnail(view, true); } }); // manage video error cases videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { mPlayingVideoView = null; displayVideoThumbnail(view, true); return false; } }); // init the thumbnail views mMediasCache.loadBitmap(mSession.getHomeserverConfig(), thumbView, thumbnailUrl, 0, 0, null); playView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // init the video view only if there is a valid file // check if the media has been downloaded File srcFile = mMediasCache.mediaCacheFile(videoUrl, videoMimeType); if (null != srcFile) { playVideo(view, videoView, videoUrl, videoMimeType); } else { mAutoPlayItemAt = position; downloadVideo(view, position); } } }); }
From source file:im.neon.adapters.VectorMediasViewerAdapter.java
/** * Load the video items/*from ww w .ja v a 2s.co m*/ * @param view the page view * @param thumbnailUrl the thumbnail URL * @param videoUrl the video Url * @param videoMimeType the video mime type */ private void loadVideo(final int position, final View view, final String thumbnailUrl, final String videoUrl, final String videoMimeType) { final VideoView videoView = (VideoView) view.findViewById(R.id.media_slider_videoview); final ImageView thumbView = (ImageView) view.findViewById(R.id.media_slider_video_thumbnail); final ImageView playView = (ImageView) view.findViewById(R.id.media_slider_video_playView); displayVideoThumbnail(view, !videoView.isPlaying()); videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mPlayingVideoView = null; displayVideoThumbnail(view, true); } }); // the video is renderer in DSA so trap the on click on the video view parent ((View) videoView.getParent()).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { stopPlayingVideo(); displayVideoThumbnail(view, true); } }); // manage video error cases videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { mPlayingVideoView = null; displayVideoThumbnail(view, true); return false; } }); // init the thumbnail views mMediasCache.loadBitmap(mSession.getHomeserverConfig(), thumbView, thumbnailUrl, 0, 0, null, null); playView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // init the video view only if there is a valid file // check if the media has been downloaded File srcFile = mMediasCache.mediaCacheFile(videoUrl, videoMimeType); if (null != srcFile) { playVideo(view, videoView, videoUrl, videoMimeType); } else { mAutoPlayItemAt = position; downloadVideo(view, position); } } }); }