File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
src/main/java/com/sccomponents/playerbutton Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ android {
1010 minSdkVersion 15
1111 targetSdkVersion 25
1212 versionCode 13
13- versionName ' 1.0.2 '
13+ versionName ' 1.0.3 '
1414 vectorDrawables. useSupportLibrary = true
1515 }
1616 buildTypes {
Original file line number Diff line number Diff line change @@ -202,15 +202,21 @@ private float dipToPixel(float dip) {
202202 * @return the duration in milliseconds
203203 */
204204 private int getMediaDuration (String source ) {
205+ MediaPlayer player = null ;
205206 try {
206207 // Try to get the media duration
207- MediaPlayer player = MediaPlayer .create (this .getContext (), Uri .parse (source ));
208+ player = MediaPlayer .create (this .getContext (), Uri .parse (source ));
208209 return player .getDuration ();
209210
210211 } catch (Exception ex ) {
211212 // Print the error on the stack and return
212213 ex .printStackTrace ();
213214 return 0 ;
215+
216+ } finally {
217+ // Release the player
218+ if (player != null )
219+ player .release ();
214220 }
215221 }
216222
You can’t perform that action at this time.
0 commit comments