relevantvideo.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. $('.m_video_img').on('click',function(){ //处理视频播放图标
  2. var _video = document.getElementById("myVideo");
  3. myVideo.play(); //点击图标视频播放
  4. $('#myVideo').attr('controls','controls'); //点击 显示默认的控件
  5. $(this).hide();
  6. var id = $(".m_video_img").attr('data-id');
  7. $.ajax({
  8. url:'/video/plays',
  9. dataType:"json",
  10. type:'GET',
  11. data:{id:id},
  12. success:function(data){
  13. }
  14. });
  15. })
  16. var videoOne = $('.m_videolist li').eq(0).attr('videoId');
  17. var videotext = $('.m_videolist li').eq(0).find('.m_videolist_text span').html();
  18. var videoOneimg = $('.m_videolist_img img').eq(0).attr('src');
  19. $('.m_video_l video').attr('src',videoOne);
  20. $('.m_video_l video').attr('poster',videoOneimg);
  21. $('.m_video_title').html(videotext);
  22. $('.m_videolist li').eq(0).addClass('on');
  23. $('.m_videolist li').each(function(i){
  24. $(this).on('click',function(){
  25. $('#myVideo').attr('controls','controls'); //点击 显示默认的控件
  26. $('.m_video_img').hide();
  27. var Idvideo = $(this).attr('videoId')
  28. var _videotext = $(this).find('.m_videolist_text span').html();
  29. $('.m_video_l video').attr('src',Idvideo);
  30. $('.m_video_title').html(_videotext);
  31. $('.site span').html(_videotext);
  32. $('.m_video_l video').attr('autoplay','autoplay');
  33. $(this).addClass('on').siblings().removeClass('on');
  34. var mid = $(this).attr('data-id');
  35. $.ajax({
  36. url:'/video/plays',
  37. dataType:"json",
  38. type:'GET',
  39. data:{id:mid},
  40. success:function(data){
  41. }
  42. });
  43. })
  44. })
  45. var _length = $('.m_Recommend ul li').length;
  46. if(_length > 6){
  47. jQuery(".m_Recommend").slide({titCell:".hd ul",mainCell:".bd ul",autoPage:true,effect:"left",autoPlay:true,vis:6,interTime:4000});
  48. $('.m_Recommend .prev').show();
  49. $('.m_Recommend .next').show();
  50. }else{
  51. $('.m_Recommend .prev').hide();
  52. $('.m_Recommend .next').hide();
  53. }
  54. // 获取 "video" 视频元素时长
  55. $(function(){
  56. function myFunction(cid){
  57. cid.each(function(){
  58. var _this=$(this)
  59. _this.find('video.video_list_main')[0].addEventListener("loadedmetadata", function(){
  60. var tol = this.duration;//获取总时长
  61. var time = parseInt(tol);
  62. var minutes = parseInt(time / 60);
  63. var seconds =( time - minutes * 60);
  64. _this.find('.time_b').html(Appendzero(minutes)+':'+Appendzero(seconds))
  65. })
  66. })
  67. }
  68. function Appendzero (obj) { //时间补零
  69. if (obj < 10) return "0" + obj; else return obj;
  70. }
  71. myFunction($('.m_videolist ul li'));
  72. myFunction($('.m_Recommend ul li'));
  73. });