Question

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

Was it helpful?

Solution

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

OTHER TIPS

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)
            }
    })
  1. Add dependency in gradle (app-level)

    compile 'com.google.vr:sdk-panowidget:1.80.0'

  2. Add VrPanoramaView in your xml and get a reference via findViewById() method in android

  3. 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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top