Skip to content

Commit 85a638c

Browse files
committed
1 parent 6972306 commit 85a638c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

app/src/main/java/github/kairusds/libvlcandroidtest/MainActivity.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ protected void onResume() {
146146
protected void onDestroy(){
147147
super.onDestroy();
148148
destroyVLC();
149+
shutdownExecutor();
149150
}
150151

151152
private void pause(){
@@ -182,6 +183,7 @@ private void setVLCMedia(String path){
182183
time = event.getTimeChanged();
183184
break;
184185
case Event.EndReached:
186+
mediaPlayer.stop();
185187
destroyVLC();
186188
break;
187189
}
@@ -217,8 +219,7 @@ private void showFilePickerDialog(File dir){
217219
handler.post(() -> {
218220
if(files == null){
219221
toast("Unable to access directory");
220-
executor.shutdown();
221-
executor = null;
222+
shutdownExecutor();
222223
return;
223224
}
224225

@@ -244,8 +245,7 @@ private void showFilePickerDialog(File dir){
244245
}else{
245246
setVLCMedia(filepath);
246247
dialog.dismiss();
247-
executor.shutdown();
248-
executor = null;
248+
shutdownExecutor();
249249
}
250250
}
251251
});
@@ -258,6 +258,13 @@ private void showFilePickerDialog(File dir){
258258
}
259259
}
260260

261+
private void shutdownExecutor(){
262+
if(executor != null){
263+
executor.shutdown();
264+
executor = null;
265+
}
266+
}
267+
261268
@Override
262269
protected void onActivityResult(int requestCode, int resultCode, Intent data){
263270
super.onActivityResult(requestCode, resultCode, data);
@@ -280,7 +287,7 @@ protected void onStop(){ // activity is in the background or minimized
280287
pause();
281288
// mediaPlayer.pause();
282289
// mediaPlayer.stop();
283-
/// mediaPlayer.detachViews();
290+
mediaPlayer.detachViews();
284291
}
285292

286293
}

0 commit comments

Comments
 (0)