예제 #1
0
        void BackgroundProcessing()
        {
            Xamarin.Forms.Device.StartTimer(TimeSpan.FromSeconds(1), () =>
            {
                try
                {
                    Task.Factory.StartNew(async() => {
                        var meta = await RefreshDataAsync();
                        if (_metadata == null ||
                            _metadata.current_track.title != meta.current_track.title ||
                            _metadata.source.type != meta.source.type)
                        {
                            _metadata = meta;
                            await UpdateHistory();

                            _metadataLoaded = true;
                            SetMetaData();
                        }
                        SetPlayback();
                    });
                    return(true);
                }
                catch (Exception)
                {
                    // we still want to continue processing backgroud task even when there is an error
                    return(true);
                }
            });
        }
예제 #2
0
 public Login(IUnityContainer container)
 {
     InitializeComponent();
     _autoLoginService = container.Resolve <AutoLoginService>();
     _liveInfo         = container.Resolve <LiveInfo>();
     _container        = container;
 }
예제 #3
0
        private List <LiveInfo> getLiveItems()
        {
            var loadTime = DateTime.Now;
            var tab      = getTabName();
            var url      = "https://live.nicovideo.jp/recent/rss?tab=" + tab + "&p=";

            util.debugWriteLine(url);
            var readNum = int.Parse(form.config.get("thresholdpage")) + 1;
            var buf     = new List <LiveInfo>();

            for (var i = 1; i < readNum; i++)
            {
                util.debugWriteLine("rss page i " + i);
                try
                {
                    var      xdocu     = XDocument.Load(url + i.ToString());
                    XElement item      = (XElement)xdocu.Root.FirstNode;
                    var      itemCount = 0;
                    foreach (XElement it in item.Nodes())
                    {
                        if (it.Name != "item")
                        {
                            continue;
                        }
                        var rssItem = new List <KeyValuePair <string, string> >();
                        foreach (XElement _it in it.Nodes())
                        {
                            //Debug.WriteLine(_it.Name.LocalName + " " + _it.Value);
                            if (_it.Name.LocalName == "thumbnail")
                            {
                                rssItem.Add(new KeyValuePair <string, string>(_it.Name.LocalName, _it.Attribute(XName.Get("url")).Value));
                            }
                            else
                            {
                                rssItem.Add(new KeyValuePair <string, string>(_it.Name.LocalName, _it.Value));
                            }
                        }

                        var li = new LiveInfo(rssItem, form.alartListDataSource, form.config, form.userAlartListDataSource);
                        buf.Add(li);
                        itemCount++;
                        //Debug.WriteLine("");
                    }

                    if (itemCount == 0)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    util.debugWriteLine("getliveitems xml " + e.Message + e.Source + e.StackTrace + e.TargetSite);
                    Thread.Sleep(180000);
                }
            }
            util.debugWriteLine("load rss item " + buf.Count);
            return(buf);
        }
 public override void Load(object @object)
 {
     if (@object is LiveInfo)
     {
         LiveInfo liveInfo = @object as LiveInfo;
         liveManager.LiveInfo.Lives = liveInfo.Lives;
         liveManager.UpdateLifeDisplay();
     }
 }
예제 #5
0
        public CommunityLiveInfoViewModel(LiveInfo info)
        {
            LiveInfo = info;

            LiveId       = LiveInfo.LiveId;
            LiveTitle    = LiveInfo.LiveId;
            StartTime    = LiveInfo.StartTime;
            StreamerName = LiveInfo.StreamerName;
        }
예제 #6
0
 public ShellViewModel(string title, LiveInfo liveInfo, SystemConfig config, IServiceClient serviceClient, WebPlatformApiFactory webPlatformApiFactory)
 {
     WindowTitle            = title;
     _liveInfo              = liveInfo;
     _config                = config;
     _serviceClient         = serviceClient;
     _webPlatformApiFactory = webPlatformApiFactory;
     _timer = new Timer((state) => TimerHandler(), null, (int)(liveInfo.StopTime.AddMinutes(-5) - DateTime.Now).TotalMilliseconds, Timeout.Infinite);
 }
