刚点击播放按钮的时候一直加载弹幕 然后播放了之后才可以发弹幕 是redis连接不上么?

来源:11-5 .代码优化及bug处理

Lee1

2017-08-27

http://szimg.mukewang.com/59a2caef0001323d12620035.jpg

http://szimg.mukewang.com/59a2caef0001077913280129.jpg

http://szimg.mukewang.com/59a2caef00012a9f05580187.jpg


写回答

2回答

rustgopy

2017-08-28

弹幕代码:

@home.route("/tm/", methods=["GET", "POST"])
def tm():
    import json
    if request.method == "GET":
        #获取弹幕消息队列
        id = request.args.get('id')
        key = "movie" + str(id)
        if rd.llen(key):
            msgs = rd.lrange(key, 0, 2999)
            res = {
                "code": 1,
                "danmaku": [json.loads(v) for v in msgs]
            }
        else:
            res = {
                "code": 1,
                "danmaku": []
            }
        resp = json.dumps(res)
    if request.method == "POST":
        #添加弹幕
        data = json.loads(request.get_data())
        msg = {
            "__v": 0,
            "author": data["author"],
            "time": data["time"],
            "text": data["text"],
            "color": data["color"],
            "type": data['type'],
            "ip": request.remote_addr,
            "_id": datetime.datetime.now().strftime("%Y%m%d%H%M%S") + uuid.uuid4().hex,
            "player": [
                data["player"]
            ]
        }
        res = {
            "code": 1,
            "data": msg
        }
        resp = json.dumps(res)
        rd.lpush("movie" + str(data["player"]), json.dumps(msg))
    return Response(resp, mimetype='application/json')


0
0

rustgopy

2017-08-27

同学,你好,是播放器的一个js效果,刚开始加载的时候会显示正在加载

0
4
rustgopy
回复
Lee1
对的,同学,你需要修改配置文件,具体你看下视频里面关于配置redis配置文件的内容
2017-08-28
共4条回复

Python Flask 构建微电影视频网站

Python 最好用轻量级框架,让你轻松胜任 Python Web 工程师

683 学习 · 663 问题

查看课程