Skip to main content
Djwaas
Participant
July 7, 2015
Answered

Displaying a Youtube video within an AIR Android app

  • July 7, 2015
  • 1 reply
  • 1740 views

Hello;

I'm trying to display a Youtube video within an AIR Android app.

Usually, I call the Youtube API player like this (barebones only):

loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));

player = loader.content;

player.loadVideoById("12345678901",0);

I don't know why, but this method doesn't work anymore.

Here's what happens on the ANDROID device (I compiled using AIR v18):

The video seems to be buffering for a few seconds, then the movieClip holding the API player becomes transparent, no video is displayed.

The sound of the video is playing though.

Meanwhile, on the ADL, the video shows up as it should.

I'm using Android 5, the Youtube Video is on public status, and I already re-tried after uninstalling the Android app (but does it clear the cache?).

Does anybody has a clue on what's going on?

Thanks a lot!

This topic has been closed for replies.
Correct answer janfw9969106

Could you check if you have hardwareAccelerated being set to true in your application descriptor?

<android>

     <manifestAdditions>

          <![CDATA[

          <manifest>

               <application android:hardwareAccelerated="true"/>

          </manifest> ]]>

     </manifestAdditions>

</android>

Also, check if you are using the <containsVideo> tag in your app descriptor since this may cause problems.

1 reply

janfw9969106Correct answer
Inspiring
July 8, 2015

Could you check if you have hardwareAccelerated being set to true in your application descriptor?

<android>

     <manifestAdditions>

          <![CDATA[

          <manifest>

               <application android:hardwareAccelerated="true"/>

          </manifest> ]]>

     </manifestAdditions>

</android>

Also, check if you are using the <containsVideo> tag in your app descriptor since this may cause problems.

Djwaas
DjwaasAuthor
Participant
July 8, 2015

Hi:

I compiled the app in CPU mode, then GPU then DIRECT mode.

In each mode, I've set <application android:hardwareAccelerated="true"/> then to false.

Result is the same: The Youtube video is transparent but the sound is there.

There's no <containsVideo> tag in my descriptor, since it's a simple descriptor as generated by Flash pro CS6.

Google officially says that the YouTube ActionScript 3.0 Player API has been DEPRECATED: developers.google.com/youtube/flash_api_reference?hl=en  (PS: DEPRECATED doesn't mean necessarely Dropped).

So I tried the StageWebView + iFrame solution as described here: developers.google.com/youtube/iframe_api_reference

The results are still not good: Video Thumbnail is displayed, but when the play button is hit, the buffering circles are displayed and I get stuck there.


Any help?

Inspiring
July 9, 2015

In one of our apps (iOS, Android) we are using StageWebView displaying YouTube video, which works well. I have just checked and found out that for the Android version StageVideo is explicitly disabled (I'm sure I've had similar issues with Android devices not displaying the video) - the following might work for you, too:

import org.osmf.utils.OSMFSettings;

OSMFSettings.enableStageVideo = false;

Also, in the application descriptor containsVideo is set to true:

<android>

  <colorDepth>16bit</colorDepth>

  <manifestAdditions>

  <![CDATA[

  [...]

  ]]>

  </manifestAdditions>

<containsVideo>true</containsVideo>

</android>