Skip to content

Commit

Permalink
Prevent re-attempting video preview playback on error
Browse files Browse the repository at this point in the history
Previously if a media file was selected but the VideoView
could not play it, the VideoView would popup an error dialog
and at the end of a timeout the video preview was started again.
The result was an endless stream of error dialogs.

This error case is now detected, and if a file fails to
play a Toast is shown and the video playback is stopped.
  • Loading branch information
brarcher committed Jan 5, 2019
1 parent 419c9a7 commit f48aea7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,17 @@ public void onClick(View v)
}
});

videoView.setOnErrorListener(new MediaPlayer.OnErrorListener()
{
@Override
public boolean onError(MediaPlayer mp, int what, int extra)
{
Toast.makeText(MainActivity.this, R.string.mediaPlaybackFailed, Toast.LENGTH_LONG).show();
stopVideoPlayback();
return true;
}
});

FFmpegUtil.getMediaDetails(new File(path), new ResultCallbackHandler<MediaInfo>()
{
@Override
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<string name="fieldMissingError"><xliff:g id="field_name">%s</xliff:g> missing</string>
<string name="fieldMissingOrInvalidError"><xliff:g id="field_name">%s</xliff:g> missing or invalid</string>
<string name="invalidMediaFile">The selected media file is invalid or not supported</string>
<string name="mediaPlaybackFailed">The selected media file could not be previewed</string>

<string name="writePermissionExplanation">This application needs access to storage in order to read and write media files. Without this access, the application cannot transcode.</string>
<string name="permissionRequestAgain">Request again</string>
Expand Down

0 comments on commit f48aea7

Please sign in to comment.