iOS DLNA投屏功能
基于 https://github.com/KeyYao/DLNAWrapper 代码修改
pod 'DLNAWrapper'
[DLNAUpnpServer shareServer].delegate = self;
[[DLNAUpnpServer shareServer] startAndSearch:YES];[[DLNAUpnpServer shareServer] selectedDeviceWithDevice:device];流程: 停止 -> 设置uri -> 获取进度和音量 -> 播放 -> 更新进度
[SelectedDevice stopWithSuccess:^{
[self setUri];
} failure:^(NSError *error) {
}];
设置uri
[SelectedDevice setUriWithURI:url success:^{
self.isUpdateProgress = YES;
[self getPositionInfo];
[self getVolume];
[self play:nil];
} failure:^(NSError *error) {
NSLog(@"设置 URL 失败");
}];播放
[SelectedDevice playWithSuccess:^{
} failure:^(NSError *error) {
NSLog(@"播放失败");
}];[[FileServer shareServer] start];- Demo目录下
pod install- 打开DLNAWrapper.xcworkspace
- ps: 例子写的有点随便,请不要在意
感谢 KeyYao!