5

I have a listview.Each listitem in the listview contains a surfaceview, an imageview and button. Initially the visibility of the surfaceview will be gone. Only the imageview and the button is visible.

  1. Once the user taps on the imageview or the button the surfaceview made visible the mediaplayer is initialized and it will start playing the video on the surfaceview. When the user scrolls up and down visibilty of the surfaceview changed again(gone).Only one surfaceview made visisble at a time.

  2. When the user touches any of the list item it checks whether the any other mediaplayer already exist if it exists it will be released and new mediaplayer is initialized with a new instance of surfaceview.

This works fine. But the problem is

Releasing a already existing media player and initializing new media player takes time(mainly between the methods mediaplayer.prepareasyn() and mediaplayer.start()). If tapped on the listitem and slowly remove my hand it works fine... otherwise if it is tapped very fast it doesnt play the video only surfaceview is made visible.

Current Solution

I tried applying a postdelay between these 2 methods it works fine. I wanted to know whether this is the efficient way of doing this. Or is there any other way where i can achieve faster reaction.

Preethi Rao
  • 5,117
  • 1
  • 16
  • 29

1 Answers1

0

I think what you should do is use a Handler and use the postDelayed method to delay the operation , meanwhile use a ProgressDialog to show the user you are loading the next video .

Hope thats Help .

  • Thats what currently i did.. I wanted know know is there any other efficient way to do this without using the delay method. – Preethi Rao Jan 21 '14 at 10:29
  • you can try to prepare other videos in the background , even before the user click it . –  Jan 21 '14 at 10:34