栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

spring boot 调用青柿流媒体喊话接口

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

spring boot 调用青柿流媒体喊话接口

技术交流QQ群933925017
livegbs接口 https://gbs.liveqing.com:10010/apidoc/#api-control-ControlTalk
喊话流程是每次取4000个字符然后进行base64encoding–>urlencode

官方给的图片

是用的golang写的

2.java实现
    public Boolean liveGBSShout(String file, String serial, Integer channel) {
        byte[] bytes = getBytes(file);
        int length = bytes.length;
        int step = 4000;
        String base64Data = null;
        Boolean flag = true;
        for (int i = 0; i <= length; i = i + step) {
            if ((i + step) > length) {
                byte[] subBytes = subBytes(bytes, i, length - i);
                base64Data = base64.getEncoder().encodeToString(subBytes);
            } else {
                byte[] subBytes = subBytes(bytes, i, step);
                base64Data = base64.getEncoder().encodeToString(subBytes);
            }
            try {
                String encode = URLEncoder.encode(base64Data, "utf-8");
                String url = "https://channel2.cspid.cn/api/v1/control/talk?serial=" + serial + "&channel=" + channel + "&audio=" + encode;
                String get = HttpClientUtils.doGet(url);
            } catch (Exception e) {
                e.printStackTrace();
                flag = false;
            }
        }
        return flag;
    }
    // 拷贝byte数组
   public static byte[] subBytes(byte[] src, int begin, int length) {
        byte[] bytes = new byte[length];
        System.arraycopy(src, begin, bytes, 0, length);
        return bytes;
    }
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/696921.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号