Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android video as a live wallpaper

i am trying to put video as a live wallpaper. I am using media player for that. i can get SurfaceHolder and i can give that holder to the media player. But its not working for me, its giving me following exception

LogCat Exception Detail

ERROR/AndroidRuntime(302): java.lang.UnsupportedOperationException: Wallpapers do not support keep screen on

if i dont give holder to the media player it works, but i can hear only audio. I saw one application VideoLiveWallpaper , which set video as a live wallpaper, so it can be possible, may be i am missing something . I am pasting the code, any help on this will be appreciated.

Code Snippet

public void surfaceCreated(SurfaceHolder holder) {
  // TODO Auto-generated method stub

 holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  mp=MediaPlayer.create(getApplicationContext(), R.raw.sample);
  mp.setDisplay(holder);
  mp.start();
 }
like image 864
user593443 Avatar asked Jan 28 '11 07:01

user593443


2 Answers

Instead of using **mediaPlayer.setDisplay(surfaceHolder)** you can use **mediaPlayer.setSurface(surfaceHolder.getSurface())**..

It will not give any kind of conflicts with the attribute KeepScreenOn.

NJOY.. :)

like image 178
Rankush Kumar Avatar answered Oct 27 '22 15:10

Rankush Kumar


My guess is that the Video Live Wallpaper currently in circulation is using a totally different approach: decoding the media manually and drawing it frame by frame. I do not think this problem can be tackled using your simple method--otherwise more people would have already done it.

I assume you have this reference, but just in case: http://forum.xda-developers.com/showthread.php?t=804720 The explicit mention of differing video formats leads me to believe the developer is doing his own decoding... Good luck, George

like image 25
George Freeman Avatar answered Oct 27 '22 17:10

George Freeman