Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
axiomy
Visitor

detecting SD or HD for proper playback

I have implemented HD to my channel and I am having trouble getting the channel to detect if the user is in SD. When a user in SD tries to watch a HD video it kicks back and won't play. What I need it to do is to detect if the user is in SD and play the SD version of a file. I have my channel set up similar to TWIT with categories for SD video and HD video. When I am in SD and go to TWIT and try and watch a HD video it plays the SD version. This is what I would like to implement. My channel is based off of the videoplayer example in the SDK.


I added 2 codes to try and allow this to happen but now the categories wont load. Can anybody help me solve this problem? What is the best way to detect SD or HD when playing a video?

Here is what I attempted to do
I placed this code in my deviceInfo.brs :

Function hd() as Boolean
di=createobject(roDeviceInfo)
if di.getdisplaytype()="HDTV" then
return true
else
return false
end if
end function


I tried placing the code:

If not hd() then
if item.StreamFormat="mp4" then
item.ishd=false
Else if item.streamFormat="hls" then
item.streamQuality=["SD"]
End if
End if

several places in my showFeed.brs with the same results none of my buttons will load.

Below are my changes.



My xml code looks like this for a video:


<item sdImg="http://www.paranormalreality.tv/prtv/images/deadtruth2.0.jpg" hdImg="http://www.paranormalreality.tv/prtv/images/deadtruth2.0.jpg">
<title>The Dead Truth Helena Texas Act 1 Episode 1</title>
<contentId>tdt000</contentId>
<contentType>Haunted</contentType>

<contentQuality>SD</contentQuality>
<contentQuality>HD</contentQuality>
<streamFormat>hls</streamFormat>
<switchingStrategy>full-adaptation</switchingStrategy>
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://Link to SD video</streamUrl>

<streamQuality>HD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://Link to HD video</streamUrl>
</media>
<synopsis>The Klinge Brothers and Everyday Paranormal bring you The Dead Truth Helena Texas Act 1 Episode 1</synopsis>
<genres>Clip</genres>
<runtime>1627</runtime>
</item>








here is my deviceInfo.brs

'**********************************************************
'** Video Player Example Application - DeviceInfo
'** November 2009
'** Copyright (c) 2009 Roku Inc. All Rights Reserved.
'**********************************************************

'******************************************************
'Get our device version
'******************************************************

Function GetDeviceVersion()
return CreateObject("roDeviceInfo").GetVersion()
End Function

'******************************************************
'Get our serial number
'******************************************************

Function GetDeviceESN()
return CreateObject("roDeviceInfo").GetDeviceUniqueId()
End Function

Function hd() as Boolean
di=createobject(roDeviceInfo)
if di.getdisplaytype()="HDTV" then
return true
else
return false
end if
end function











Here is my showFeed.brs:

if e <> invalid then
item.StreamBitrates.Push(strtoi(validstr(e.streamBitrate.GetText())))
item.StreamQualities.Push(validstr(e.streamQuality.GetText()))
item.StreamUrls.Push(validstr(e.streamUrl.GetText()))
endif
next idx

showCount = showCount + 1
feed.Push(item)

skipitem:

next


End Function
0 Kudos
7 REPLIES 7
bandal
Visitor

Re: detecting SD or HD for proper playback

In your xml set the StreamQuality and ContentQuality to SD and that will solve for both.
0 Kudos
TheEndless
Channel Surfer

Re: detecting SD or HD for proper playback

<media>
<streamQuality>SD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://Link to SD video</streamUrl>

<streamQuality>HD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://Link to HD video</streamUrl>
</media>

This portion of your XML is probably part of the problem. You can't specify multiple Qualities, Bitrates, and URLs in the same media element.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
axiomy
Visitor

Re: detecting SD or HD for proper playback

"bandal" wrote:
In your xml set the StreamQuality and ContentQuality to SD and that will solve for both.


Wouldn't that make it to where it would play in SD only?
0 Kudos
axiomy
Visitor

Re: detecting SD or HD for proper playback

"TheEndless" wrote:
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://Link to SD video</streamUrl>

<streamQuality>HD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://Link to HD video</streamUrl>
</media>

This portion of your XML is probably part of the problem. You can't specify multiple Qualities, Bitrates, and URLs in the same media element.



How would I be able to get the HLS adaptive to determine which stream is HD and which stream is SD?
0 Kudos
destruk
Streaming Star

Re: detecting SD or HD for proper playback

<media>
<streamQuality>SD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://Link to SD video</streamUrl>
</media>
<media>
<streamQuality>HD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://Link to HD video</streamUrl>
</media>


by parsing an array of streams with multiple media tags.
0 Kudos
TheEndless
Channel Surfer

Re: detecting SD or HD for proper playback

"axiomy" wrote:
"TheEndless" wrote:
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://Link to SD video</streamUrl>

<streamQuality>HD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://Link to HD video</streamUrl>
</media>

This portion of your XML is probably part of the problem. You can't specify multiple Qualities, Bitrates, and URLs in the same media element.

How would I be able to get the HLS adaptive to determine which stream is HD and which stream is SD?

HLS doesn't require multiple streams to be defined in the XML. The multiple streams are intrinsic to HLS, as they're included in the M3U8 playlist. You need to make sure you don't set the streamQuality value, and you should be good to go. If you specify a streamQuality of "HD" then it will only play at HD resolutions, so try removing that element altogether.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
destruk
Streaming Star

Re: detecting SD or HD for proper playback

ah, HLS... thanks 🙂
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.