Sub Globals
Dim vv1 As VideoView
Dim vvl As VideoViewOnErrorListener
End Sub
Sub Activity_Create(FirstTime As Boolean)
vv1.Initialize("vv")
vvl.SetOnErrorListener(vv1, "vvl")
Activity.AddView(vv1, 0dip, 10dip, 250dip, 250dip)
File.Copy(File.DirAssets, "IMAG0018.mp4", File.DirInternal, "IMAG0018.mp4")
vv1.LoadVideo(File.DirInternal, "IMAG0018.mp4")
vv1.Play
End Sub
Sub vvl_error(What As Int, Extra As Int) As Boolean
Select Case What
Case vvl.MEDIA_ERROR_SERVER_DIES
Log("vv error what: SERVER_DIES")
Case vvl.MEDIA_ERROR_UNKNOWN
Log("vv error what: ERROR_UNKNOWN")
Case Else
Log("vv error what else: " & What)
End Select
Select Case Extra
Case vvl.MEDIA_ERROR_IO
Log("vv error Extra: IO")
Case vvl.MEDIA_ERROR_MALFORMED
Log("vv error Extra:_MALFORMED")
Case vvl.MEDIA_ERROR_TIMED_OUT
Log("vv error Extra: TIMED_OUT")
Case vvl.MEDIA_ERROR_UNSUPPORTED
Log("vv error Extra: UNSUPPORTED")
Case Else
Log("vv error Extra else: " & Extra)
End Select
Return True 'Message Box suppressed, vv_complete does not execute
' Return False 'Message Box shows and vv_Complete executes
End Sub
Sub vv_Complete
Log("Playing complete")
End Sub
The MediaPlayer constants are all listed on this page: http://developer.android.com/reference/android/media/MediaPlayer.html#MEDIA_ERROR_TIMED_OUT.
I see no value for -2147483648.
Google tells me that -2147483648 is hex -0x80000000 and again i see no constant value that matches.
Have a look through the error code constant values and see if you can make sense of it.
I'd have thought that the constant values documented on this page are the only constant values passed in the event - but you're seeing other values are you?
The MediaPlayer.OnErrorListener returns only a boolean value to the MediaPlayer to indicate whether the application has handled the error or not.
There's no way to return any value other than boolean True or False.
Martin.
works perfectly...i think this library should be added to wiki
yes that relative layout for videoview library is awesome add that too...
@Author("Martin Pearman")
@Events(values={
"Error(What As Int, Extra As Int) As Boolean"
})
@ShortName("VideoViewOnErrorListener")
@Version(0.01f)
public class VideoViewOnErrorListener{
/**
* A possible value for the 'What' parameter.
*/
public static final int MEDIA_ERROR_UNKNOWN=MediaPlayer.MEDIA_ERROR_UNKNOWN;
/**
* A possible value for the 'What' parameter.
*/
public static final int MEDIA_ERROR_SERVER_DIES=MediaPlayer.MEDIA_ERROR_SERVER_DIED;
/**
* A possible value for the 'Extra' parameter.
*/
public static final int MEDIA_ERROR_IO=MediaPlayer.MEDIA_ERROR_IO;
/**
* A possible value for the 'Extra' parameter.
*/
public static final int MEDIA_ERROR_MALFORMED=MediaPlayer.MEDIA_ERROR_MALFORMED;
/**
* A possible value for the 'Extra' parameter.
*/
public static final int MEDIA_ERROR_UNSUPPORTED=MediaPlayer.MEDIA_ERROR_UNSUPPORTED;
/**
* A possible value for the 'Extra' parameter.
*/
public static final int MEDIA_ERROR_TIMED_OUT=MediaPlayer.MEDIA_ERROR_TIMED_OUT;
/**
* Clear any error listener for VideoView1.
*/
public static void ClearOnErrorListener(VideoViewWrapper VideoView1){
VideoView1.getObject().setOnErrorListener(null);
}
/**
* Create and set an error listener for VideoView1.
* The error listener will raise the event:
* Error(What As Int, Extra As Int) As Boolean
* Your callback must return a Boolean value to indicate whether or not it has consumed the event.
*/
public static void SetOnErrorListener(final VideoViewWrapper VideoView1, final BA pBA, String EventName){
final String onErrorEventName=(EventName+"_Error").toLowerCase(BA.cul);
if(pBA.subExists(onErrorEventName)){
VideoView1.getObject().setOnErrorListener(new android.media.MediaPlayer.OnErrorListener(){
@Override
public boolean onError(MediaPlayer pMediaPlayer, int pWhat, int pExtra) {
boolean consumeEvent=false;
Object object=pBA.raiseEvent(VideoView1, onErrorEventName, new Object[]{pWhat, pExtra});
if(object instanceof Boolean){
consumeEvent=((Boolean) object).booleanValue();
}
return consumeEvent;
}
});
} else {
BA.LogError("MediaPlayerOnErrorListener not initialized, callback sub not found: "+EventName+"_Error");
}
}
}