Swift 中的 Smart View SDK,如何连接电视并发送按键命令? ChannelId 和 appId 是什么?

问题描述 投票:0回答:1

我已经在ios中用swift实现了三星远程控制电视应用程序,并手动完成了所有操作,现在想切换到smart-view-sdk,此时我能够发现本地网络中的电视,下一步是: 连接到电视(服务:服务) 启动应用程序(应用程序ID:字符串) sendKeyCommand(命令键:字符串) 并投射视频/照片

这是我当前的代码?有人可以帮我完成这些步骤吗,我已经阅读了文档

这是我的代码:

import Foundation
import SmartView
import Network

class SamsungService: ServiceSearchDelegate, ObservableObject {
    
    @Published
    var services = [Service]()
    
    let serviceSearch = Service.search()
    var didFindServiceObserver: AnyObject? = nil
    var didRemoveServiceObserver: AnyObject? = nil
    
    init() {
        self.serviceSearch.start()
        listenForNotifications()
    }
    
    func connectTo(_ service: Service) {
        
    }

    func launchApp(_ appId: String, on service: Service) {
        
    }
    
    func sendCommand(_ command: String, to service: Service) {
        
    }
 
    func listenForNotifications() {
        didFindServiceObserver = NotificationCenter.default.addObserver(forName: Notification.Name(rawValue: MSDidFindService), object: serviceSearch, queue: .main, using: { notification in
            guard let service = notification.userInfo?["service"] as? Service else { return }
            self.services.append(service)
        })
        
        didRemoveServiceObserver = NotificationCenter.default.addObserver(forName: Notification.Name(rawValue: MSDidRemoveService), object: serviceSearch, queue: .main, using: { notification in
            let service = notification.userInfo?["service"] as? Service
            self.services.removeAll(where: { $0.id == service?.id })
        })
    }
}
ios sdk samsung-smart-tv smartview
1个回答
0
投票

我有同样的问题,我也连接到SamSungTV但无法投射视频/照片,有人有这个问题的解决方案吗?

© www.soinside.com 2019 - 2024. All rights reserved.