Skip to content

Commit

Permalink
feat: add getAppIcon method (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylancom authored Feb 19, 2021
1 parent 0436c86 commit 9136e14
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ control
}
})

// Get app icon by iconPath which you can get from getAppsFromTV
control.getAppIcon(
`/opt/share/webappservice/apps_icon/FirstScreen/${APPS.YouTube}/250x250.png`,
(err, res) => {
if (!err) {
console.log('# Response getAppIcon', res)
}
}
)

// Open app by appId which you can get from getAppsFromTV
control.openApp(APPS.YouTube, (err, res) => {
if (!err) {
Expand Down
10 changes: 10 additions & 0 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ control
}
})

// Get app icon by iconPath which you can get from getAppsFromTV
control.getAppIcon(
`/opt/share/webappservice/apps_icon/FirstScreen/${APPS.YouTube}/250x250.png`,
(err, res) => {
if (!err) {
console.log('# Response getAppIcon', res)
}
}
)

// Open app by appId which you can get from getAppsFromTV
control.openApp(APPS.YouTube, (err, res) => {
if (!err) {
Expand Down
13 changes: 13 additions & 0 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ export function getMsgInstalledApp() {
}
}

export function getMsgAppIcon(iconPath: string) {
return {
method: 'ms.channel.emit',
params: {
data: {
iconPath
},
event: 'ed.apps.icon',
to: 'host'
}
}
}

export function getMsgLaunchApp(app: App) {
return {
method: 'ms.channel.emit',
Expand Down
9 changes: 9 additions & 0 deletions src/samsung.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
chr,
getVideoId,
getMsgInstalledApp,
getMsgAppIcon,
getMsgLaunchApp,
getCommandByKey,
getSendTextCommand,
Expand Down Expand Up @@ -172,6 +173,14 @@ class Samsung {
return this._sendPromise(getMsgInstalledApp())
}

public getAppIcon(iconPath:string, done?: (err: Error | { code: string } | null, res: WSData | string | null) => void) {
return this._send(getMsgAppIcon(iconPath), done)
}

public getAppIconPromise(iconPath: string): Promise<WSData | null> {
return this._sendPromise(getMsgAppIcon(iconPath))
}

public openAppByAppIdAndType(
appId: string,
type: number,
Expand Down

0 comments on commit 9136e14

Please sign in to comment.