コード例 #1
0
        public List <ProtoBattleVideoInfo> LoadVideoList(WarRecordIOInfo info)
        {
            bool hasDelete = false;
            List <ProtoBattleVideoInfo> list = LoadVideoList(info.ids);

            for (int i = 0; i < list.Count;)
            {
                ProtoBattleVideoInfo item = list[i];
                if (War.GetVersionCompatible(item.war_version))
                {
                    i++;
                }
                else
                {
                    list.Remove(item);
                    DeleteVideoFile(item.uid_local);
                    info.ids.Remove(item.uid_local);
                    hasDelete = true;
                }
            }

            if (hasDelete)
            {
                SaveInfo(info);
            }

            return(list);
        }
コード例 #2
0
        public void Load(ProtoBattleVideoInfo video, int watchRoleId)
        {
            string url = GetVideoUrl(video.uuid);

            Debug.Log("url=" + url);

            HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create(url);

            //设置接收对象的范围为0-10000000字节。

            hwr.AddRange(0, 10000000);

            MemoryStream ms = new MemoryStream();

            //流对象使用完后自动关闭
            using (Stream stream = hwr.GetResponse().GetResponseStream())
            {
                //建立字节组,并设置它的大小是多少字节
                byte[] bytes = new byte[102400];
                int    n     = 1;
                while (n > 0)
                {
                    //一次从流中读多少字节,并把值赋给N,当读完后,N为0,并退出循环
                    n = stream.Read(bytes, 0, 10240);
                    ms.Write(bytes, 0, n);                     //将指定字节的流信息写入文件流中
                }
            }


            video.video_data = new byte[ms.Length];
            ms.Position      = 0;
            ms.Read(video.video_data, 0, (int)ms.Length);

            War.Start(video, watchRoleId);
        }
コード例 #3
0
        public void Save(WarOverData overData)
        {
            if (War.recordManager == null)
            {
                return;
            }

            War.recordManager.timeLineData.overData  = overData;
            War.recordManager.timeLineData.enterData = War.enterData;
            byte[] videoData = War.recordManager.timeLineData.GetBytes();

            ProtoBattleVideoInfo video = new ProtoBattleVideoInfo();

            video.war_version = War.version;
            video.stageId     = War.enterData.stageId;
            video.video_data  = videoData;
            video.create_time = DateTimeUtils.CurrentTimestamp;
            GenerateProtoBattleVideoRoleInfoList(overData, video.fight_roles);

            Goo.save.record.SaveVideo(video, info);

            Debug.Log("War.endProto.video_type=" + War.endProto.video_type + " 视频类型: 0.普通视频   1.精选视频 ");

            // 视频类型: 0.普通视频   1.精选视频
            if (War.endProto != null && War.endProto.video_type == 1)
            {
                // 1.公会分享   2.精选上传   99.私人上传
                Upload(video, 2, -1);
            }
        }
コード例 #4
0
 public void Upload(ProtoBattleVideoInfo data, int uploadType, int roleId)
 {
     if (roleId == -1 && War.ownLegionData != null)
     {
         roleId = War.ownLegionData.roleId;
     }
     Goo.save.record.Upload(data, uploadType, roleId);
 }
コード例 #5
0
ファイル: War.cs プロジェクト: PenpenLi/abcabcabc.mg
        public static void Start(ProtoBattleVideoInfo video, int watchRoleId)
        {
            War.videoInfo = video;
            if (video.uid_local > 0)
            {
                War.record.SetWatchCount(video.uid_local, video.view_count++);
            }
            WRTimeLineData timeLineData = WRTimeLineData.Create(video.video_data);

            Start(timeLineData, watchRoleId);
        }
コード例 #6
0
ファイル: WarService.cs プロジェクト: PenpenLi/abcabcabc.mg
        /** 发送--上传视频 */
        public void C_UploadBattleVideo_0x550(ProtoBattleVideoInfo videoInfo, int upload_type, int roleId)
        {
            C_UploadBattleVideo_0x550 msg = new C_UploadBattleVideo_0x550();

            msg.upload_type = upload_type;              // 1.公会分享   2.精选上传   99.私人上传
            msg.share_video = new ProtoShareVideoInfo();
            msg.share_video.share_roleId = roleId != -1 ? roleId :    War.ownLegionData != null ? War.ownLegionData.roleId : 0;
            msg.share_video.video        = videoInfo;
            videoInfo.share_time         = DateTimeUtils.CurrentTimestamp;

            packetManager.SendMessage <C_UploadBattleVideo_0x550>(SocketId.Main, msg);
        }
コード例 #7
0
        private ProtoBattleVideoInfo CreateVideo(byte[] bytes)
        {
            MemoryStream memStream = new MemoryStream(bytes.Length);

            memStream.Position = 0;
            memStream.Write(bytes, 0, bytes.Length);
            memStream.Position = 0;

            ProtoBattleVideoInfo video = Serializer.Deserialize <ProtoBattleVideoInfo>(memStream);

            memStream.Dispose();
            return(video);
        }
