Android Question Animated GIF not running on WebView.

Beja

Expert
Licensed User
Longtime User
Hi to all,

I created an animated GIF file with 18 frames using photoscape, about 100k, designed a webpage and
set the loadhtml property to the index.html page.. but only the first picture
(frame) of the GIF file is showing. Any idea why the Webview is not displaying the index.html page?

Thanks in advance

p.s.
The animation is fine when open it in IE or Chrome
 

Beja

Expert
Licensed User
Longtime User
Sure,
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("1")
WebView1.LoadUrl("file://" & File.DirInternal & "/index.htm")
End Sub

In fact this is Erel's example I used it "AS IS"
 
Upvote 0

Tom Christman

Active Member
Licensed User
Longtime User
Try the code below taken from a WebView Sound Sample (I can't find the author although I've searched the forum for WebView Sound Sample). The code requires, Core, and Audio Libraries and You TubeAndroidPlayer api (See Erels post "You Tube Library") for adding sound. The code below was used in a program I wrote for an app called coop2. The Main. bal simply contained a webview for a 7"pad in landscape. The html code was written using a program called "Coffee Cup" and is cited first. It has sound "explosion.mp3", and the gif "android_asset/hulk.gif" in the code listing....that you can change to your assets.

Test.html
B4X:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>Test</TITLE>

</HEAD>
<BODY bgcolor="#000000" text="#000000">
<CENTER>
<DIV align="center">
<FONT style="font-size:13px" color="#000000" face="Arial">Click on the picture</FONT></DIV>
<A href="explosion.mp3"><IMG src="android_asset/hulk.gif" alt="" align="top" border="0" width="502" height="309"></A>
</CENTER>
</BODY>
</HTML>

coop2
B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: coop2
    #VersionCode: 1
    #VersionName: 0.0
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

'Activity module

Sub Process_Globals

End Sub

Sub Globals

      Dim Player As MediaPlayer
                Dim WebView1 As WebView
   
End Sub

Sub Activity_Create(FirstTime As Boolean)

    Activity.LoadLayout("Main")'Set a Webview size for the device
               
                Player.Initialize
                Player.Load(File.DirAssets, "sound.mp3")
               
           
HTML = File.ReadString(File.DirAssets, "Test.html")
         WebView1.LoadHtml(HTML)
                

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause(UserClosed As Boolean)

End Sub

'##########################
'######## Controls ########
'##########################

Sub WebView1_OverrideUrl(Url As String) As Boolean


Hope this helps
 
Upvote 0

KY Leng

Member
Licensed User
Longtime User
Try the code below taken from a WebView Sound Sample (I can't find the author although I've searched the forum for WebView Sound Sample). The code requires, Core, and Audio Libraries and You TubeAndroidPlayer api (See Erels post "You Tube Library") for adding sound. The code below was used in a program I wrote for an app called coop2. The Main. bal simply contained a webview for a 7"pad in landscape. The html code was written using a program called "Coffee Cup" and is cited first. It has sound "explosion.mp3", and the gif "android_asset/hulk.gif" in the code listing....that you can change to your assets.

Test.html
B4X:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>Test</TITLE>

</HEAD>
<BODY bgcolor="#000000" text="#000000">
<CENTER>
<DIV align="center">
<FONT style="font-size:13px" color="#000000" face="Arial">Click on the picture</FONT></DIV>
<A href="explosion.mp3"><IMG src="android_asset/hulk.gif" alt="" align="top" border="0" width="502" height="309"></A>
</CENTER>
</BODY>
</HTML>

coop2
B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: coop2
    #VersionCode: 1
    #VersionName: 0.0
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

'Activity module

Sub Process_Globals

End Sub

Sub Globals

      Dim Player As MediaPlayer
                Dim WebView1 As WebView
  
End Sub

Sub Activity_Create(FirstTime As Boolean)

    Activity.LoadLayout("Main")'Set a Webview size for the device
              
                Player.Initialize
                Player.Load(File.DirAssets, "sound.mp3")
              
          
HTML = File.ReadString(File.DirAssets, "Test.html")
         WebView1.LoadHtml(HTML)
               

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause(UserClosed As Boolean)

End Sub

'##########################
'######## Controls ########
'##########################

Sub WebView1_OverrideUrl(Url As String) As Boolean


Hope this helps

Hi Tom Christman,

I try your code and nothing happen. only black screen. When I touch the image (no image, only frame), it also say the mp3 is not found.
However, I notice that I do not have the WebView1_OverrideUrl function because it is missing in your post.

Hope you can help me out,

Best regards,
 
Upvote 0

KY Leng

Member
Licensed User
Longtime User
Hi Tom Christman,

I try your code and nothing happen. only black screen. When I touch the image (no image, only frame), it also say the mp3 is not found.
However, I notice that I do not have the WebView1_OverrideUrl function because it is missing in your post.

Hope you can help me out,

Best regards,
I find the problem:

1. I use Upper Case name (Ex: Im1.png) => Use all lower case name (Ex: im1.png)
2. Use WebView1.LoadHtml(HTML) or WebView1.LoadUrl("file:///android_asset/Test.htm") => Use WebView1.LoadUrl("file:///android_asset/test.htm")

Thank you.
 
Last edited:
Upvote 0
Top