@@ -23,13 +23,13 @@ require "os_util"
2323require " os_constant"
2424local repeatAdTable = {} -- 广告轮询集合
2525local showAdTable = {} -- 正在展示的table
26+ local checkAdTable = {} -- 广告是否可以展示
2627local lastProgress = 0
2728local bubbleIdList = {}
2829local targetObjId = nil
2930local roomId = Native :nativeVideoID ()
30- local deviceType = 2
31- local buId = " videoos"
32- local adShowInterval = 2000
31+ local adShowInterval = 1000
32+ local adCheckInterval = 5000
3333local preloadCount = 1
3434mainNode = object :new ()
3535
@@ -104,6 +104,55 @@ local function closeAdView(adId, data)
104104 end
105105end
106106
107+ local function checkHotspotShow (data )
108+
109+ if (data == nil ) then
110+ return nil
111+ end
112+
113+ local paramData = {
114+ videoId = Native :nativeVideoID (),
115+ id = data .id ,
116+ launchPlanId = data .launchPlanId ,
117+ createId = data .createId ,
118+ timestamp = data .videoStartTime ,
119+ commonParam = Native :commonParam ()
120+ }
121+
122+ local paramDataString = Native :tableToJson (paramData )
123+ -- local OS_HTTP_POST_CHECK_HOTSPOT = OS_HTTP_HOST .. "/api/notice"
124+
125+ -- print("[LuaView] "..paramDataString)
126+ -- print("[LuaView] "..OS_HTTP_POST_CHECK_HOTSPOT)
127+ -- print("[LuaView] "..Native:aesEncrypt(paramDataString, OS_HTTP_PUBLIC_KEY, OS_HTTP_PUBLIC_KEY))
128+
129+ mainNode .request :post (OS_HTTP_POST_CHECK_HOTSPOT , {
130+ bu_id = buId ,
131+ device_type = deviceType ,
132+ data = Native :aesEncrypt (paramDataString , OS_HTTP_PUBLIC_KEY , OS_HTTP_PUBLIC_KEY )
133+ }, function (response , errorInfo )
134+ -- print("luaview getVoteCountInfo")
135+ if (response == nil ) then
136+ return
137+ end
138+ -- print("luaview getVoteCountInfo 11"..Native:tableToJson(response))
139+ responseData = Native :aesDecrypt (response .encryptData , OS_HTTP_PUBLIC_KEY , OS_HTTP_PUBLIC_KEY )
140+ -- print("luaview " .. Native:tableToJson(data))
141+ -- print("luaview " .. responseData)
142+ response = toTable (responseData )
143+ if (response .resCode ~= " 00" ) then
144+ return
145+ end
146+
147+ if (response .status == " 00" ) then
148+ if checkAdTable [data .id ] ~= nil then
149+ checkAdTable [data .id ] = true
150+ end
151+ end
152+
153+ end )
154+ end
155+
107156-- 轮询添加广告逻辑广告逻辑(注:)
108157local function dispatchAd (dataTables , position )
109158 local currentPositionAdInfos = {}
@@ -117,7 +166,11 @@ local function dispatchAd(dataTables, position)
117166 showAdTable [value .id ] = value
118167 currentPositionAdInfos [value .id ] = value
119168 table.insert (bubbleIdList , value .id )
120- elseif value .videoStartTime ~= nil and (tonumber (value .videoStartTime ) <= position and (tonumber (value .videoStartTime ) + adShowInterval ) >= position and showAdTable [value .id ] == nil ) then
169+ elseif value .videoStartTime ~= nil and ((tonumber (value .videoStartTime ) - adCheckInterval ) <= position and tonumber (value .videoStartTime ) >= position and checkAdTable [value .id ] == nil ) then
170+ checkAdTable [value .id ] = false
171+ checkHotspotShow (value )
172+ elseif value .videoStartTime ~= nil and (tonumber (value .videoStartTime ) <= position and (tonumber (value .videoStartTime ) + adShowInterval ) >= position and showAdTable [value .id ] == nil ) and checkAdTable [value .id ] == true then
173+ checkAdTable [value .id ] = nil
121174 showAdTable [value .id ] = value
122175 currentPositionAdInfos [value .id ] = value
123176 elseif ((position >= tonumber (value .videoEndTime ) or position <= tonumber (value .videoStartTime )) and showAdTable [value .id ] ~= nil ) then
@@ -163,6 +216,7 @@ local function registerMedia()
163216 onMediaProgress = function (progress )
164217 -- 视频被拖动时,删除所有已经显示的热点
165218 if lastProgress ~= nil and math.abs (lastProgress - progress ) > 1500 then
219+ checkAdTable = {}
166220 for key , value in pairs (showAdTable ) do
167221 closeAdView (key , value )
168222 end
@@ -422,9 +476,6 @@ function show(args)
422476 mainNode .media = registerMedia ()
423477 mainNode .request = HttpRequest ()
424478
425- if System .ios () then
426- deviceType = 1
427- end
428479 -- 加载网络请求通用参数
429480 local paramData = {
430481 videoId = Native :nativeVideoID (),
0 commit comments