コード例 #8
0
        // tool
        private byte[] GetVideoBytes(ProtoBattleVideoInfo video)
        {
            MemoryStream memStream = new MemoryStream(3096);

            memStream.Position = 0;
            Serializer.Serialize(memStream, video);

            byte[] bytes = new byte[(int)memStream.Length];
            memStream.Position = 0;
            memStream.Read(bytes, 0, (int)memStream.Length);
            memStream.Dispose();

            return(bytes);
        }
コード例 #9
0
        // load file
        public ProtoBattleVideoInfo LoadVideo(int id)
        {
            ProtoBattleVideoInfo item = null;
            string file = GetVideoPath(id);

            if (ES2.Exists(file))
            {
                byte[] bytes = ES2.LoadRaw(file);
                item = CreateVideo(bytes);

                item.view_count = LoadWatchCount(item.uid_local);
            }
            return(item);
        }
コード例 #10
0
        // load list
        public List <ProtoBattleVideoInfo> LoadVideoList(List <int> ids)
        {
            List <ProtoBattleVideoInfo> list = new List <ProtoBattleVideoInfo> ();

            foreach (int id in ids)
            {
                ProtoBattleVideoInfo item = LoadVideo(id);
                if (item != null)
                {
                    list.Add(item);
                }
            }

            return(list);
        }
コード例 #11
0
ファイル: War.cs プロジェクト: PenpenLi/abcabcabc.mg
        /** 播放录像 */

        public static void Start(LuaStringBuffer msgContent, int watchRoleId, bool isLua)
        {
            Debug.Log("播放录像 War.Start msgContent=" + msgContent + "  watchRoleId=" + watchRoleId);
            MemoryStream memStream = new MemoryStream(msgContent.buffer);

            memStream.Position = 0;
            S_GetEliteVideoList_0x551 videoList = Serializer.Deserialize <S_GetEliteVideoList_0x551>(memStream);

            memStream.Dispose();

            if (videoList != null && videoList.share_videos.Count > 0)
            {
                ProtoBattleVideoInfo video = videoList.share_videos [0].video;
                Goo.save.record.Load(video, watchRoleId);
            }
        }
コード例 #12
0
        public void Upload(ProtoBattleVideoInfo video, int uploadType, int roleId)
        {
            string url = Url_Video_Upload;

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method        = "POST";
                request.ContentType   = "application/octet-stream";
                request.ContentLength = video.video_data.Length;

                request.BeginGetRequestStream((IAsyncResult result) =>
                {
                    if (!result.IsCompleted)
                    {
                        Debug.LogError("上传视频文件失败");
                        return;
                    }

                    HttpWebRequest req     = (HttpWebRequest)result.AsyncState;
                    Stream myRequestStream = request.EndGetRequestStream(result);
                    myRequestStream.Write(video.video_data, 0, video.video_data.Length);
                }, request);

                using (WebResponse wr = request.GetResponse())
                {
                    //在这里对接收到的页面内容进行处理
                    Stream       stream       = wr.GetResponseStream();
                    StreamReader streamReader = new StreamReader(stream, Encoding.UTF8);
                    string       filename     = streamReader.ReadToEnd();
                    Debug.Log(filename);
                    video.uuid = filename;

                    byte[] t = video.video_data;
                    video.video_data = null;
                    War.service.C_UploadBattleVideo_0x550(video, uploadType, roleId);
                    video.video_data = t;
                }
            }
            catch (Exception)
            {
                Debug.LogError("上传视频文件异常");
            }
        }
コード例 #13
0
    public void SetData(ProtoBattleVideoInfo data)
    {
        this.data        = data;
        idText.text      = data.uid_local + "";
        countText.text   = data.view_count + "";
        versionText.text = "V." + data.war_version;

        string name = "";

        for (int i = 0; i < data.fight_roles.Count; i++)
        {
            ProtoBattleVideoRoleInfo role = data.fight_roles[i];
            name += role.role_info.name;
            if (i < data.fight_roles.Count - 1)
            {
                name += "   VS   ";
            }
        }
        nameText.text       = name;
        createTimeText.text = DateTimeUtils.DateStringFromNow(data.create_time);
    }
コード例 #14
0
        // save
        public void SaveVideo(ProtoBattleVideoInfo video, WarRecordIOInfo info)
        {
            video.uid_local = info.GetNewId();
            info.Add(video.uid_local);

            byte[] bytes = GetVideoBytes(video);
            string file  = GetVideoPath(video.uid_local);

            Debug.LogFormat("video.uid_local = {0}, bytes.Length={1}, file={2}", video.uid_local, bytes.Length, file);


            ES2.SaveRaw(bytes, file);
            SetWatchCount(video.uid_local, 0);

            while (info.Count > info.MaxNum)
            {
                int itemId = info.ids[0];
                DeleteVideoFile(itemId);
                info.ids.Remove(itemId);
            }


            SaveInfo(info);
        }
コード例 #15
0
        /// <summary>
        /// 上传视频
        /// </summary>
        /// <param name="id">视频ID.</param>
        /// <param name="uploadType">上传类型 : 1.公会分享   2.精选上传   99.私人上传.</param>
        /// <param name="roleId">上传玩家ID.</param>
        public void Upload(int id, int uploadType, int roleId)
        {
            ProtoBattleVideoInfo video = GetVideo(id);

            Upload(video, uploadType, roleId);
        }