3
3
import java .io .IOException ;
4
4
5
5
import in .omerjerk .processing .video .android .callbacks .MediaPlayerHandlerCallback ;
6
+ import android .app .AlertDialog ;
7
+ import android .content .DialogInterface ;
6
8
import android .content .res .AssetFileDescriptor ;
7
9
import android .media .MediaMetadataRetriever ;
8
10
import android .media .MediaPlayer ;
@@ -29,6 +31,11 @@ public Movie(PApplet parent, String fileName) {
29
31
metaRetriever .setDataSource (afd .getFileDescriptor (), afd .getStartOffset (), afd .getLength ());
30
32
String height = metaRetriever .extractMetadata (MediaMetadataRetriever .METADATA_KEY_VIDEO_HEIGHT );
31
33
String width = metaRetriever .extractMetadata (MediaMetadataRetriever .METADATA_KEY_VIDEO_WIDTH );
34
+ if (height == null || width == null ) {
35
+ showDialog ("Error!" , "This video format is not supported by the device."
36
+ + "Please try a video with another format." );
37
+ return ;
38
+ }
32
39
init (Integer .valueOf (width ), Integer .valueOf (height ), ARGB );
33
40
} catch (IOException e ) {
34
41
e .printStackTrace ();
@@ -117,4 +124,19 @@ public void initPlayer(AssetFileDescriptor afd) {
117
124
public void startPlayer () {
118
125
player .start ();
119
126
}
127
+
128
+ private void showDialog (String title , String message ) {
129
+ AlertDialog .Builder dialogBuilder = new AlertDialog .Builder (activity );
130
+ dialogBuilder .setMessage (message );
131
+ dialogBuilder .setMessage (title );
132
+
133
+ dialogBuilder .setPositiveButton ("Okay" , new DialogInterface .OnClickListener () {
134
+ public void onClick (DialogInterface dialog , int id ) {
135
+ activity .finish ();
136
+ }
137
+ });
138
+
139
+ AlertDialog dialog = dialogBuilder .create ();
140
+ dialog .show ();
141
+ }
120
142
}
0 commit comments