Android : Video as background in GLSurfaceView ANDROID to develop PageCurl

on Tuesday, September 16, 2014


I'm developing an special effect in my Android app. It consists in a page curl. I'm using the effect developed by Harism https://github.com/harism/android_page_curl


So I am using 2 pages, and I am trying to pass one page to another, by having VideoView in whole layout in both pages.


PROBLEM: In my code I am using GLSurfaceView.Renderer that permits using for each layout an ImageView to get after its Drawable and prints the next Drawable for the next page.


My code is the next:



private class PageProvider implements CurlView.PageProvider {

// Bitmap resources.
private int[] mBitmapIds = { R.drawable.home0, R.drawable.home1 };

@Override
public int getPageCount() {
return 2;
}

private Bitmap loadBitmap(int width, int height, int index) {
Bitmap b = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
b.eraseColor(0xFFFFFFFF);
Canvas c = new Canvas(b);
Drawable d = getResources().getDrawable(mBitmapIds[index]);

int margin = 0;
int border = 0;

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
Rect r = new Rect(0, 0, size.x, size.y);

int imageWidth = size.x;
int imageHeight = imageWidth * d.getIntrinsicHeight()
/ d.getIntrinsicWidth();

r.left += ((r.width() - imageWidth) / 2) - border;
r.right = r.left + imageWidth + border + border;
r.top += ((r.height() - imageHeight) / 2) - border;
r.bottom = r.top + imageHeight + border + border;

Paint p = new Paint();
p.setColor(0xFFC0C0C0);
c.drawRect(r, p);
r.left += border;
r.right -= border;
r.top += border;
r.bottom -= border;

d.setBounds(r);
d.draw(c);

return b;
}

@Override
public void updatePage(CurlPage page, int width, int height, int index) {

switch (index) {
// First case is image on front side, solid colored back.
case 0: {
Bitmap front = loadBitmap(width, height, 0);
page.setTexture(front, CurlPage.SIDE_BOTH);
page.setColor(Color.argb(127, 255, 255, 255),
CurlPage.SIDE_BACK);
break;
}
// Second case is image on back side, solid colored front.
case 1: {
Bitmap front = loadBitmap(width, height, 1);
page.setTexture(front, CurlPage.SIDE_BOTH);
page.setColor(Color.argb(127, 255, 255, 255),
CurlPage.SIDE_BACK);
break;
}
}
}
}


My question is: Is it possible to use VideoView for each page? What Android element do I must use to implement this function? Many thanks!


0 comments:

Post a Comment