Skip to content

Commit

Permalink
fix(android): do not release media player too soon (#11609)
Browse files Browse the repository at this point in the history
Fixes TIMOB-27493
  • Loading branch information
garymathews committed Apr 9, 2020
1 parent 7bede6f commit 960d208
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 4 additions & 7 deletions android/modules/media/src/java/android/widget/TiVideoView8.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand Down Expand Up @@ -570,9 +570,6 @@ public void onCompletion(MediaPlayer mp)
if (mOnCompletionListener != null) {
mOnCompletionListener.onCompletion(mMediaPlayer);
}
if (mp != null) {
mp.release();
}
}
};

Expand Down Expand Up @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down

0 comments on commit 960d208

Please sign in to comment.