public static DownloadVideoContextMgr getInstance()
 {
     if (gDownVideoContextMgr == null)
     {
         gDownVideoContextMgr = new DownloadVideoContextMgr();
     }
     return(gDownVideoContextMgr);
 }
Ejemplo n.º 2
0
        //public static void cleanSendingStatus()
        //{
        //    List<ChatMsg> collection = StorageMgr.chatMsg.searhCacheMsg(0x2b, 0, 0);
        //    List<ChatMsg> list2 = StorageMgr.chatMsg.searhCacheMsg(0x3e, 0, 0);
        //    List<ChatMsg> list3 = new List<ChatMsg>();
        //    if ((collection != null) && (collection.Count > 0))
        //    {
        //        list3.AddRange(collection);
        //    }
        //    if ((list2 != null) && (list2.Count > 0))
        //    {
        //        list3.AddRange(list2);
        //    }
        //    if (list3.Count != 0)
        //    {
        //        foreach (ChatMsg msg in list3)
        //        {
        //            Log.i("DownloadVideoService", string.Concat(new object[] { "Failed to clean status-downing , ", msg.strClientMsgId, " nMsgType = ", msg.nMsgType }));
        //            msg.nStatus = 1;
        //        }
        //        StorageMgr.chatMsg.updateMsgList(collection);
        //    }
        //}

        public bool doCancelScene(int msgSvrId, bool isThumb = false)
        {
            DownloadVideoContext context = DownloadVideoContextMgr.getInstance().findBySrvMsgID(msgSvrId, isThumb);

            if (context == null)
            {
                return(false);
            }
            if ((context.mStatus == 5) || (context.mStatus == 4))
            {
                return(false);
            }
            context.mStatus = 4;
            context.doCancelAll();
            return(true);
        }
Ejemplo n.º 3
0
 public void onVideoDownContextDispatcher(object sender, EventArgs e)
 {
     DownloadVideoContextMgr.getInstance().clearnFinishedContext();
     if (DownloadVideoContextMgr.getInstance().getCount() <= 0)
     {
         Log.d("DownloadVideoService", "all ready, close dispatcher timer. ");
         mTimerObject.stop();
         mTimerObject = null;
     }
     else if (DownloadVideoContextMgr.getInstance().countRunningContext() < MAX_RUNNING)
     {
         DownloadVideoContext context = DownloadVideoContextMgr.getInstance().getFirstContextNeedHandle();
         if (context != null)
         {
             Log.i("DownloadVideoService", "new task startup, msgid = " + context.mVideoInfo.nMsgSvrID);
             context.startScene();
         }
     }
 }
Ejemplo n.º 4
0
        private bool doSceneEx(int msgSvrId, string talker, bool isThumb, ChatMsg msg)
        {
            MsgTrans trans;

            if (msgSvrId == 0)
            {
                Log.e("DownloadVideoService", "Not found the chatmsg , invalid msgid =  " + msgSvrId);
                return(false);
            }
            DownloadVideoContext context = DownloadVideoContextMgr.getInstance().findBySrvMsgID(msgSvrId, isThumb);

            if ((context != null) && !context.needToClean())
            {
                Log.e("DownloadVideoService", "already downloading video  by msgid =  " + msgSvrId);
                return(false);
            }
            // ChatMsg msg = StorageMgr.chatMsg.getBySvrID(talker, msgSvrId);
            if (msg == null)
            {
                Log.e("DownloadVideoService", "Not found the chatmsg by msgid =  " + msgSvrId);
                return(false);
            }

            Log.d("DownloadVideoService", "begin downLoad video thumb...msgid = " + msgSvrId);
            trans                 = new MsgTrans();
            trans.nTransType      = 6;
            trans.nMsgSvrID       = msgSvrId;
            trans.nMsgLocalID     = msg.nMsgLocalID;
            trans.strThumbnail    = msg.strThumbnail;
            trans.strFromUserName = talker;
            trans.strToUserName   = AccountMgr.getCurAccount().strUsrName;
            DownloadVideoContext contextInfo = new DownloadVideoContext {
                mVideoInfo   = trans,
                mChatMsg     = msg,
                mIsThumbMode = isThumb
            };

            if (!parseVideoMsgXML(msg.strMsg, trans, contextInfo))
            {
                Log.e("DownloadVideoService", "parseVideoMsgXML failed!  ");
                return(false);
            }

            if (Directory.Exists(System.IO.Directory.GetCurrentDirectory() + "\\ReplyRes\\Video\\") == false)//如果不存在就创建file文件夹
            {
                Directory.CreateDirectory(System.IO.Directory.GetCurrentDirectory() + "\\ReplyRes\\Video");
            }
            //using (FileStream sw = new FileStream(System.IO.Directory.GetCurrentDirectory() + "\\ReplyRes\\Video\\" + msgSvrId.ToString() + ".xml", FileMode.CreateNew))
            //{
            //    byte[] myByte = System.Text.Encoding.UTF8.GetBytes(msg.strMsg);
            //    sw.Write(myByte, 0, myByte.Length);
            //    sw.Close();
            //}

            new NetSceneUploadCdnVideo().doSceneToCGI(talker, trans, contextInfo, msg.nMsgType);
            return(true);

            contextInfo.updateProgressInfo(0);
            contextInfo.updateChatMsg();
            DownloadVideoContextMgr.getInstance().putToHead(contextInfo);
            this.checkReadyContextDispatcher();
            return(true);
        }