Android Question ExoPlayer VR 360 Mode

Roger Taylor

Member
Licensed User
Longtime User
I was shocked to see that ExoPlayer supports 360-degree videos! According to the ExoPlayer docs, app:surface_type = "spherical_view" is all that's needed? Probably not "all", but at least required. When trying to add this attribute to the B4A manifest file for my project I get an error. I've been trying to find out how to set this attribute at run-time but I think it has to be done during the project compile and may have to be done elsewhere.

While the B4X wrapper might not support the spherical_view attribute yet, if it does has anyone had experience with this mode and can you share how you invoke it? If the mode isn't available yet for B4X, is there a way I can add the mode to a new version of the wrapper?

I have several "VR360" videos where the left-right rotation image occupies the top half of the video frames, and the up-down head movement occupies the bottom half of the image. I think this is the format that ExoPlayer supports.

I'd be thrilled to learn how to use the 360 mode!
 

JohnC

Expert
Licensed User
Longtime User
The chance of getting a reply is usually dependent on how many users ran into this issue or how likely users will run into this issue.

So, please don't take no response as that no one is interested in helping you.

My suggestions:

1) First run the third-party demo app to see if the version of exoplayer on your device is 2.9 or later as mentioned on this page:
B4X:
https://medium.com/google-exoplayer/playing-360-degree-videos-with-exoplayer-f3b48f8ea390

2) Try adding this to the manifest file:
B4X:
<com.google.android.exoplayer2.ui.PlayerView
    app:surface_type="spherical_view"/>

And if you already tried adding the above to the manifest and you got an error, please post the error. The easier you make it for someone to help you (by providing details), the better chance someone will :)
 
Last edited:
Upvote 0

Roger Taylor

Member
Licensed User
Longtime User
I've already added the code to my manifest file days ago, and the result is the screen goes all white for a while then the app exits. "The error" is a huge debug readout that I don't care to post but it suggests that the B4X wrapper isn't using ExoPlayer 2.9. If this is the case I'm interested in knowing who's maintaining the library and where outside of the forums might their latest update be, etc. From what I can tell the library posted on this site contains compiled .jar files and I can't make the changes required to get the spherical view working.
 
Upvote 0

Roger Taylor

Member
Licensed User
Longtime User
With the manifest snippet above, inserted as shown below, I get the included debug output:

CreateResource(layout, exo_simple_player_view.xml,

<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<com.google.android.exoplayer2.ui.PlayerView
app:surface_type="spherical_view"/>


<com.google.android.exoplayer2.ui.AspectRatioFrameLayout android:id="@id/exo_content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">

<!-- Video surface will be inserted as the first child of the content frame. -->

..... other customization code clipped out ...


deubg ->

B4A Version: 10.50
Parsing code. (0.00s)
Java Version: 8
Building folders structure. (0.33s)
Compiling code. (1.05s)
Compiling layouts code. (0.09s)
Organizing libraries. (0.00s)
(Android Support Library)
Generating R file. (0.00s)
Compiling debugger engine code. (0.04s)
Compiling generated Java code. (0.04s)
Convert byte code - optimized dex. (5.31s)
Packaging files. Error
res\layout\exo_simple_player_view.xml:5: error: Error: String types not allowed (at 'surface_type' with value 'spherical_view').

AAPT path: C:\Users\Roger\AppData\Local\Android\sdk\tools\..\build-tools\29.0.2\aapt.exe
Exit code:1
 
Upvote 0

Roger Taylor

Member
Licensed User
Longtime User
My short demo program is basically the one included with the library but I changed the video URL and made some other minor changes but it otherwise works great before attempting to invoke a spherical view mode.

With this snippet added to the manifest file, the project compiles but I get the white screen and no response, then exit from FireTV app.

CreateResource(layout, exo_simple_player_view.xml,

<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<com.google.android.exoplayer2.ui.PlayerView
app:surface_type="spherical_gl_surface_view"/>
.....



It looks like 500+ instances of ExoPlayer are being attempted, but I could be wrong...
debug ->

Logger connected to: Amazon AFTT
--------- beginning of main
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
art/runtime/indirect_reference_table.cc:98] JNI ERROR (app bug): local reference table overflow (max=512)
art/runtime/indirect_reference_table.cc:98] local reference table dump:
art/runtime/indirect_reference_table.cc:98] Last 10 entries (of 512):
art/runtime/indirect_reference_table.cc:98] 511: 0x12c1ec00 com.google.android.exoplayer2.ui.PlayerView
art/runtime/indirect_reference_table.cc:98] 510: 0x12c1d800 com.google.android.exoplayer2.ui.PlayerView
art/runtime/indirect_reference_table.cc:98] 509: 0x12c1cc00 com.google.android.exoplayer2.ui.PlayerView
art/runtime/indirect_reference_table.cc:98] 508: 0x12c1c800 com.google.android.exoplayer2.ui.PlayerView
art/runtime/indirect_reference_table.cc:98] 507: 0x12c19800 com.google.android.exoplayer2.ui.PlayerView
art/runtime/indirect_reference_table.cc:98] 506: 0x12c19400 com.google.android.exoplayer2.ui.PlayerView
art/runtime/indirect_reference_table.cc:98] 505: 0x12f50c00 com.google.android.exoplayer2.ui.PlayerView
art/runtime/indirect_reference_table.cc:98] 504: 0x12f50800 com.google.android.exoplayer2.ui.PlayerView
art/runtime/indirect_reference_table.cc:98] 503: 0x12f50400 com.google.android.exoplayer2.ui.PlayerView
art/runtime/indirect_reference_table.cc:98] 502: 0x12f50000 com.google.android.exoplayer2.ui.PlayerView
art/runtime/indirect_reference_table.cc:98] Summary:
art/runtime/indirect_reference_table.cc:98] 1 of java.lang.String[] (3 elements)
art/runtime/indirect_reference_table.cc:98] 2 of java.lang.Class (2 unique instances)
art/runtime/indirect_reference_table.cc:98] 3 of java.lang.String (3 unique instances)
art/runtime/indirect_reference_table.cc:98] 506 of com.google.android.exoplayer2.ui.PlayerView (506 unique instances)
art/runtime/indirect_reference_table.cc:98]
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
As I mentioned, as a diagnostic step, I would first make sure the 360 demo plays ok on your device to make sure your device actually has version 2.9 or higher so we can eliminate that as a possible cause of any problems. This page mentions the demo app:
B4X:
https://medium.com/google-exoplayer/playing-360-degree-videos-with-exoplayer-f3b48f8ea390
 
