小编fsu*_*ser的帖子

html5视频在设置currentTime后等待readystate == 4

我正在尝试拍摄一些未播放视频的图像.因此我使用HTML5.

因为我想要抓取尚未播放的图像,所以我设置了

video.currentTime = y;
Run Code Online (Sandbox Code Playgroud)

如果我现在调用grap函数它将无法工作.因为video.readyState是1(而不是4).如果我在抓取功能的开头添加alert();它可以工作.

我试图循环,直到readyState == 4

while(true){
   if(video.readyState == 4){
       grapImage();
   }
}
Run Code Online (Sandbox Code Playgroud)

但这最终会无休止地循环.

那么我怎么能等到readyState == 4

谢谢

javascript video html5 readystate html5-video

5
推荐指数
1
解决办法
9422
查看次数

chrome android设置宽度为100%

我在使用Chrome浏览器的android上遇到了问题

我在css做的是:

html{
max-width: 100%;
height: 100%;
width: 100%;
overflow: hidden;
position: relative;
}

body{
background-color: rgba(101,122,151,0.8);
margin: 0px;
width: 100%;
overflow: hidden;
position: relative;
}

header {
width: 100%;
min-width: 100%;
color: yellow;
font-size: 40px;
text-align: left;
}
Run Code Online (Sandbox Code Playgroud)

并在javascript我打印身体和标题的宽度

alert($('header').width());
alert($('body').width());
Run Code Online (Sandbox Code Playgroud)

它显示我的身体宽度是980,标题宽度是340但我不明白为什么.有人能帮我吗?谢谢

css android google-chrome width css3

4
推荐指数
1
解决办法
5992
查看次数

generic object creation with type as function parameter in c#

I'm trying to create a generic function to parse my json result with Newtonsoft:

private T ParseResult<T>(string queryResult)
{
    Result res = JsonConvert.DeserializeObject<Result>(queryResult);

    if (res.Success == 1)
    {
        try
        {
            return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(res.data));
        }
        catch (Exception)
        {
            return default(T);
        }
    }
    return default(T);
}
Run Code Online (Sandbox Code Playgroud)

If there is a problem with Success or the parsing I want to return an empty object of whatever T is (currently lists or just custom objects).

My problem is that the current solution is returning null …

c# generics json default xamarin

1
推荐指数
1
解决办法
71
查看次数

Django Celery 在抛出自定义异常时出现酸洗错误

我在 django 应用程序中使用 celery。如果发生故障,我会引发一个自定义异常,该异常是用此类定义的:

class CustomException(Exception):
    def __init__(self, err_input, err_info=''):
        self.err_key, self.err_msg, self.app_domain = err_input
        self.message = self.err_msg
        super(CustomException, self).__init__(self.message)
        self.err_info = err_info

    def __str__(self):
        return '[{}] {}'.format(str(self.err_key), str(self.err_msg))

    def __repr__(self):
        return self.message
Run Code Online (Sandbox Code Playgroud)

用于error_info内部日志记录目的。如果我抛出在相关 celery 任务中收到的消息:

{
  "task_id": "0dfd5ef3-0df1-11eb-b74a-0242ac110002",
  "status": "FAILURE",
  "result": {
    "exc_type": "MaybeEncodingError",
    "exc_message": [
      "'PicklingError(\"Can\\'t pickle &lt;class \\'module.CustomException\\'&gt;: it\\'s not the same object as module.CustomException\")'",
      "\"(1, &lt;ExceptionInfo: CustomException('Error message')&gt;, None)\""
    ],
    "exc_module": "billiard.pool"
  },
  "traceback": null,
  "children": []
}
Run Code Online (Sandbox Code Playgroud)

我在异常类中配置了什么错误?

python django pickle celery

1
推荐指数
1
解决办法
1359
查看次数