Samsung Smart TV Application: Using TV Volume OSD

Certifying applications is the most annoying stage in Samsung Smart TV Application Development, the Quality Assurance of Samsung rather strict with the application quality for their products. Some of cases are volume policy problem: volume up, volume down, mute, unmute, synchronized mute state with TV signal and more. And after several development of apps, i think let the TV itself control it and visualize the value using volume OSD is the best way to avoid the problems.

Now, let’s take a look how to let the TV control the audio and using TV’s Volume OSD to visualize the values 

First i’ll explain briefly what is Volume OSD. OSD is On-Screen Display so thats mean the Volume OSD is the User Interface from TV to show the user the value of TV Volume now, it is muted or not and so on. Some applications handle the volume control itself so they should create it’s own UI and synchronize the state with UI and actual state of TV which is often create problem if it is not synchronized. Example: pressing mute then the UI mute shown but actually the apps failed to send mute signal to TV.

Okay, now we entering to technical step to make it works… First the config.xml

<?xml version="1.0" encoding="UTF-8"?>
<widget>
	<sometag>somevalue</sometag>
	<fullwidget itemtype="boolean">y</fullwidget>
	<sometag>somevalue</sometag>
</widget>

Make sure if you’re using fullscreen application and didn’t need a TV signal in your apps, assign fullwidget value to “y”, this will register all remote control keys to be handled by your apps and prevent application quit if key like number or program up/down pressed.

Then the index.html should contain the SEF Plugins and APIs needed to make it works. It is pluginAPI and NNAvi + TVMW SEF Plugin.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>IDFC</title>
		<script type='text/javascript' language='javascript' src='$MANAGER_WIDGET/Common/jquery.js'></script>
		<script type='text/javascript' language='javascript' src='$MANAGER_WIDGET/Common/core.js'></script>

		<!--  SEF PLUGIN -->
		<object id="pluginPlayer"	classid="clsid:SAMSUNG-INFOLINK-PLAYER" style="opacity:0.0;background-color:#000000;width:0px;height:0px;"></object>
		<object id="pluginAudio" 	classid="clsid:SAMSUNG-INFOLINK-AUDIO" 	style="opacity:0.0;background-color:#000000;width:0px;height:0px;"></object>
		<OBJECT id='pluginObjectTVMW' border=0 classid='clsid:SAMSUNG-INFOLINK-TVMW' style='opacity:0.0; background-color:#000000;width:0px;height:0px;'></OBJECT>
		<OBJECT id='pluginObjectVideo' border=0 classid='clsid:SAMSUNG-INFOLINK-VIDEO' style='opacity:0.0; background-color:#000000;'></OBJECT>
		<OBJECT id='pluginObjectNNavi' classid='clsid:SAMSUNG-INFOLINK-NNAVI' style='opacity:0.0; background-color:#000000; width:0px;height:0px;'></OBJECT>
		<OBJECT id='pluginObjectAppCommon' classid='clsid:SAMSUNG-INFOLINK-APPCOMMON' style='opacity:0.0; background-color:#000000;width:0px; height:0px;'></OBJECT>

		<!-- API SCRIPTS -->
		<script type='text/javascript' language='javascript' src='$MANAGER_WIDGET/Common/API/Widget.js'></script>
		<script type='text/javascript' language='javascript' src='$MANAGER_WIDGET/Common/API/Plugin.js'></script>
		<script type="text/javascript" language="javascript" src="$MANAGER_WIDGET/Common/API/TVKeyValue.js"></script>

	</head>
	<body>
		<!-- POST LOADING USER DEFINED LIB -->
		<script type="text/javascript" language="javascript" src="app/video.js"></script>
	</body>
</html>

It’s done… Now get into the javascript code to tell the TV to show the Volume OSD and unregister volume up/down key and mute key to let the TV handle the control, so all keys are registered except volume up/down and mute now.

//Show Volume OSD
document.getElementById('pluginObjectNNavi').SetBannerState(1);

//Unregisters Keys
var pluginAPI = new Common.API.Plugin();
pluginAPI.unregistKey(tvKey.KEY_VOL_UP); 	//unregisters volume up button
pluginAPI.unregistKey(tvKey.KEY_VOL_DOWN); 	//unregisters volume down button
pluginAPI.unregistKey(tvKey.KEY_MUTE); 		//unregisters mute button

Original confusing source can be looked at: Volume OSD at samsungdforum.com

4 Thoughts on “Samsung Smart TV Application: Using TV Volume OSD

  1. Hey there,
    This works, but still, there is a (not so small) inconvenient. When I click the “mute” button, the audio does mute, but the TV exits my application and returns to previous source.
    Do you have any idea on how to fix that?
    Thanks in advance,
    Claudius

    • Hi claudius,

      Please try to execute the code above after 3 to 5 seconds after onload application using setTimeout. Sometimes the NNavi object is not ready set on the start of application

  2. It’s work. Thank.

  3. Dear All !

    I have the same this problems, after loading, play default channel, presss CH_Volume (UP/DOWN) , play good with volume control , but when i stop and play channel againt. then press CH_Volume (UP/DOWN) my application exit.

    Do you have any idea on how to fix that?
    Thanks in advance,

    Rayan.

Leave a Reply

Your email address will not be published. Required fields are marked *

Post Navigation