Uses ... Androidapi.JNI.Webkit;
function GetMimeType(FFilename: String; IsLocalFile: Boolean): JString;
{$IFDEF ANDROID}
var jstr: JString;
const _Default = 'video/mp4';
begin
Try
result := StringToJString(_Default); // Standard
If IsLocalFile then jstr := TJMimeTypeMap.JavaClass.getFileExtensionFromUrl(StringToJString(cFileUrlPrefix + FFilename))
Else jstr := TJMimeTypeMap.JavaClass.getFileExtensionFromUrl(StringToJString(FFilename));
if jstr <> nil then begin
jstr := TJMimeTypeMap.JavaClass.getSingleton.getMimeTypeFromExtension(jstr);
if jstr <> nil then result := jstr;
end;
Except
Result := StringToJString(_Default);
End;
end;
{$ELSE}
begin
raise
Exception.Create('Not supported!');
end;
{$ENDIF}
Function OpenVideo(const
URL: string; IsLocalFile: Boolean): Boolean;
{$IFDEF ANDROID}
var
Intent: JIntent;
begin
Try
Intent := TJIntent.Create;
Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
Intent.setFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);
If IsLocalFile then Intent.setDataAndType(TJnet_Uri.JavaClass.parse(StringToJString(cFileUrlPrefix +
URL)), GetMimeType(
URL,IsLocalFile) )
Else Intent.setDataAndType(TJnet_Uri.JavaClass.parse(StringToJString(
URL)), GetMimeType(
URL,IsLocalFile) );
SharedActivity.startActivity(TJIntent.JavaClass.createChooser(Intent, StrToJCharSequence('Bitte App auswählen...')));
Result := true;
Except
Result := false;
End;
end;
{$ELSE}
begin
raise
Exception.Create('Not supported!');
end;
{$ENDIF}