有没有一种方法可以通过setInterval()函数返回布尔值?

时间:2019-04-24 17:56:24

标签: javascript jquery video.js google-ima

我正在研究视频播放器项目,并且正在使用videojs和videojs-ima进行广告前贴片。

我终于找到了一种方法来判断是否存在广告;但是,我试图返回布尔值[Wed Apr 24 10:55:50.407745 2019] [mpm_worker:notice] [pid 15709:tid 140385667327872] AH00292: Apache/2.4.37 (Unix) mod_wsgi/4.6.5 Python/3.7 configured -- resuming normal operations [Wed Apr 24 10:55:50.407853 2019] [core:notice] [pid 15709:tid 140385667327872] AH00094: Command line: '/home/marknguyen94/webapps/adm_220_2/apache2/bin/httpd.worker -f /home/marknguyen94/webapps/adm_220_2/apache2/conf/httpd.conf' [Wed Apr 24 10:56:00.948624 2019] [wsgi:error] [pid 31535:tid 140385586988800] BASE_DIR: /home/marknguyen94/webapps/adm_220_2/app_www_admission/app_www_admission [Wed Apr 24 10:56:00.948979 2019] [wsgi:error] [pid 31535:tid 140385586988800] STATICFILES_DIRS: ('/home/marknguyen94/webapps/adm_220_2/app_www_admission/app_www_admission/static',) [Wed Apr 24 10:56:00.949025 2019] [wsgi:error] [pid 31535:tid 140385586988800] TEMPLATES_DIRS: ('/home/marknguyen94/webapps/adm_220_2/app_www_admission/app_www_admission/templates',) [Wed Apr 24 10:56:01.273233 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] Internal Server Error: / [Wed Apr 24 10:56:01.273311 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] Traceback (most recent call last): [Wed Apr 24 10:56:01.273337 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] File "/home/marknguyen94/webapps/adm_220_2/lib/python3.7/Django-2.1.7-py3.7.egg/django/core/handlers/exception.py", line 34, in inner [Wed Apr 24 10:56:01.273361 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] response = get_response(request) [Wed Apr 24 10:56:01.273384 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] File "/home/marknguyen94/webapps/adm_220_2/lib/python3.7/Django-2.1.7-py3.7.egg/django/core/handlers/base.py", line 111, in _get_response [Wed Apr 24 10:56:01.273408 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] resolver_match = resolver.resolve(request.path_info) [Wed Apr 24 10:56:01.273429 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] File "/home/marknguyen94/webapps/adm_220_2/lib/python3.7/Django-2.1.7-py3.7.egg/django/urls/resolvers.py", line 491, in resolve [Wed Apr 24 10:56:01.273452 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] for pattern in self.url_patterns: [Wed Apr 24 10:56:01.273473 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] File "/home/marknguyen94/webapps/adm_220_2/lib/python3.7/Django-2.1.7-py3.7.egg/django/utils/functional.py", line 37, in __get__ [Wed Apr 24 10:56:01.273496 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] res = instance.__dict__[self.name] = self.func(instance) [Wed Apr 24 10:56:01.273518 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] File "/home/marknguyen94/webapps/adm_220_2/lib/python3.7/Django-2.1.7-py3.7.egg/django/urls/resolvers.py", line 533, in url_patterns [Wed Apr 24 10:56:01.273541 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) [Wed Apr 24 10:56:01.273564 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] File "/home/marknguyen94/webapps/adm_220_2/lib/python3.7/Django-2.1.7-py3.7.egg/django/utils/functional.py", line 37, in __get__ [Wed Apr 24 10:56:01.273648 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] res = instance.__dict__[self.name] = self.func(instance) [Wed Apr 24 10:56:01.273676 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] File "/home/marknguyen94/webapps/adm_220_2/lib/python3.7/Django-2.1.7-py3.7.egg/django/urls/resolvers.py", line 526, in urlconf_module [Wed Apr 24 10:56:01.273700 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] return import_module(self.urlconf_name) [Wed Apr 24 10:56:01.273721 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module [Wed Apr 24 10:56:01.273766 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] return _bootstrap._gcd_import(name[level:], package, level) [Wed Apr 24 10:56:01.273791 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] File "<frozen importlib._bootstrap>", line 1006, in _gcd_import [Wed Apr 24 10:56:01.273814 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] File "<frozen importlib._bootstrap>", line 983, in _find_and_load [Wed Apr 24 10:56:01.273837 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked [Wed Apr 24 10:56:01.273860 2019] [wsgi:error] [pid 31535:tid 140385586988800] [remote 127.0.0.1:57672] ModuleNotFoundError: No module named 'app_www_admission.urls' true,以告知何时运行和执行某个代码块。

这是我的代码,目前无法正常运行。

false

如果有人可以帮助我理解并可以向我解释为什么这样不起作用,我会喜欢的。我该如何解决这个问题?

我知道我已经接近了。预先感谢!

1 个答案:

答案 0 :(得分:1)

这是一个经典的XY问题。

试图解决与总体情况无关的问题。

这是有效的代码,以及我如何进行不同的处理。

if (navigator.userAgent.match(/iPhone/i) ||
    navigator.userAgent.match(/iPad/i) ||
    navigator.userAgent.match(/Android/i)) {

    let checkAd = $('.ima-ad-container');

    player.on('touchend', () => {
        if (checkAd.css('display') != 'none') {
            console.log('Ad is playing.');
            // do nothing
        } else if (checkAd.css('display') == 'none') {
            console.log('Ad is NOT playing.');

            if (player.paused()) {
                player.play();
            } else {
                player.pause();
            }
        }
    });
    $('.vjs-icon-placeholder').on('touchend', () => {
        if (checkAd.css('display') != 'none') {
            console.log('Ad is playing.');
            // do nothing

        } else if (checkAd.css('display') == 'none') {
            console.log('Ad is NOT playing.');

            if (player.paused()) {
                player.play();
            } else {
                player.pause();
            }
        }
    });
}