刚点击播放按钮的时候一直加载弹幕 然后播放了之后才可以发弹幕 是redis连接不上么?
来源:11-5 .代码优化及bug处理

Lee1
2017-08-27
写回答
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')
00 -
rustgopy
2017-08-27
同学,你好,是播放器的一个js效果,刚开始加载的时候会显示正在加载
042017-08-28
相似问题