Skip to content

Commit 7607e57

Browse files
committed
update lua
1 parent df3bbd0 commit 7607e57

File tree

6 files changed

+73
-13
lines changed

6 files changed

+73
-13
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"1.2.0"}
1+
{"version":"1.3.0"}

Resources/VideoPlsResources.bundle/lua/main.lua

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ require "os_util"
2323
require "os_constant"
2424
local repeatAdTable = {} --广告轮询集合
2525
local showAdTable = {} --正在展示的table
26+
local checkAdTable = {} --广告是否可以展示
2627
local lastProgress = 0
2728
local bubbleIdList = {}
2829
local targetObjId = nil
2930
local roomId = Native:nativeVideoID()
30-
local deviceType = 2
31-
local buId = "videoos"
32-
local adShowInterval = 2000
31+
local adShowInterval = 1000
32+
local adCheckInterval = 5000
3333
local preloadCount = 1
3434
mainNode = object:new()
3535

@@ -104,6 +104,55 @@ local function closeAdView(adId, data)
104104
end
105105
end
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
--轮询添加广告逻辑广告逻辑(注:)
108157
local 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(),

Resources/VideoPlsResources.bundle/lua/os_config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function object:new(o)
66
return o
77
end
88
function getScale()
9-
local screenW, screenH = System.screenSize()
9+
local screenW, screenH = Native:getVideoSize(2)
1010
return math.min(screenW, screenH) / 375
1111
end
1212
is_iPhoneX = false

Resources/VideoPlsResources.bundle/lua/os_constant.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ osTypeLiveOS = 2
2626

2727
--页面层次
2828
osHotspotViewPriority = 1
29-
osInfoViewPriority = 2
29+
osInfoViewPriority = 2
30+
31+
--设备类型 1 iOS 2 Android
32+
deviceType = 2
33+
if System.ios() then
34+
deviceType = 1
35+
end
36+
37+
buId = "videoos"

Resources/VideoPlsResources.bundle/lua/os_string.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ OS_HTTP_GET_MOBILE_QUERY = OS_HTTP_HOST .. "/api/mobileQuery"
1111
OS_HTTP_POST_MOBILE_QUERY = OS_HTTP_HOST .. "/api/mobileModify"
1212
OS_HTTP_GET_COMMON_QUERY = OS_HTTP_HOST .. "/api/commonQuery"
1313
OS_HTTP_GET_SIMULATION_TAG = OS_HTTP_HOST .. "/simulation/queryInfo"
14+
OS_HTTP_POST_CHECK_HOTSPOT = OS_HTTP_HOST .. "/api/notice"
1415

1516
--数据统计网络相关
1617
OS_HTTP_GET_STARTS = OS_HTTP_HOST .. "/statistic"

Resources/VideoPlsResources.bundle/lua/os_win_link.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ local function createParent(isPortrait)
3030
luaView = ThroughView()
3131
end
3232
luaView:backgroundColor(0xFFFFFF)
33-
local screenWidth, screenHeight = System.screenSize()
33+
local screenWidth, screenHeight = Native:getVideoSize(2)
3434
if (isPortrait) then
3535
luaView:frame(0, 0, math.min(screenWidth, screenHeight), math.max(screenWidth, screenHeight))
3636
else
@@ -41,7 +41,7 @@ end
4141

4242
local function createTopView(isPortrait)
4343
local topParentView = View()
44-
local screenWidth, screenHeight = System.screenSize()
44+
local screenWidth, screenHeight = Native:getVideoSize(2)
4545
if (isPortrait) then
4646
topParentView:frame(0, 0, math.min(screenWidth, screenHeight), 44 * scale)
4747
else
@@ -65,7 +65,7 @@ end
6565

6666
local function createWebView(isPortrait)
6767
local webview = WebView()
68-
local screenWidth, screenHeight = System.screenSize()
68+
local screenWidth, screenHeight = Native:getVideoSize(2)
6969
if (isPortrait) then
7070
webview:frame(0, 44 * scale, math.min(screenWidth, screenHeight), math.max(screenWidth, screenHeight))
7171
else

0 commit comments

Comments
 (0)