Last edited:
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Packaging files. Error
res\layout\exo_simple_player_view.xml:5: error: Error: String types not allowed (at 'surface_type' with value 'spherical_view').
This error seems to indicate that b4a doesn't understand that statement.

Sometimes you can't insert commands as-is into the b4a manifest - sometimes you need to change the syntax a little for b4a to understand it properly. Unfortunately, I don't have the knowledge of how to reword that surface_type attribute for b4a to handle it correctly.
 
Last edited:
Upvote 0

Roger Taylor

Member
Licensed User
Longtime User
In my manifest snippets I posted above you can see that the code is in the right place. The error suggests to me that "spherical_view" is not available yet suggesting further that the B4X wrapper for ExoPlayer isn't up to 2.9, but that's what I'm trying to figure out. But as you stated, the 360 demo needs to be ran on my FireTV stick as well to see if it's supported, so I've have the project loaded in Android Studio since last night waiting to get around to sometime today. I'll post my results.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
The error suggests to me that "spherical_view" is not available yet suggesting further that the B4X wrapper for ExoPlayer isn't up to 2.9, but that's what I'm trying to figure out.
This might not be the case. If this were a property or method of the player object that you would normally access from code, then I would agree with you that a newer wrapper might be needed to support that attribute.

But because this setting is done in the manifest, I am thinking that it might be able to be set outside of any wrapper - that the player object would read the value directly when it runs. But the error seems like it needs to be worded differently for B4a to properly add it to the final manifest.
 
Upvote 0

Roger Taylor

Member
Licensed User
Longtime User
The link you posted above might "mention" a 360 view demo but there isn't a link on the page. I can't find a "360 demo app" but there's the ExoPlayer demo app which doesn't come preset with such a mode. In fact, I had to add "PlayerView" to the project although it did contain a "PlayerControlView" without a surface_type attribute. PlayerView has the surface_type attribute. At any rate, I feel like I'm building a 360 player instead of getting ahold of a ready to build demo. Do you have the actual github link?
Thanks
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Upvote 0

Roger Taylor

Member
Licensed User
Longtime User
JohnC, I appreciate your attempt to help by suggesting to use google :) but this is not the kind of help I was needing, actually. Thank you for the effort, though. The demo you're referencing is just the basic ExoPlayer demo for Android Studio, so we're getting out of bounds a bit. I already know what the attribute is to set for the player to get it to switch to spherical mode. My original post mentions the fact that the B4X wrapper/library for ExoPlayer apparently doesn't support the spherical mode and I was asking who the author is or if they still maintain the project so we can get it updated to ExoPlayer 2.9+ and let us use the spherical mode. If you aren't able to help in this area, then we're just spinning our wheels. However, I do plan to build the Android Studio project to see if one of my Fire devices handles the spherical player. Again, thank you.
 
Upvote 0
Top