Streaming and Playing AV

Streaming and Playing AV

what is the correct way to play youtube link English Forum > Streaming and Playing AV

  • Reply 8
  • View 2197

Hi all,


i try to play a link from youtube inside the SmartTV.

I use YTPlayer, the code can be found at bottom section of this message. 


This code can display the video, but need to be set as autoplay and HTML5. 

And, somehow, this is not stable. 

Sometimes, the video can be played. 

Sometimes, it will display blank screen. 


Another information : 

At 2012 tv, this code is working . 

but at 2011 tv, can't play the youtube


Any suggestion for play youtube at SmartTV will be helpful. 



Code : 

 player2 = new YT.Player('player2', {

height:'320',

width:'520',

videoId: getYoutubeID(url),

playerVars: { 'html5':1,'autoplay': 1, 'controls': 0 },

events: {

'onReady': onPlayerReady,

'onStateChange': onPlayerStateChange

}

});

var done = false;

function onPlayerStateChange(event) {

  if (event.data == YT.PlayerState.PLAYING && !done) {

    setTimeout(stopVideo, 6000);

    done = true;

  }

}

function onPlayerReady(event) {

    event.target.playVideo();

  }

Edit by 0 2012.10.19

What do you think about this article?

UP 0

DOWN 0

BOOK MARK 0

RE :

Hi,

Recently i've played youtube using swfobject.js and youtube javascript API and it seems no problem for 2012 TV models.

Link: https://developers.google.com/youtube/js_api_reference#Embedding


But make sure the scripts included in index.html, i don't know why if i call the script inside Main.js or else the youtube ready callback never called. Hope it can help


Regards,

I Made Krisna

RE :

Hi Krisna,


Thanx for your feedback. 

So, do we need to specify the video id at index.html at load at first time we launch the application?

can we pass the id via a function and call embedSWF when press a button?


below is the script from google :

swfobject.embedSWF('http://www.youtube.com/v/VIDEO_ID?enablejsapi=1&playerapiid=ytplayer&version=3',                       'ytapiplayer', '425', '356', '8', null, null, params, atts);

Because,i will have a list of video title that come from xml. 

choose one video title, then the app will play the youtube. 


another question : 

- how about handling the video via remote button, is this embedSWF work smoothly ?

- is this runable at 2011 tv ? 



RE :

Ah, yes

i got same problem with that, youtube player must specify the video id so i put all 0 (zero) with same digits to the video id.

If i'm not wrong, youtube video id is 11 digits, so i use video id = 00000000000

RE :

quote

This has been quoted from [joaan]'s post.

another question : 

- how about handling the video via remote button, is this embedSWF work smoothly ?

- is this runable at 2011 tv ? 


 

For these questions,

- Yes, in my experience with ES7500 the embed work smooth

- This method is not runnable at 2011 TV, but you can do old embed style of youtube for 2011 TV (just harder to implement than the swfobject method)

RE :

Hi im.krisna, 


thanx for  your advice.

For 2012, i've tried your suggestion. Also like my previous code, able to play video from youtube. Just need to test the stability. 

For the control using remote , i'm able to PLAY, PAUSE, but can't control the volume. 

Is there a way to control the youtube volume ? or do we need to control the tv volume instead of youtube volume ? 


For 2011, i already tried your suggestion using old embed. I can play the video, but can not control (PLAY,PAUSE,VOLUME). 



regards,

RE :

Hi,

yeah i will suggest to use TV volume control because as far as i know it's the easiest method to do volume controlling and some policy of apps also mentioning to use tv control.


FYI the guide for using tv volume osd: http://www.samsungdforum.com/Guide/tec00107/index.html

RE :

quote

This has been quoted from [im.krisna]'s post.

Hi,

yeah i will suggest to use TV volume control because as far as i know it's the easiest method to do volume controlling and some policy of apps also mentioning to use tv control.


FYI the guide for using tv volume osd: http://www.samsungdforum.com/Guide/tec00107/index.html

 hey joaan and krishna , i am also tring to work on SSTv youtube application , which is showing video from a channel , and on play in am using an popup function to play the video and i an unable to do play n pause via remote , seems like you guys have done that so little help will be appreciated and also u mention to add code on index.html other wise callback not work and thats the main issue i have thankyou , 


RE :

File 1

quote

This has been quoted from [aaqib]'s post.

quote

This has been quoted from [im.krisna]'s post.

Hi,

yeah i will suggest to use TV volume control because as far as i know it's the easiest method to do volume controlling and some policy of apps also mentioning to use tv control.


FYI the guide for using tv volume osd: http://www.samsungdforum.com/Guide/tec00107/index.html

 hey joaan and krishna , i am also tring to work on SSTv youtube application , which is showing video from a channel , and on play in am using an popup function to play the video and i an unable to do play n pause via remote , seems like you guys have done that so little help will be appreciated and also u mention to add code on index.html other wise callback not work and thats the main issue i have thankyou , 


 I am able to use the play and pause button in the 'youtube' app. I am attaching a sample code, go through it and see whether you can solve your problem.
If it doesn't help share your code, I'd like to have a look at the issue myself and tackle it headon.