예제 #7
0
        public CommunityLiveInfoViewModel(LiveInfo info, PageManager pageManager)
        {
            LiveInfo    = info;
            PageManager = pageManager;

            LiveId       = LiveInfo.LiveId;
            LiveTitle    = LiveInfo.LiveId;
            StartTime    = LiveInfo.StartTime;
            StreamerName = LiveInfo.StreamerName;
        }
예제 #8
0
        async Task <LiveInfo> RefreshDataAsync()
        {
            _client = new HttpClient();
            var uri      = new Uri(INFO_URL + "status");
            var response = await _client.GetStringAsync(uri);

            LiveInfo info = new LiveInfo();

            info = JsonConvert.DeserializeObject <LiveInfo>(response);

            return(info);
        }
예제 #9
0
        /// <summary>
        /// 收到MQTT的JSON信息的回调函数,将消息解析后加入MQTT消息队列
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnReciveMessage(Object sender, MqttMsgPublishEventArgs e)
        {
            String json = Encoding.ASCII.GetString(e.Message);

            LiveInfo info = JsonConvert.DeserializeObject <LiveInfo>(json);
            String   In   = info.name + "开播辣\n" + info.title + "\n" + "地址:" + info.url;

            if (!ListenList.Contains(In))
            {
                ListenList.Add(In);
            }
        }
예제 #10
0
 public WelcomeViewModel(LiveInfo liveInfo)
 {
     if (liveInfo.TeacherList != null)
     {
         liveInfo.TeacherList
         .Where(item => item.IsMajor)
         .ToList()
         .ForEach(item =>
         {
             if (!string.IsNullOrEmpty(_teachersNames))
             {
                 _teachersNames += ",";
             }
             _teachersNames += $"{item.TeacherName}老师";
         });
         TeachersNames = _teachersNames;
         Title         = liveInfo.Title;
     }
 }
예제 #11
0
        public RecordingControlViewModel(
            SystemConfig config,
            IEventAggregator eventAggregator,
            IUnityContainer container,
            EventSubscriptionManager eventSubscriptionManager)
            : this()
        {
            _config                            = config;
            _eventAggregator                   = eventAggregator;
            _eventSubscriptionManager          = eventSubscriptionManager;
            _liveInfo                          = container.Resolve <LiveInfo>();
            _speechVideoLiveAndRecordProvider  = container.Resolve <SpeechVideoLiveAndRecordProvider>();
            _teacherVideoLiveAndRecordProvider = container.Resolve <TeacherVideoLiveAndRecordProvider>();

            StartRecordingBtnIsEnable = true;
            StartRecordingCommand     = new DelegateCommand(new Action(StartRecording));
            StopRecordingCommand      = new DelegateCommand(new Action(StopRecording));
            PauseRecordingCommand     = new DelegateCommand(new Action(PauseRecording));

            _eventSubscriptionManager.Subscribe <LiveAndRecordingOperateEvent, LiveAndRecordingOperateEventContext>(null, LiveOperateEventHandler, EventFilter);
            _eventSubscriptionManager.Subscribe <ShutDownEvent, bool>(null, SystemShutDownEventHandler, null);
        }
