From 960d208898939f37c9a11621e3e6a2ce267e50a8 Mon Sep 17 00:00:00 2001 From: Gary Mathews Date: Thu, 9 Apr 2020 06:56:27 -0700 Subject: [PATCH] fix(android): do not release media player too soon (#11609) Fixes TIMOB-27493 --- .../media/src/java/android/widget/TiVideoView8.java | 11 ++++------- .../java/ti/modules/titanium/media/TiUIVideoView.java | 2 -- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/android/modules/media/src/java/android/widget/TiVideoView8.java b/android/modules/media/src/java/android/widget/TiVideoView8.java index ed86e8ccf1f..e2f5e83ac0e 100644 --- a/android/modules/media/src/java/android/widget/TiVideoView8.java +++ b/android/modules/media/src/java/android/widget/TiVideoView8.java @@ -20,7 +20,7 @@ * Copyright (c) 2009-2014 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the Apache Public License * Please see the LICENSE included with this distribution for details. - * + * * This is the api level 8 VideoView.java with Titanium-specific modifications. */ @@ -570,9 +570,6 @@ public void onCompletion(MediaPlayer mp) if (mOnCompletionListener != null) { mOnCompletionListener.onCompletion(mMediaPlayer); } - if (mp != null) { - mp.release(); - } } }; @@ -611,7 +608,7 @@ public void onBufferingUpdate(MediaPlayer mp, int percent) /** * Register a callback to be invoked when the media file * is loaded and ready to go. - * + * * @param l * The callback that will be run */ @@ -623,7 +620,7 @@ public void setOnPreparedListener(MediaPlayer.OnPreparedListener l) /** * Register a callback to be invoked when the end of a media file * has been reached during playback. - * + * * @param l * The callback that will be run */ @@ -637,7 +634,7 @@ public void setOnCompletionListener(OnCompletionListener l) * during playback or setup. If no listener is specified, * or if the listener returned false, VideoView will inform * the user of any errors. - * + * * @param l * The callback that will be run */ diff --git a/android/modules/media/src/java/ti/modules/titanium/media/TiUIVideoView.java b/android/modules/media/src/java/ti/modules/titanium/media/TiUIVideoView.java index 0fece1db786..83d0da8b2a2 100644 --- a/android/modules/media/src/java/ti/modules/titanium/media/TiUIVideoView.java +++ b/android/modules/media/src/java/ti/modules/titanium/media/TiUIVideoView.java @@ -343,14 +343,12 @@ public void onPrepared(MediaPlayer mp) @Override public void onCompletion(MediaPlayer mp) { - mp.release(); getPlayerProxy().onPlaybackComplete(); } @Override public boolean onError(MediaPlayer mp, int what, int extra) { - mp.release(); getPlayerProxy().onPlaybackError(what); return false; // Let completion listener run. }