decoding inputstream to Movie object.

All your problems with Audio, Video and Images.

decoding inputstream to Movie object.

Postby ranzbak » Tue Jan 20, 2009 8:39 pm

Hi,

Could somebody tell me why I get an IO exception what Ever I try with the Movie.decodeStream() method ..

What I'm trying to do is to get an animated GIF from an http resource and decode it using the Movie object.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private Movie MovieOperations(Context ctx, String url, String saveFilename) {  
  2.  
  3.         try {
  4.  
  5.                 InputStream is = (InputStream) this.fetch(url);
  6.  
  7.                
  8.  
  9.                 Movie mov = Movie.decodeStream(is);
  10.  
  11.                
  12.  
  13.                 return mov;
  14.  
  15.         } catch (MalformedURLException e) {
  16.  
  17.                 // TODO Auto-generated catch block
  18.  
  19.                 e.printStackTrace();
  20.  
  21.         } catch (IOException e) {
  22.  
  23.                 e.printStackTrace();
  24.  
  25.         }
  26.  
  27.         return null;
  28.  
  29. }
  30.  
  31.  
  32.  
  33. public Object fetch(String address) throws MalformedURLException,IOException {
  34.  
  35.         URL url = new URL(address);
  36.  
  37.         Object content = url.getContent();
  38.  
  39.         return content;
  40.  
  41. }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


But I keep ending up with an IO exception :
Stack trace:

01-20 20:34:52.107: WARN/System.err(773): java.io.IOException
01-20 20:34:52.117: WARN/System.err(773): at java.io.InputStream.reset(InputStream.java:176)
01-20 20:34:52.127: WARN/System.err(773): at android.graphics.Movie.decodeStream(Native Method)
01-20 20:34:52.137: WARN/System.err(773): at cx.etv.Buienradar.MovieOperations(Buienradar.java:108)
01-20 20:34:52.147: WARN/System.err(773): at cx.etv.Buienradar.onCreate(Buienradar.java:95)
01-20 20:34:52.157: WARN/System.err(773): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1122)
01-20 20:34:52.167: WARN/System.err(773): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2103)
01-20 20:34:52.177: WARN/System.err(773): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2156)
01-20 20:34:52.187: WARN/System.err(773): at android.app.ActivityThread.access$1800(ActivityThread.java:112)
01-20 20:34:52.197: WARN/System.err(773): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1580)
01-20 20:34:52.207: WARN/System.err(773): at android.os.Handler.dispatchMessage(Handler.java:88)
01-20 20:34:52.207: WARN/System.err(773): at android.os.Looper.loop(Looper.java:123)
01-20 20:34:52.217: WARN/System.err(773): at android.app.ActivityThread.main(ActivityThread.java:3742)
01-20 20:34:52.227: WARN/System.err(773): at java.lang.reflect.Method.invokeNative(Native Method)
01-20 20:34:52.237: WARN/System.err(773): at java.lang.reflect.Method.invoke(Method.java:515)
01-20 20:34:52.247: WARN/System.err(773): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
01-20 20:34:52.257: WARN/System.err(773): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
01-20 20:34:52.267: WARN/System.err(773): at dalvik.system.NativeStart.main(Native Method)

I know that the reset method in InputStream throws an exception by default.. but I don't seem to get around this..
Does someone have a solution, so I can decode animated gif files from an URL class ?
code examples are welcome.
ranzbak
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Jan 19, 2009 9:17 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 12 guests