예제 #12
0
        private void OperationImageTap(VideoViewModel template)
        {
#if DEBUG
            long memory      = DeviceStatus.ApplicationCurrentMemoryUsage / (1024 * 1024);
            long memoryLimit = DeviceStatus.ApplicationMemoryUsageLimit / (1024 * 1024);
            long memoryMax   = DeviceStatus.ApplicationPeakMemoryUsage / (1024 * 1024);
            System.Diagnostics.Debug.WriteLine("当前内存使用情况:" + memory.ToString() + " MB 当前最大内存使用情况: " + memoryMax.ToString() + "MB  当前可分配最大内存: " + memoryLimit.ToString() + "  MB");
#endif

            switch (template.jumpType)
            {
            case "videoPlayer":
                if (template.type != "title")
                {
                    App.PlayerModel.VideoId     = template.videoId;
                    App.PlayerModel.currentType = ViewModels.PlayerViewModel.PlayType.VideoType;
                    CallbackManager.currentPage.NavigationService.Navigate(new Uri(CommonData.PlayerPageName, UriKind.Relative));
                }
                break;

            case "subjectPage":
                MoreSubject.subjectId     = template.subjectId;
                MoreSubject.speicalName   = template.name;
                MoreSubject.isMoreChannel = false;
                CallbackManager.currentPage.NavigationService.Navigate(new Uri(CommonData.SpecialPageName, UriKind.Relative));
                break;

            case "videoLibrary":
                if (channel != null)
                {
                    MoreChannelInfo.typeId = channel.libId;
                    MoreChannelInfo.name   = channel.channelName;
                    CallbackManager.currentPage.NavigationService.Navigate(new Uri(CommonData.MoreChannelPageName, UriKind.Relative));
                }
                break;

            case "webView":
                WebBrowserTask task = new WebBrowserTask();
                task.Uri = new Uri(template.webUrl, UriKind.Absolute);
                try
                {
                    task.Show();
                }
                catch (Exception e)
                {
                }
                break;

            case "livePlayer":
                LivePlayer.liveUrl = template.playUrl;
                CallbackManager.currentPage.NavigationService.Navigate(new Uri(CommonData.LivePlayerPage, UriKind.Relative));
                break;

            case "concertLivePlayer":
                LivePlayer.liveUrl = "http://live.api.hunantv.com/mobile/getLiveStreaming?videoId=" + template.videoId;
                HttpHelper.httpGet(LivePlayer.liveUrl, (ar) =>
                {
                    string result = HttpHelper.SyncResultTostring(ar);
                    if (result != null)
                    {
                        LiveInfo videosResult = null;
                        try
                        {
                            videosResult = JsonConvert.DeserializeObject <LiveInfo>(result);
                        }
                        catch (Exception ex)
                        {
                            System.Diagnostics.Debug.WriteLine("LoadChannelCompleted   json 解析错误" + ex.Message);
                            App.JsonError(result);
                        }
                        if (videosResult != null && videosResult.m3u8 != null)
                        {
                            LivePlayer.liveUrl = videosResult.m3u8;
                            if (!string.IsNullOrEmpty(LivePlayer.liveUrl))
                            {
                                CallbackManager.currentPage.Dispatcher.BeginInvoke(() =>
                                {
                                    CallbackManager.currentPage.NavigationService.Navigate(new Uri(CommonData.LivePlayerPage, UriKind.Relative));
                                });
                            }
                        }
                    }
                });

                //App.ShowToast("抱歉,暂时不支持直播功能");
                break;

            default:
                System.Diagnostics.Debug.WriteLine("该播放类型暂时未实现" + template.jumpType);
                App.ShowToast("该播放类型暂时未实现" + template.jumpType);
                break;
            }
        }
예제 #13
0
 public StorageProvider(LiveInfo liveInfo, IServiceClient serviceClient, WebPlatformApiFactory webPlatformApiFactory)
 {
     _liveInfo = liveInfo;
     _serviceClient = serviceClient;
     _webPlatformApiFactory = webPlatformApiFactory;
 }
