技术开发 频道

自食其力!ASP.NET 4打造HTML5视频控件

  步骤4 继续为控件增加属性

  根据之前的介绍,我们开始为控件增加一些属性,要增加的属性如下:

  VideoUrl:指定视频播放的地址。

  PosterUrl: 这个是当没有视频时,显示的替代图片的地址。

  AutoPlay:指示视频是否自动装载播放。

  DisplayControlButtons: 指示是否显示或者隐藏播放的相关按钮。

  Loop: 指示视频是否自动播放。

  增加属性后的代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace CustomControls
{
    [ToolboxData(
"<{0}:VideoPlayer runat=server></{0}:VideoPlayer>")]
    
public class VideoPlayer : WebControl
    {
        
private string _Mp4Url;
        
public string Mp4Url
        {
            
get { return _Mp4Url; }
            
set { _Mp4Url = value; }
        }

        
private string _OggUrl = null;
        
public string OggUrl
        {
            
get { return _OggUrl; }
            
set { _OggUrl = value; }
        }

        
private string _Poster = null;
        
public string PosterUrl
        {
            
get { return _Poster; }
            
set { _Poster = value; }
        }

        
private bool _AutoPlay = false;
        
public bool AutoPlay
        {
            
get { return _AutoPlay; }
            
set { _AutoPlay = value; }
        }

        
private bool _Controls = true;
        
public bool DisplayControlButtons
        {
            
get { return _Controls; }
            
set { _Controls = value; }
        }

        
private bool _Loop = false;
        
public bool Loop
        {
            
get { return _Loop; }
            
set { _Loop = value; }
        }
    }
}
0
相关文章