id- id of the player app,com.webos.app.mediadiscoveryfor webOS 6+,com.webos.app.photovideofor webOS 3.x-5.x,com.webos.app.smartsharefor webOS 1.0-2.xfullPath- url of the video filefileName- name of the video displayed in player. Filename is remembered by the player to continue playback from exit timestamp
from a web app
webOS.service.request("luna://com.webos.applicationManager", {
method: "launch",
parameters: { "id": "com.webos.app.photovideo", "params": {"payload":[{
"fullPath":"https://media.w3.org/2010/05/sintel/trailer.mp4",
"artist":"",
"subtitle":"",
"dlnaInfo":{"flagVal":4096,"cleartextSize":"-1","contentLength":"-1","opVal":1,"protocolInfo":"http-get:*:video/x-matroska:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000","duration":0},
"mediaType":"VIDEO",
"thumbnail":"",
"deviceType":"DMR",
"album":"",
"fileName":"trailer",
"lastPlayPosition":-1}]}},
onSuccess: function (inResponse) {
console.log("The app is launched");
},
onFailure: function (inError) {
console.log("Failed to launch the app");
console.log("[" + inError.errorCode + "]: " + inError.errorText);
return;
}
});
from shell
luna-send-pub -n 1 -f luna://com.webos.applicationManager/launch '{"id": "com.webos.app.photovideo", "params": {"payload":[{"fullPath":"https://media.w3.org/2010/05/sintel/trailer.mp4","artist":"","subtitle":"","dlnaInfo":{"flagVal":4096,"cleartextSize":"-1","contentLength":"-1","opVal":1,"protocolInfo":"http-get:*:video/x-matroska:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000","duration":0},"mediaType":"VIDEO","thumbnail":"","deviceType":"DMR","album":"","fileName":"trailer","lastPlayPosition":-1}]}}'
# 1
luna-send -f -n 1 luna://com.webos.service.settings/setSystemSettings '{"category":"picture","settings":{"energySaving":"screen_off","energySavingModified":"true"}}'
//screen will turn back on with any remote key
# 2
luna-send -n 1 "luna://com.webos.service.tvpower/power/turnOffScreen" '{}'
luna-send -n 1 "luna://com.webos.service.tvpower/power/turnOnScreen" '{}'
luna-send -n 1 -f 'luna://com.webos.service.capture/executeOneShot' '{"path":"/tmp/'"$(date +%Y_%m_%d_%H-%M-%S)"'_capture.png","method":"DISPLAY","format":"PNG"}'
mediaId is assigned by webos media server to any opened media pipeline. Value is required to perform direct com.webos.media calls to control playback of videos.
document.querySelector('video').mediaId
Public Luna calls that return video details including mediaId (may not be supported on older webOS versions)
luna://com.webos.service.videooutput/getStatus
luna://com.webos.media/getForegroundAppInfo
luna://com.webos.media/getActivePipelines
Direct use of com.webos.media by application developers is strongly discouraged. Instead, the media interfaces native to a particular application framework (e.g. Web, QT, SDL/NDL) should be used. However some standard web apis (like managing subtitles) are not supported leaving us no choice rather to use direct calls.
method setSubtitleEnable
parameters:
mediaIdenable-trueto show subtitles,falseto hide subtitles
Example
webOS.service.request("luna://com.webos.media", {
method:"setSubtitleEnable",
parameters: {
"mediaId": "_MQUBT01X5MiTj4",
"enable": true
},
onSuccess: function (result) {
console.log(JSON.stringify(result));
}
},
onFailure: function (result) {
console.log( "[fail][" + result.errorCode + "] " + result.errorText );
}
});
method selectTrack
parameters:
mediaIdtype-audiofor audiotracks,textfor subtitletracksindex- number of track (0...n)
method setSubtitleFontSize
parameters:
mediaIdfontSize- values:0for tiny,1- small,2- standard (default),3- large,4- huge
method setSubtitleColor
parameters:
mediaIdcolor- values:0- yellow,1- red,2- white (default),3- green,4- blue,5- gray
method setSubtitlePosition
parameters:
mediaIdposition- values:-3for lowest position,-2,-1,0(default),1,2,3,4for highest position
method setSubtitleCharacterOpacity
parameters:
mediaIdcharOpacity- values: from0for fully transparent to255for non-transparent (default)
(seems to do the same as setSubtitleColor but some different values)
method setSubtitleCharacterColor
parameters:
mediaIdcharColor- values:black,white(default),yellow,red,green,blue
method setSubtitleBackgroundOpacity
parameters:
mediaIdbgOpacity- values: from0for fully transparent (default) to255for non-transparent
method setSubtitleBackgroundColor
parameters:
mediaIdbgColor- values:black(default),white,yellow,red,green,blue
method setSubtitleWindowOpacity
parameters:
mediaIdwindowOpacity- values: from0for fully transparent (default) to255for non-transparent
method setSubtitleWindowColor
parameters:
mediaIdwindowColor- values:black(default),white,yellow,red,green,blue
method setSubtitleEncoding
parameters:
mediaIdencoding- values:ISO8859-1,ISO6937,UTF-8,WINDOWS-1252,WINDOWS-1250,ISO8859-4,WINDOWS-1251,WINDOWS-1256,WINDOWS-1253,ISO8859-8,ISO8859-9,ISO8859-11,WINDOWS-1258,BIG5,GB2312,EUCKR,Shift_JIS
method setSubtitleSource
parameters:
mediaIdurilink to subtitles file (i.e.http://some.website/filename.srtor local filefile:///tmp/usb/sda/sda1/filename.srt)preferredEncodings- optional parameter
method setSubtitleSync
parameters:
mediaIdsync- values: +-sync in milliseconds (i.e.-350,200,1500, etc)
method setPlayRate
parameters:
mediaIdplayRate- values from0.1to2.0, default is1.0audioOutput-true, audio is played only up to x2 playback rate
To get video detailed data like number of embedded audio and subtitle tracks may be needed to subscribe to pipeline events and parse sourceInfo generated after media is loaded (https://www.webosose.org/docs/reference/ls2-api/com-webos-media/#sourceinfo-1)
method subscribe
parameters:
mediaIdsubscribe-true
To unsubscribe use method unsubscribe with only parameter mediaId
Example of sourceInfo object
{"sourceInfo":{"numPrograms":1,"container":"mkv","seekable":true,"trickable":true,"programInfo":[{"duration":1295552,"numAudioTracks":4,"audioTrackInfo":[{"bitRate":0,"language":"ru","codec":"ac3","sampleRate":48,"channels":2,"audioType":0},{"bitRate":0,"language":"ru","codec":"ac3","sampleRate":48,"channels":2,"audioType":0},{"bitRate":0,"language":"ru","codec":"ac3","sampleRate":48,"channels":2,"audioType":0},{"bitRate":0,"language":"en","codec":"ac3","sampleRate":48,"channels":6,"audioType":0} ],"numVideoTracks":1,"videoTrackInfo":[{"angleNumber":0,"level":3.1,"width":1280,"height":720,"codec":"H264","profile":"high","frameRate":23.976,"progressive":true} ],"numSubtitleTracks":2,"subtitleTrackInfo":[{"language":"ru","type":"text"},{"language":"en","type":"text"} ]} ],"mediaId":"_MQUBT01X5MiTj4"}}
Audiotrack may have disposition.default tag. WebOS 4+ reads this tag and puts the track marked as default into the first position of tracks list (index 0)



Hmmm. For example, from Home Assistant, we can send button event to LG webOS. Home Assistant has LG webOS Smart TV integration which is communicate with webOS via REST API I think. I was meant if this can be done from Home Assistant via API, then most probably there is some endpoint where shell command could interact via luna://
In this particular case where I am interested to confirm "Yes" button on current on-screen alert, what I am actually doing:
I have bluetooth audio amplifier, connected to Monitor Audio speakers by wires. TV is connecting to amplifier via bluetooth. Every time when I turn on TV, I have to manually go to sound devices, switch to BT device, choose my amplifier, click on connect. I want to automate this, and since my C1 is already rooted, I can write init.d scripts (already have few of them).
So I have this for connect to BT amplifier:
luna-send -f -n 1 luna://com.webos.service.bluetooth2/a2dp/connect '{"address": "7b:b1:b9:be:82:fe"}'(Devices are already paired before, so there is no need for that step. However, if anybody need it, there is pairing and a lot more about BT here: https://www.webosose.org/docs/guides/development/connectivity/bluetooth-guide/)
Anyway, after previous command, devices are connected, but UI alert pops-up and asking to accept this:

I can even switch to BT sound output with the following command:
luna-send -f -n 1 luna://com.webos.service.apiadapter/audio/changeSoundOutput '{"output": "bt_soundbar"}'It is working, output on TV was changed to BT, but alert stay on screen, and:
So, since "Yes" button is already focused on alert, it seems that I only missing the part how to send ENTER button event from command line with
luna-send- this is what I cannot find how to do.