예제 #14
0
        private List <LiveInfo> getOfficialLiveItems()
        {
            try {
                var r = util.getPageSource("https://live.nicovideo.jp/focus");
                if (r == null)
                {
                    foreach (var li in form.liveListDataSource)
                    {
                        if (li.type == "official")
                        {
                            li.lastExistTime = DateTime.Now;
                        }
                    }
                    foreach (var li in form.liveListDataReserve)
                    {
                        if (li.type == "official")
                        {
                            li.lastExistTime = DateTime.Now;
                        }
                    }
                    return(new List <LiveInfo>());
                }
                var m   = new Regex("id&quot;:&quot;(lv\\d+)").Matches(r);
                var ret = new List <LiveInfo>();
                foreach (Match _m in m)
                {
                    var lvid    = _m.Groups[1].Value;
                    var isAdded = false;
                    foreach (var li in form.liveListDataSource)
                    {
                        if (li.type != "official" && li.lvId == lvid)
                        {
                            li.lastExistTime = DateTime.Now;
                            isAdded          = true;
                        }
                    }
                    foreach (var li in form.liveListDataReserve)
                    {
                        if (li.type == "official" && li.lvId == lvid)
                        {
                            li.lastExistTime = DateTime.Now;
                            isAdded          = true;
                        }
                    }
                    if (isAdded)
                    {
                        continue;
                    }

                    var hig = new HosoInfoGetter();
                    var _r  = hig.get(lvid, null);
                    if (!_r)
                    {
                        continue;
                    }
                    if (hig.type != "official" || hig.openDt > DateTime.Now || hig.isClosed)
                    {
                        continue;
                    }

                    var ri = new RssItem(hig.title, lvid, hig.openDt.ToString(), hig.description, hig.group, hig.communityId, hig.userName, hig.thumbnail, hig.isMemberOnly.ToString(), "", hig.isPayment);
                    ri.type = "official";
                    ri.setUserId(hig.userId);
                    ri.tags      = new string[] { "" };
                    ri.pubDateDt = DateTime.Parse(ri.pubDate);
                    var _li = new LiveInfo(ri, form.alartListDataSource.ToArray(), form.config, form.userAlartListDataSource.ToArray());
                    ret.Add(_li);
                }
                return(ret);
            } catch (Exception e) {
                util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
                return(new List <LiveInfo>());
            }
        }
예제 #15
0
        private MatchEntity DealMatchInfo(JToken jtoken, NormalParam normalParam)
        {
            try
            {
                //解析比赛信息
                var pmi = new ParseMatchInfo();
                pmi.CompareSet(jtoken);
                int         sportId = 0;
                MatchEntity me;
                if (pmi.SportType != null)
                {
                    sportId = IbcTools.ConvertToSportId(pmi.SportType);
                    if (sportId == 0)
                    {
                        return(null);
                    }

                    var matchDate = GetTime(pmi.KickOffTime);
                    matchDate = matchDate.AddSeconds(-matchDate.Second);
                    var diffMinutes = matchDate.Minute % 5;
                    matchDate = matchDate.AddMinutes(5 - diffMinutes);
                    var home = string.IsNullOrEmpty(pmi.HomeTeamNameExtension) ? pmi.HomeTeamName : pmi.HomeTeamName + "[" + pmi.HomeTeamNameExtension + "]";
                    var away = string.IsNullOrEmpty(pmi.AwayTeamNameExtension) ? pmi.AwayTeamName : pmi.AwayTeamName + "[" + pmi.AwayTeamNameExtension + "]";
                    if (sportId == 1 && pmi.Isneutral == "1")
                    {
                        home = home + " (N)";
                    }

                    me = matchEntityManager.GetOrAdd(pmi.MatchId, pmi.LeagueName, home, away, matchDate, sportId);

                    me.CompareToStage(normalParam.Stage);
                }
                else
                {
                    me = matchEntityManager.Get(pmi.MatchId);
                }

                if (me == null)
                {
                    logger.Error("DealMatchInfo Cannot find srcMatchId = " + pmi.MatchId);
                    return(null);
                }

                //  if stage = 3
                if (normalParam.Stage == 3 && !me.IsSelfCreate && (me.SportID == 1 || me.SportID == 2))
                {
                    var lti = new LiveInfo();
                    lti.SportId                 = me.SportID;
                    lti.SrcMatchId              = pmi.MatchId;
                    lti.HomeScore               = string.IsNullOrEmpty(pmi.LiveHomeScore) ? (int?)null : Convert.ToInt32(pmi.LiveHomeScore);
                    lti.AwayScore               = string.IsNullOrEmpty(pmi.LiveAwayScore) ? (int?)null : Convert.ToInt32(pmi.LiveAwayScore);
                    lti.HomeRed                 = string.IsNullOrEmpty(pmi.HomeRed) ? (int?)null : Convert.ToInt32(pmi.HomeRed);
                    lti.AwayRed                 = string.IsNullOrEmpty(pmi.AwayRed) ? (int?)null : Convert.ToInt32(pmi.AwayRed);
                    lti.Csstatus                = pmi.Csstatus;
                    lti.Liveperiod              = pmi.Liveperiod;
                    lti.PhaseStartUtc           = pmi.Livetimer;
                    lti.PhaseStartUtcUpdateTime = string.IsNullOrEmpty(pmi.Livetimer) ? (DateTime?)null : DateTime.Now;

                    var ret = LiveInfoManager.Instance.AddOrUpdate(lti);

                    if (me.SportID == 1)
                    {
                        me.CompareToScore(ret.HomeScore.Value, ret.AwayScore.Value);
                        me.CompareToCard(ret.HomeRed.Value, ret.AwayRed.Value);
                    }
                    else if (me.SportID == 2)
                    {
                        if (!string.IsNullOrEmpty(pmi.LiveScore))
                        {
                            var bkScore   = JsonConvert.DeserializeObject <BasketballScore>(pmi.LiveScore);
                            var homeScore = Convert.ToInt32(bkScore.h1q) + Convert.ToInt32(bkScore.h2q) +
                                            Convert.ToInt32(bkScore.h3q) + Convert.ToInt32(bkScore.h4q);
                            var awayScore = Convert.ToInt32(bkScore.a1q) + Convert.ToInt32(bkScore.a2q) +
                                            Convert.ToInt32(bkScore.a3q) + Convert.ToInt32(bkScore.a4q);
                            me.CompareToScore(homeScore, awayScore);
                        }
                    }
                    me.CompareToTime(ret.Phase.Value, ret.LiveTime(LiveInfoManager.Instance.IbcDiffSyncTime));
                }

                JsonSerializerSettings jsetting = new JsonSerializerSettings();
                jsetting.NullValueHandling = NullValueHandling.Ignore;
                var str = JsonConvert.SerializeObject(pmi, jsetting);

                Console.WriteLine("match = " + str);
                return(me);
            }
            catch (Exception e)
            {
                logger.Error(e.ToString());
                return(null);
            }
        }
