php
  • jquery
  • jwplayer
  • 2016-05-31 152 views 0 likes 
    0

    我需要在使用jwplayer播放视频之前播放一些动态广告。如何在使用jwplayer进行视频播放之前播放广告

    我有下面的代码来播放视频和广告

    $res = '<?xml version="1.0" encoding="UTF-8"?>'; 
    $res .= '<VAST version="2.0">'; 
    $res .= '<Ad id="static">'; 
    $res .= '<InLine>'; 
    $res .= '<AdSystem>Static VAST Template</AdSystem>'; 
    $res .= '<AdTitle>Static VAST Tag</AdTitle>'; 
    $res .='<Impression>http://example.com/pixel.gif</Impression>'; 
    $res .= '<Creatives>'; 
    $res .= '<Creative>'; 
    $res .= '<Linear>'; 
    $res .= '<Duration>00:00:08</Duration>'; 
    $res .= '<TrackingEvents>'; 
           $res .='<Tracking event="start">http://example.com/pixel.gif</Tracking>'; 
           $res .='<Tracking event="firstQuartile">http://example.com/pixel.gif</Tracking>'; 
           $res .='<Tracking event="midpoint">http://example.com/pixel.gif</Tracking>'; 
           $res .='<Tracking event="thirdQuartile">http://example.com/pixel.gif</Tracking>'; 
           $res .='<Tracking event="complete">http://example.com/pixel.gif</Tracking>'; 
           $res .='<Tracking event="pause">http://example.com/pixel.gif</Tracking>'; 
           $res .='<Tracking event="mute">http://example.com/pixel.gif</Tracking>'; 
           $res .='<Tracking event="fullscreen">http://example.com/pixel.gif</Tracking>'; 
           $res .='</TrackingEvents>'; 
          $res .='<VideoClicks>'; 
           $res .='<ClickThrough>http://www.longtailvideo.com/</ClickThrough>'; 
           $res .='<ClickTracking>http://example.com/pixel.gif</ClickTracking>'; 
          $res .='</VideoClicks>'; 
          $res .='<MediaFiles>'; 
           $res .='<MediaFile type="video/mp4" bitrate="300" width="480" height="270">'; 
           $res .='http://example.com/uploads/myPReroll.mp4'; 
           $res .='</MediaFile>'; 
          $res .='</MediaFiles>'; 
          $res .='</Linear>'; 
         $res .='</Creative>'; 
         $res .='</Creatives>'; 
        $res .='</InLine>'; 
        $res .='</Ad>'; 
    $res .='</VAST>'; 
    
    jwplayer('primcast.com').setup({ 
        file: 'http://localhost.com/test/uploads/videos/test-video-107.mp4', 
        primary: 'flash', 
        advertising: { 
        client: 'vast', 
        tag: '<?php // echo $res ;?>' 
        }, 
        width: 480, 
        height: 270 
    }); 
    

    这里$资源变量包含我的广告视频文件的XML格式。 但它只播放视频,不播放广告。我怎样才能解决这个问题 。

    回答

    0

    你不需要JW Player的任何代码。假设你有我们的播放器的广告牌,所有你需要做的是包括在广告中的VAST广告代码网址:块的标记{}:“”参数:

    jwplayer('your_div_id').setup({ 
        file: 'your_video_URL', 
        advertising: { 
         client: 'vast', 
         tag: 'your_VAST_URL' 
        } 
    }); 
    

    您还可以包括你的广告代码直接在玩家的配置中使用您的JW Player帐户仪表板。

    详情请参阅http://support.jwplayer.com/customer/portal/articles/1431665-basic-preroll-video-ads

    +0

    我可以直接链接:https://s3.amazonaws.com/demo.jwplayer.com/static-tag/jwplayer-30s.mp4广告标记。 – soniya

    相关问题