API 介绍

启动/关闭服务

//启动服务
MYOUController.of(activity)
    .StartService(cfg)
    .subscribe(
        y->toast("后台服务启动成功"),
        e->toast(e.getMessage())
    );

//关闭服务
 MYOUController.of(activity).Close();

连接/断开设备接口

//投屏码输入连接设备接口
 MYOUController.of(activity)
    .Connect(String code)
    .subscribe(
        y->toast("投屏码连接成功"),
        e->toast("投屏码错误:"+err.getMessage())
    );


//海豚星空投屏设备发现二维码连接(仅仅扫海豚星空投屏二维码有效)
ReturnMsg msg = MYOUController.of(activity).ScanQRCode(String qrCode);


//断开设备连接
MYOUController.of(activity).Disconnect();

开启/断开镜像接口

//申请录屏镜像
 MYOUController.of(activity).StartMirror(MirrorCfg mirrorCfg);


//开启镜像接口发起申请屏幕录制,用户确定镜像,或取消时响应
@TargetApi(Build.VERSION_CODES.M)
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == MYOUController.RECORD_REQUEST_CODE 
        && resultCode == RESULT_OK) {
        //真正开始录屏
        MYOUController.of(activity)
        .onAfterActivityResult(requestCode,resultCode,data);
            //确定           
    }else{
            //取消
    } 
}

//断开镜像
MYOUController.of(activity).StopMirror();

监听DLNA设备上/下线接口

MYOUController.of(activity).SetDmcBrowserClient(new DmcClientWraper.IDmcBrowserClient() {

            @Override
            public void DMCServiceStatusNotify(int status) {

                if (status == DMCClient.DMC_SERVICE_DOWN
                        || status == DMCClient.DMC_SERVICE_ERROR) {
                   //DMC Service 已关闭
                } else {
                   //DMC Service 启动成功
                }
            }

            @Override
            public void DlnaDeviceStatusNotify(DlnaDevice device) {
                Map<String, String> map = new HashMap<>();
                if (ContentDevice.isContentDevice(device)) {
                    switch (device.stateNow) {
                        case DEVICE_STATE_ONLINE:
                            // 有新的内容供应者(发送端设备)上线

                            break;
                        case DEVICE_STATE_OFFLINE:
                            // 有内容供应者(发送端设备)离线                             
                            break;
                        default:
                           //unknown content device state
                            break;
                    }
                } else if (RenderDevice.isRenderDevice(device)) {
                    switch (device.stateNow) {
                        case DEVICE_STATE_ONLINE:
                            // 有新的接收端设备上线                            
                            break;
                        case DEVICE_STATE_OFFLINE:
                            // 有接收端设备离线                             
                            break;
                        default:
                            //unknown render device state
                            break;
                    }
                }
            }

            //DMS媒体文件变更通知 照成无需改动
            @Override
            public void DlnaFilesNotify(String udn, int videoCount, int audioCount,
                                        int imageCount, int fileCount) {
                if (TextUtils.isEmpty(udn)) {
                    return;
                }
                final ContentDevice device = ContentDevice.sDevices.findDeviceByUdn(udn);
                if (device != null) {
                    final int fAudioCount = audioCount;
                    final int fVideoCount = videoCount;
                    final int fImageCount = imageCount;
                    final int fFileCount = fileCount;

                    new Runnable() {
                        public void run() {
                            device.updateContent(DmcClientWraper.sClient, fAudioCount,
                                    fImageCount, fVideoCount, fFileCount);
                        }
                    };
                }
            }
        });

获取发送端分享二维码地址

  String qrUrl = MYOUController.of(activity).GetShareQrUrl();

接收端交互接口

//获取当前发现在线的接收端设备列表
 ArrayList<RenderDevice> list = MYOUController.of(activity).GetOnlineRenderDevices();

// 按名字连接指定设备
 ReturnMsg msg =  MYOUController.of(activity).ConnRenderDevice(String deviceName);

//投屏
 ReturnMsg msg = MYOUController.of(activity).Player.Push(PushContentModel model);

//播放
 MYOUController.of(activity).Player.Play();

// 暂停
 MYOUController.of(activity).Player.Pause();

//停止
MYOUController.of(activity).Player.Stop();

//设置音量 0~100
 MYOUController.of(activity).Player.SetVolume(int volume);

// 拉动滚动条 秒数 0 ~ 到片长
 MYOUController.of(activity).Player.SetSeek(int seek);

// 设置播放倍速 "0.5" "0.75" "1" "1.5" "1.75" "2.0"
 MYOUController.of(activity).Player.SetSpeed(String speed);


//实时查询当前控制接收端的状态
 Disposable timer = MYOUController.of(activity).Player.Query().subscribe(r->{
             // r 为PlayerStatus 类型
        });

//注意 离开控制播放器的UI时候最后取消监听避免浪费资源
/*
 if (timer != null && !timer.isDisposed()) {
    timer.dispose();
    timer = null;
}
*/

dps://action 接口

请联系我们

其他

悬浮窗口申请(非API,因为镜像必须,提供参考)

//镜像功能必须动态申请悬浮窗口 
 private void requestAlertWindowPermission() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (! Settings.canDrawOverlays(this)) {
                Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
                intent.setData(Uri.parse("package:" + getPackageName()));
                startActivityForResult(intent, REQUEST_ALERTWINDOW_PERMISSION_CODE);
            }
        }
    }
Copyright © myouworld.cn 2020 all right reserved,powered by Gitbook该文件修订时间: 2020-04-21 16:32:51

results matching ""

    No results matching ""