Reputation: 3362
I want to display a panorama from my android application, this panorama is online and I have its url I load it on a webview but it won't work properly. It just appears a portion of it, and it won't turn or move upside down. I have no idea where to start with this, can you point me at the right direction? thank you in advance
Upvotes: 7
Views: 9806
Reputation: 3805
I had a similar situation in Kotlin, but I needed to get the image from a URL. I resolved it using Picasso. I leave this here for future reference:
val options = VrPanoramaView.Options()
val url = "https://urltoyourimage.com/image.jpg"
Picasso.get().load(url)
.into(object : Target {
override fun onBitmapLoaded(bitmap: Bitmap?, from: Picasso.LoadedFrom?) {
options.inputType = VrPanoramaView.Options.TYPE_MONO
vrPanoramaView.loadImageFromBitmap(bitmap, options)
}
override fun onBitmapFailed(e: Exception?, errorDrawable: Drawable?) {
print(e?.localizedMessage)
}
override fun onPrepareLoad(placeHolderDrawable: Drawable?) {
print(placeHolderDrawable)
}
})
Upvotes: 2
Reputation: 8305
Add dependency in gradle (app-level)
compile 'com.google.vr:sdk-panowidget:1.80.0'
Add VrPanoramaView
in your xml and get a reference via findViewById()
method in android
Below is the code for loading the image from asset.
VrPanoramaView
takes input as Bitmap so we need to first
convert it into right format. Here, the loadPhotoSphere
functions
in called in onCreate()
private void loadPhotoSphere() {
VrPanoramaView.Options options = new VrPanoramaView.Options();
InputStream inputStream = null;
try {
inputStream = assetManager.open("image.jpg");
options.inputType = VrPanoramaView.Options.TYPE_MONO;
mVRPanoramaView.loadImageFromBitmap(BitmapFactory.decodeStream(inputStream), options);
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Read about Google VR SDK for Android here
Upvotes: 0
Reputation: 3362
After a lot of research I found out this library it is still pretty new but sure can help you start with something. I'm posting it just to save time for other searchers! cheers PanoramaGl
Upvotes: 5