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???

4
  • What format is the video data in? Commented May 8, 2014 at 6:00
  • i really dont know haha how can i find the format?? i jsut savbed a video done with a samsung galaxy Commented May 8, 2014 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. Commented Jun 12, 2014 at 2:54
  • Possible duplicate of how to decode the byte array(.h264 format) in to video in android? Commented Oct 25, 2015 at 20:37

1 Answer 1

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“).
Sign up to request clarification or add additional context in comments.

6 Comments

and then??? i also saw this answer in another post, but i dont know how to manage the video
then you can access the saved video.whether you want to play it or do something else
but is it posible to play it without saving it? imagine youtube, if you save everyvideo you see you'll have ur card full in a day.
No my answer is about the saving of the video.
Well i didnt asked for that, so ur answer is useles.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.