예제 #16
0
 public DocumentService(IServiceClient serviceClient, LiveInfo liveInfo, WebPlatformApiFactory webPlatformApiFactory)
 {
     _serviceClient         = serviceClient;
     _liveInfo              = liveInfo;
     _webPlatformApiFactory = webPlatformApiFactory;
 }
예제 #17
0
        private List <LiveInfo> getCategoryLiveItems()
        {
            var loadTime      = DateTime.Now;
            var tab           = getTabName();
            var categoryNames = new string[] { "common", "try", "live", "req" };

            var readNum = int.Parse(form.config.get("thresholdpage"));
            var buf     = new List <LiveInfo>();

            foreach (var name in categoryNames)
            {
                if (name != tab && tab != "")
                {
                    continue;
                }
                var url = "https://live.nicovideo.jp/front/api/pages/recent/v1/programs?tab=" + name + "&offset=#&sortOrder=recentDesc";
                util.debugWriteLine(url);

                for (var i = 0; i < readNum; i++)
                {
                    util.debugWriteLine("livecheck category page i " + i + " " + name);
                    try
                    {
                        var res = util.getPageSource(url.Replace("#", i.ToString()), null);
                        if (res == null)
                        {
                            Thread.Sleep(10000);
                            continue;
                        }
                        var categoryObj = (CategoryRecent)Newtonsoft.Json.JsonConvert.DeserializeObject <CategoryRecent>(res);
                        if (categoryObj.meta.errorCode != "OK")
                        {
                            continue;
                        }

                        var itemCount = 0;
                        foreach (var d in categoryObj.data)
                        {
                            try
                            {
                                var item = d.getRssItem(name);
                                if (item == null)
                                {
                                    continue;
                                }
                                if (buf.Find(x => x.lvId == item.lvId) != null)
                                {
                                    continue;
                                }

                                var li = new LiveInfo(item, form.alartListDataSource, form.config, form.userAlartListDataSource);
                                buf.Add(li);
                                itemCount++;
                            }
                            catch (Exception e)
                            {
                                util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
                            }
                        }
                        if (itemCount == 0)
                        {
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        util.debugWriteLine("getliveitems xml " + e.Message + e.Source + e.StackTrace + e.TargetSite);
                        Thread.Sleep(180000);
                    }
                }
            }
            util.debugWriteLine("load category item " + buf.Count);
            return(buf);
        }