dongtou2016 2012-10-26 04:24
浏览 199

在通过ajax加载的页面/内容之后初始化video.js.

I'm currently in the process of setting up infinite scroll on one of my wordpress sites which loads the next set of posts via ajax once you've scrolled to the bottom of the page. Because of this, I have been unable to get videojs working properly (readas: at all); so am hoping someone can help me with this.

First and foremost, I'm using videojs code directly in my theme, which pulls data from a posts custom fields, and adds the post id to the video tags id attribute. Here's a sample of the template code:

<video id="video_<?php echo get_the_id(); ?>" class="video-js vjs-default-skin"  
  controls preload="auto" width="640" height="264"  
  poster="<?php echo $poster; ?>">  
 <source src="<?php echo $mp4vid; ?>" type='video/mp4' />  
</video>

(To note, I'll add ogg/webm later)

I've seen the docs page that says to add the following block:

_V_("example_video_1", {}, function(){
  // Player (this) is initialized and ready.
});

but no matter where I add it (with the necessary attributes added), the player does not work. I mean, with the above I get standard html5 video player, but has none of the benefits of videojs.

Anyone have a working solution for something like this?

  • 写回答

1条回答 默认 最新

  • drp935159 2012-11-07 20:51
    关注

    referencing the correct ID might do the trick...

    <script type="text/javascript">
    _V_("video_<?php echo get_the_id(); ?>", {}, function(){
      // Player (this) is initialized and ready.
    });
    </script>
    
    <video id="video_<?php echo get_the_id(); ?>" class="video-js vjs-default-skin"  
      controls preload="auto" width="640" height="264"  
      poster="<?php echo $poster; ?>">  
     <source src="<?php echo $mp4vid; ?>" type='video/mp4' />  
    </video>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类