Skip to content
This repository has been archived by the owner on Nov 8, 2019. It is now read-only.

Enable remote content stream Google VR 360 #622

Open
KeySeeDev opened this issue Mar 16, 2019 · 3 comments
Open

Enable remote content stream Google VR 360 #622

KeySeeDev opened this issue Mar 16, 2019 · 3 comments

Comments

@KeySeeDev
Copy link

Hi, i was looking for a way to play remote content. It's seems to be disabled on propouse, no?
I'm working with the vr360 project as suggested and changed the function like the following.
Is this right, or maybe there is some problem with remote content? Thanks

    @Override
    protected Void doInBackground(Intent... intent) {

      // Extract the stereoFormat from the Intent's extras.
      int stereoFormat = intent[0].getIntExtra("stereoFormat", Mesh.MEDIA_MONOSCOPIC);
      if (stereoFormat != Mesh.MEDIA_STEREO_LEFT_RIGHT && stereoFormat != Mesh.MEDIA_STEREO_TOP_BOTTOM) {
        stereoFormat = Mesh.MEDIA_MONOSCOPIC;
      }

      // Create video sphere
      mesh = Mesh.createUvSphere(
           SPHERE_RADIUS_METERS, DEFAULT_SPHERE_ROWS, 
           DEFAULT_SPHERE_COLUMNS, DEFAULT_SPHERE_VERTICAL_DEGREES,   
           DEFAULT_SPHERE_HORIZONTAL_DEGREES, stereoFormat
       );

      // Based on the Intent's data, load the appropriate media from disk.
      String media_url = intent[0].getStringExtra("src");
      Uri uri = Uri.parse(media_url);
      try {

        File file = new File(uri.getPath());
        String type = URLConnection.guessContentTypeFromName(uri.getPath());

        if (type == null) {
          throw new InvalidParameterException("Unknown file type: " + uri);
        } else if (type.startsWith("image")) {
          if (file.exists()) {
            mediaImage = BitmapFactory.decodeFile(uri.getPath());
          } else {
            mediaImage = BitmapFactory.decodeStream(new java.net.URL(media_url).openStream());
          }
        } else if (type.startsWith("video")) {
          MediaPlayer mp = MediaPlayer.create(context, uri);
          synchronized (MediaLoader.this) {
            mediaPlayer = mp;
          }
        } else {
          throw new InvalidParameterException("Unsupported MIME type: " + type);
        }

      } catch (IOException | InvalidParameterException e) {
        errorText = String.format("Error loading file [%s]: %s", uri.getPath(), e);
        Log.e(TAG, errorText);
      }

      displayWhenReady();
      return null;
    }
@KeySeeDev
Copy link
Author

Uh, seems like the audio wont play while streaming... gonna find out why.

@sigmaxipi
Copy link

This may be a compatibility issue with the video stream format and the default Media Player. The sample was primarily designed to demonstrate the VR rendering aspects and not the video playback functionality. Instead of using Android's MediaPlayer, the general recommendation for video playback on Android is to use a more powerful player like https://github.com/google/ExoPlayer which has better format compatibility.

@KeySeeDev
Copy link
Author

Yeah, will definitly try it once I got spare time, at the moment it's not a must have for our project 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants