MVC+WCF實現視頻播放的頂和踩功能

來源:互聯網
上載者:User

標籤:mvc   wcf   視頻網站   

    大家都知道做視頻網站必須要有頂和踩的功能,我們的校園視頻管理系統的頂和踩做到了和優酷頂和踩一樣的效

果,下面我們就介紹一下我做的頂和踩的功能實現。

    之前想的是點擊圖片按鈕,直接讓顯示和資料庫中的資料都+1就可以了,後來參照了優酷,決定實現圖片的“點

亮”效果,於是將原來的兩張帶顏色的按鈕另做的兩張灰色按鈕,實現了圖片點亮和資料及時更新的效果。



         --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


    下面我就做一下簡單的介紹一下實現。

    準備黑白和彩色相對應的四張圖片(可以用PS和美圖秀秀修圖)。

    View中的代碼:


<div class="ding" style="cursor:pointer;">            <img id="ding1" src="../../images/vedioPlayer/5-140FG92021-55_副本.jpg" onclick="getValueDing1()" />            <span id="dingspan">@video.VideoDingCount</span>        </div>        <div class="cai" style="cursor:pointer;">            <img id="cai1" src="../../images/vedioPlayer/5-140FG92022_副本.jpg" onclick="getValueDing2()" />            <span id="caispan">@video.VideoCaiCount</span>        </div>

    img標籤放圖片,span標籤顯示播放次數。

    Controller中方法1,調用WCF中的方法,返回視頻播放的的資訊:

//通過guid查詢vedio的基本資料用於頁面的顯示            Guid guid = new Guid(str);            List<VideoInfo> videoInfoList = new List<VideoInfo>();            videoInfoList = videoInfoService.GetPlayVideoInfo(guid);            ViewData["VideoInfo"] = videoInfoList;
     

    Controller中方法2,更新頂和踩的記錄,以頂為例:


#region 更新頂的記錄 UpdateDingCount() 張子傑 2015-2-12 09:03:34        public bool UpdateDingCount(VideoInfo videoinfo)        {            string videoid = Request["VideoID"];            string dingcount = Request["DingCount"];             //將捕獲的dingcount和vedioid放到實體中            VideoInfo envideoinfo = new VideoInfo();            Guid VideoID = new Guid(videoid);            int DingCount = Convert.ToInt32(dingcount);            envideoinfo.VideoID = VideoID;            envideoinfo.VideoDingCount = DingCount;             bool result = videoInfoService.UpdateDingCount(envideoinfo);             return result;        }        #endregion

 

    WCF中的實現方法:


 #region  更新頂的個數  bool UpdateDingCount(VideoInfo videoinfo) 張子傑 2015-2-12 07:57:02        public bool UpdateDingCount(VideoInfo videoinfo)        {            //建立映射規則               Mapper.CreateMap<VideoInfo, VideoInfoEntity>();            //建立實體集合            VideoInfoEntity videoinfotmp = new VideoInfoEntity();            //進行轉換              videoinfotmp = Mapper.Map<VideoInfoEntity>(videoinfotmp);              VideoInfoEntity VideoInfoEntity = videoinfoBLL.LoadEnities(u => u.VideoID == videoinfo.VideoID).ToList().First();            VideoInfoEntity.VideoDingCount = videoinfo.VideoDingCount;             bool result = videoinfoBLL.Update(VideoInfoEntity);             return result;        }        #endregion

之後,高端大氣的頂和踩功能就實現了。

MVC+WCF實現視頻播放的頂和踩功能

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.