3

So i have uploaded my video to my amazon DataBase, and now i Want to download it and display it, here is the part of my code where i download it:

S3ObjectInputStream content = s3.getObject(
                            Constants.getVideoBucket(),
                            keyList.get(i).getKey().toString())
                            .getObjectContent();
                    byte[] bytes = IOUtils.toByteArray(content);

Now I have the byte array that has the video, but i dont know what to do next. What should i do? I want to display it on a VideoView that I have ready.

help will be much apreciated

ps: i dont want to write down the video to the sd card! (imagine a youtube video, it gisplays but it wont write to ur sd card every video you watch.!)!!!!!!!!!!!!

EDIT1: i did this with the pictures:

S3ObjectInputStream content = s3.getObject(
                            Constants.getPictureBucket(),
                            keyList.get(i).getKey().toString())
                            .getObjectContent();
                    byte[] bytes = IOUtils.toByteArray(content);
bitmap = BitmapFactory.decodeByteArray(bitmaparray.get(i), 0,
                            bitmaparray.get(i).length);             
                    imageview.setImageBitmap(bitmap); 

as you can see, i converted the byte array to bitmap and then displayed it to a imageview, could you please help me to do the same with the video one???

luthor
  • 95
  • 1
  • 5
  • What format is the video data in? – fadden May 08 '14 at 06:00
  • i really dont know haha how can i find the format?? i jsut savbed a video done with a samsung galaxy – luthor May 08 '14 at 14:28
  • @fadden I also have the same problem in a different context. Can the problem be solved with specific format? In that case, I can consider converting the videos. Currently, I have video in flv,mp4 and webm formats. – cnvzmxcvmcx Jun 12 '14 at 02:54
  • Possible duplicate of [how to decode the byte array(.h264 format) in to video in android?](http://stackoverflow.com/questions/28123759/how-to-decode-the-byte-array-h264-format-in-to-video-in-android) – KeksArmee Oct 25 '15 at 20:37

1 Answers1

1

You can try this with appropriate permissions.

FileOutputStream out = new FileOutputStream("sdcard path where you want to save video");
out.write(bytes);
out.close();
videoView.setVideoPath(“path to saved video“).
Altaf
  • 5,150
  • 10
  • 39
  • 55