Ooyala SDK problem: is not a valid View instance

android

#1

I’m trying to integrate an Ooyala Player in my app, so i included the SDK for Android. I added this lines to my build.gradle into /platforms/android/app and put OoyalaSDK.aar into /platforms/android/app/libs
build.gradle

android {
     dexOptions {
        jumboMode = true
    }
}
//Ooyala LIBRARY
repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile(name:'OoyalaSDK', ext:'aar')
	compile 'com.google.android.exoplayer:exoplayer:2.6.1'
}

Then, i saw this example from Ooyala docs (it is for native Android) : https://github.com/ooyala/android-sample-apps/blob/stable/BasicPlaybackSampleApp/app/src/main/res/layout/player_simple_layout.xml
So, i tried this:
player.xml

<Page class="page" xmlns="http://www.nativescript.org/tns.xsd" loaded="loaded" id="page">
	<StackLayout xmlns:android="http://schemas.android.com/apk/res/android"
	    id="controlsLayout"
	    android:layout_width="fill_parent"
	    android:layout_height="fill_parent"
	    android:layout_gravity="center_horizontal|bottom"
	    android:orientation="vertical" >
               <com.ooyala.android.OoyalaPlayerLayout
	        id="playerLayout"
	        android:layout_width="fill_parent"
	        android:layout_height="fill_parent"
	        android:layout_gravity="center_horizontal|top"
	        android:layout_weight="4"
	        android:background="#000" >
	    </com.ooyala.android.OoyalaPlayerLayout>
	</StackLayout>
</Page>

But it doesn’t work because i put this “com.ooyala.android.OoyalaPlayerLayout” like an xml element.
So, I changed that and i have this now:
player.xml

<Page class="page" xmlns="http://www.nativescript.org/tns.xsd" loaded="loaded" id="page" >
	<StackLayout xmlns:android="http://schemas.android.com/apk/res/android"
	    id="controlsLayout"
	    android:layout_width="fill_parent"
	    android:layout_height="fill_parent"
	    android:layout_gravity="center_horizontal|bottom"
	    android:orientation="vertical" >
	</StackLayout>
</Page>

player.js

var app = require("application");

exports.loaded = function(args) {
   var controlsLayout = page.getViewById("controlsLayout");
   var playerLayout = new com.ooyala.android.OoyalaPlayerLayout(app.android.context);
   controlsLayout.addChild(playerLayout);
   var domain = new com.ooyala.android.PlayerDomain("http://www.ooyala.com");
   console.dir(playerLayout);
   var options = new com.ooyala.android.configuration.Options.Builder().setShowPromoImage(false).setShowNativeLearnMoreButton(false).setUseExoPlayer(true).build();
    var player = new com.ooyala.android.OoyalaPlayer("SOME_PCODE", domain, options);
    var playerLayoutController = new com.ooyala.android.ui.OoyalaPlayerLayoutController(playerLayout, player);
    if (player.setEmbedCode("SOME_EMBED_CODE")) {
        player.play();
    } else {
        console.log("Asset Failure");
    }
};

And i have this error:

Error: com.ooyala.android.OoyalaPlayerLayout{2b628fe V.E...... ......I. 0,0-0,0} is not a valid View instance.

How can i do that these element to be a valid View? Or how can i do to implement the xml element that use Ooyala (<com.ooyala.android.OoyalaPlayerLayout>)?

Thanks!


#2

Extend View as a custom class that implements OoyalaPlayerLayout.
Docs: https://docs.nativescript.org/plugins/ui-plugin-custom#add-the-ui-bits