expo-dlna-player
Version:
A React Native/Expo module for DLNA/AirPlay media casting to smart TVs and streaming devices
29 lines • 1.09 kB
JavaScript
import ExpoDlnaPlayerModule from './ExpoDlnaPlayerModule';
export { default } from './ExpoDlnaPlayerModule';
export * from './ExpoDlnaPlayer.types';
/**
* 连接到DLNA/AirPlay设备
* @param deviceId 设备ID
* @returns 是否连接成功
*/
export async function connectToDevice(deviceId) {
try {
console.log(`[Expo DLNA Player] 连接到设备: ${deviceId}`);
// 获取设备信息
const deviceInfoList = await ExpoDlnaPlayerModule.getDevices();
const device = deviceInfoList.find(d => d.id === deviceId);
if (!device) {
console.error(`[Expo DLNA Player] 设备未找到: ${deviceId}`);
return false;
}
if (device.type === 'dlna' && !device.controlURL) {
console.warn(`[Expo DLNA Player] 警告: DLNA设备缺少controlURL, 设备ID: ${deviceId}`);
}
return await ExpoDlnaPlayerModule.connectToDevice(deviceId);
}
catch (error) {
console.error('[Expo DLNA Player] 连接设备失败:', error);
throw error;
}
}
//# sourceMappingURL=index.js.map