Android Native.newwebview: Embed Youtube Video Doesn't Work

None.  We have no plans on implementing this because it is rarely requested.

I suggest that you use the above work-arounds instead, such as using system.openURL().

مصطفى، كيف حالك؟

I have a few projects that use Youtube video, and at the moment I use the solutions I described above. They work, but it’s not an optimal user experience. I’m planning to write some plugins for Android and iOS at some point in time to integrate Youtube videos on a native level using the Youtube Android Player API and Youtube iOS Helper Library. This should provide a better user experience across platforms.

I don’t have a time-frame for when this will happen. I also need to develop a proof of concept to make sure what I’m planning will give me the results I want/expect. I’ll update this thread when and if I have something to show.

@Joshua

Thank you for your answer. Even if this feature is not requested by such user number, I believe it’s a fundamental one.

@ingemar

الحمد لله بخير وعافية

It’s true, the above solution works, but as you mentioned, not an ideal one. Glad to know that you are planning to do something is this regards. I will be waiting to see what you have done. Thanks ingemar

No problem, Mustafa.

I’ll keep you posted.

PS.

My Arabic is quite rusty since it’s been a long time ago I used it. I lived in Riyadh for 7 years and managed to be able to master the alphabet at least :slight_smile: Still have my Nawal Al-Zoghbi and Ragheb Alama CD’s though  :D.

Okay, finally I got Youtube video works on Android (a work-around solution).  

Here is what I did:

  1. Download: https://github.com/jeckman/YouTube-Downloader

  2. Upload it to my server

  3. Use media.playVideo() API to play the video

  4. See the code below I use in my app to run the video relaying on the script mentioned above to give the direct link of Youtube video:

    local function watchButtonsListener(event) if event.phase == “moved” then elseif event.phase == “ended” then print("\n"…event.target.id…" was Pressed") local buttonID = event.target.id display.getCurrentStage():setFocus(nil) local onComplete = function(event) print( “video session ended” ) end – c_video is youtube video ID media.playVideo( “http://example.com/yt/getvideo.mp4?videoid=”… c_video …"&format=ipad", true, onComplete ) end return true end local playButton = widget.newButton {     defaultFile = “images/button.png”,     overFile = “images/button.png”,     width = _W,     height = 30,     label = “Play Video”,     labelAlign = “center”,     fontSize = 16,     font = native.systemFont, labelColor = { default = { 1, 1, 1, 1 }, over = { 0, 158/255, 233/255, 1 }, }, id = i, onEvent = watchButtonsListener, } transition.from(playButton,{delay=0,alpha=0,time=505}) playButton.anchorX = 0 playButton.anchorY = 0 playButton.x = 0 playButton.y = 20 group:insert(playButton)

I hope this helps anyone experiencing the same issue. 

Regards,

Mustafa

!الحمد لله

Now *that* looks very interesting. Good find!
I’ll have to have a look a that :slight_smile:

Thanks

@Joshua, any update? 

None.  We have no plans on implementing this because it is rarely requested.

I suggest that you use the above work-arounds instead, such as using system.openURL().

مصطفى، كيف حالك؟

I have a few projects that use Youtube video, and at the moment I use the solutions I described above. They work, but it’s not an optimal user experience. I’m planning to write some plugins for Android and iOS at some point in time to integrate Youtube videos on a native level using the Youtube Android Player API and Youtube iOS Helper Library. This should provide a better user experience across platforms.

I don’t have a time-frame for when this will happen. I also need to develop a proof of concept to make sure what I’m planning will give me the results I want/expect. I’ll update this thread when and if I have something to show.

@Joshua

Thank you for your answer. Even if this feature is not requested by such user number, I believe it’s a fundamental one.

@ingemar

الحمد لله بخير وعافية

It’s true, the above solution works, but as you mentioned, not an ideal one. Glad to know that you are planning to do something is this regards. I will be waiting to see what you have done. Thanks ingemar

No problem, Mustafa.

I’ll keep you posted.

PS.

My Arabic is quite rusty since it’s been a long time ago I used it. I lived in Riyadh for 7 years and managed to be able to master the alphabet at least :slight_smile: Still have my Nawal Al-Zoghbi and Ragheb Alama CD’s though  :D.

Okay, finally I got Youtube video works on Android (a work-around solution).  

Here is what I did:

  1. Download: https://github.com/jeckman/YouTube-Downloader

  2. Upload it to my server

  3. Use media.playVideo() API to play the video

  4. See the code below I use in my app to run the video relaying on the script mentioned above to give the direct link of Youtube video:

    local function watchButtonsListener(event) if event.phase == “moved” then elseif event.phase == “ended” then print("\n"…event.target.id…" was Pressed") local buttonID = event.target.id display.getCurrentStage():setFocus(nil) local onComplete = function(event) print( “video session ended” ) end – c_video is youtube video ID media.playVideo( “http://example.com/yt/getvideo.mp4?videoid=”… c_video …"&format=ipad", true, onComplete ) end return true end local playButton = widget.newButton {     defaultFile = “images/button.png”,     overFile = “images/button.png”,     width = _W,     height = 30,     label = “Play Video”,     labelAlign = “center”,     fontSize = 16,     font = native.systemFont, labelColor = { default = { 1, 1, 1, 1 }, over = { 0, 158/255, 233/255, 1 }, }, id = i, onEvent = watchButtonsListener, } transition.from(playButton,{delay=0,alpha=0,time=505}) playButton.anchorX = 0 playButton.anchorY = 0 playButton.x = 0 playButton.y = 20 group:insert(playButton)

I hope this helps anyone experiencing the same issue. 

Regards,

Mustafa

!الحمد لله

Now *that* looks very interesting. Good find!
I’ll have to have a look a that :slight_smile:

Thanks