nstudio / nstudio/nativescript-plugins
exoplayer: Exposing surface_type to use texture_view
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 55
- Forks
- 42
- Avg merge
- 49m
- Merged PRs (30d)
- 1
Description
Hi we have some problems with using the exoplayer plugin in the use case of tilting videos by rotation.
We couldn't find out a good way to change the exoplayers surface_type to texture_view which is needed for rotation to work.
At the moment we hot patch the plugin to load a layout of this form.
<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="texture_view"
/>
</merge>
We do this by applying a patch like this:
diff --git a/node_modules/@nstudio/nativescript-exoplayer/index.android.js b/node_modules/@nstudio/nativescript-exoplayer/index.android.js
index f661303..9af42cb 100644
--- a/node_modules/@nstudio/nativescript-exoplayer/index.android.js
+++ b/node_modules/@nstudio/nativescript-exoplayer/index.android.js
@@ -174,7 +174,22 @@ export class Video extends VideoBase {
this._updateSubtitles(value ? value.android : null);
}
createNativeView() {
- var nativeView = new com.google.android.exoplayer2.ui.PlayerView(this._context);
+ let res = this._context.getResources();
+ const layoutId = res.getIdentifier("player_view", 'layout', this._context.getPackageName());
+ const parser = res.getLayout(layoutId)
+
+ let state = 0;
+ do {
+ state = parser.next();
+ if (state == org.xmlpull.v1.XmlPullParser.START_TAG) {
+ if (parser.getName() === "com.google.android.exoplayer2.ui.PlayerView") {
+ var attrs = android.util.Xml.asAttributeSet(parser);;
+ break;
+ }
+ }
+ } while(state != org.xmlpull.v1.XmlPullParser.END_DOCUMENT);
+
+ var nativeView = new com.google.android.exoplayer2.ui.PlayerView(this._context, attrs);
if (this.enableSubtitles) {
}
return nativeView;
Does anyone know a cleaner way to get this use case working?
Thanks in advance.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in index.android.js at Video.createNativeView(), where PlayerView is currently constructed without the layout attributes shown in the issue. Read the surrounding Android view setup and determine how the plugin should expose the surface_type choice. Done means users can select texture_view for rotation without patching node_modules; no test file is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, typescript
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100