Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

playing sounds on samsung smart tv

I am developing a simple game for samsung smart tv. I want to play little sound files when certain things happened like ready, win, lose. I don't want to deal with flash players, player controls .. Is there a way to use javascript to trigger a play sound action with a predefined sound volume and i nwant to do this several times in my code.

like image 526
Enes Avatar asked Apr 04 '12 07:04

Enes


People also ask

Why is my Samsung Smart TV not playing sound?

On your TV, navigate to Settings, then select Support, and then select Self Diagnosis. Select Sound Test and wait for the test to finish. If the test reveals a problem, you can try resetting the sound. From Settings, select Sound, then select Expert Settings, and then select Reset Sound.

Where is sound settings on Samsung Smart TV?

Press the Home button on the remote, and then navigate to Settings. Select Sound, and then select Sound Mode. From there, select the one that sounds best to you.


3 Answers

You need to add player object (SAMSUNG-INFOLINK-PLAYER) into your <body> tag:

<object id="pluginPlayer" style="visibility: hidden; width: 0px; height: 0px; opacity: 0.0" classid="clsid:SAMSUNG-INFOLINK-PLAYER"></object>

And then in the app's javascript just use this function:

var playerObj = document.getElementById('pluginPlayer');
playerObj.Play("absolute_url_to_your_mp3");

As Player plugin executes in different location inside Samsung's filesystem you need always use absolute path to the file. It can be remote one, but you can use location.href of you app's index.html to get absolute local path of app's working directory where you can put the mp3s.

Check the documentation, here:

http://www.samsungdforum.com/Guide/View/Developer_Documentation/Samsung_SmartTV_Developer_Documentation_2.5/API_Reference/JavaScript_APIs/Device_API/Player

like image 63
Adam Lukaszczyk Avatar answered Oct 10 '22 01:10

Adam Lukaszczyk


this was my solution:

add to of index.html file

<body>
    <object id="pluginPlayer" border=0    classid="clsid:SAMSUNG-INFOLINK-PLAYER">
...
...
...
</body>

inside my .js file Scene1.js

SceneScene1.prototype.initialize = function () {
var Player = document.getElementById('pluginPlayer');
var retVal=Player.Play("http://mysite.com/android/smartTV/little_wing.mp3");
...
...
...
}   
like image 31
Jorgesys Avatar answered Oct 10 '22 00:10

Jorgesys


I use the SDK version 5.1 for TVs 2013 and 2014 model years and I have the following code works:

<object id="pluginPlayer" classid="clsid:SAMSUNG-INFOLINK-PLAYER"></object>

var playerObj = document.getElementById('pluginPlayer');
var fileName = location.pathname.substring(location.pathname.lastIndexOf("/") + 1);
playerObj.Play(document.location.href.split(fileName)[0] + 'test.mp3');

And this alternative also works (using Flash):

<div style="position:absolute; z-index:-1;">
    <object type="application/x-shockwave-flash" width="100" height="50" id="fplayer">
        <param name="movie" value="test.swf"/>
        <param name="quality" value="high"/>
        <param name="bgcolor" value="blue"/>
    </object>
</div>

And many thanks to Dobiatowski!

like image 30
Boris Gappov Avatar answered Oct 10 '22 01:10

Boris Gappov