按照官网文档写的demo,连接不上,以下是代码
AvController:
ElementName elementName = new ElementName("", "com.example.myapplication", "com.example.mediademo.AVService");
// connectionCallback在调用avBrowser.connect方法后进行回调。
avBrowser = new AVBrowser(getAbility(), elementName, connectionCallback, null);
// avBrowser发送对媒体浏览器服务的连接请求。
avBrowser.connect();
if(avBrowser.isConnected()){
Logger.getGlobal().info("### isConnected");
}else{
Logger.getGlobal().info("### notConnect");
}
// 将媒体控制器注册到ability以接收按键事件。
AVController.setControllerForAbility(getAbility(), avController);config:
{
"app": {
"bundleName": "com.example.myapplication",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 4,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.mediademo",
"name": ".MyApplication",
"deviceType": [
"phone",
"tv",
"tablet"
],
"reqPermissions": [
{
"name": "harmonyos.permission.READ_MEDIA"
},
{
"name": "ohos.permission.INTERNET"
},
{
"name": "harmonyos.permission.INTERNET"
},
{
"name": "ohos.permission.GET_NETWORK_INFO"
},
{
"name": "ohos.permission.INTERNET"
},
{
"name": "ohos.permission.READ_USER_STORAGE"
},
{
"name": "ohos.permission.WRITE_USER_STORAGE"
},
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
},
{
"name": "ohos.permission.DISTRIBUTED_DEVICE_STATE_CHANGE"
},
{
"name": "ohos.permission.GET_DISTRIBUTED_DEVICE_INFO"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
}
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "MediaDemo",
"moduleType": "feature"
},
"abilities": [
{
"orientation": "unspecified",
"visible": true,
"name": "com.example.mediademo.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "MyApplication",
"type": "page",
"launchType": "standard",
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home",
"action.audioplay",
"action.audiorecord",
"action.soundplay",
"action.videoplay",
"action.image",
"action.wlan",
"action.bluetooth"
]
}
]
},
{
"name": "com.example.mediademo.AVClientAbility",
"icon": "$media:icon",
"description": "avccontroller",
"type": "page",
"visible": true,
"launchType": "standard",
"skills": [
{
"actions": [
"ability.123"
]
}
]
},
{
"name": "com.example.mediademo.AVService",
"icon": "$media:icon",
"description": "AVBrowserService",
"type": "service",
"skills": [
{
"actions": [
"action.media.browse.AVBrowserService"
]
}
]
}
]
}
}执行结果:
connectioncallback没有任何回调反应,包括onConnectFailed
log显示 ### notConnect
是哪里配置有问题吗?






































苏公安网备 32011402010933号