0

我正在尝试插入一个由视频主机提供的 cookie,它将在用户停止的地方恢复视频。他们有一个明显有效的例子。当试图将它插入我的 Drupal 站点时,cookie 不起作用。视频只是从头开始。

我已经启用了“PHP 输入过滤器”,因为我读到我需要这样做以便 drupal 插入脚本。请参阅下面我的节点中的代码。

谁能帮我弄清楚为什么这不起作用,如何让它起作用,或者用 Drupal 做这件事的更好方法?

谢谢,

<script type="text/javascript">

wistiaEmbed.ready( function() {
  var all_cookies = document.cookie.split(';'), // gets the value of the cookies on the     page
    cookie_str = "resume_video=",
    resume_cookie = does_resume_cookie_exist(all_cookies);


  function does_resume_cookie_exist(cookie_arr) {
    var i, curr_string, found;
      for (i = 0; i < cookie_arr.length; i++) {
      curr_string = cookie_arr[i];
        if (curr_string.substring(0,5) === cookie_str.substring(0,5)) {
          // we've found it!
          found = curr_string;
          break;
        }
      }
    return found;
  }

  function set_cookie_time(t) {  
    document.cookie = cookie_str + t.toString(); // this takes the time (t) and sets the cookie with that time  
  }

  if (resume_cookie) {
    num = resume_cookie.split('=')[1];
    start_time = parseInt(num);
    wistiaEmbed.time(start_time).play(); // plays the video at the specific time defined in the cookie upon return to the page
  } else {
   set_cookie_time(0);  // places a cookie on the visitor
    wistiaEmbed.play();  // starts the video from the beginning
  }
  wistiaEmbed.bind("timechange", function(t) { // on timechange, reset cookie
    set_cookie_time(t);
  });
  wistiaEmbed.bind("end", function() { // if person has watched the entire video, sets the video to beginning upon retun
    set_cookie_time(0);
  });
});
</script>

<div id="wistia_npcc5k96s9" class="wistia_embed"         style="width:640px;height:508px;"> </div>
 <script charset="ISO-8859-1" src="http://fast.wistia.com/assets/external/E-v1.js">  </script>
     <script>
wistiaEmbed = Wistia.embed("npcc5k96s9");
</script>**strong text**
4

1 回答 1

0

你用的是什么版本的drupal?您提供的代码是否在您的请求响应中实际输出?

有几种解决方案(IMO)。

希望有帮助。

于 2013-11-01T18:58:37.530 回答