Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
e580084a
Commit
e580084a
authored
Nov 12, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改实例化关系
parent
4bf722af
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
164 additions
and
0 deletions
+164
-0
MediaCache.java
...image/src/main/java/com/yanzuoguang/media/MediaCache.java
+33
-0
MediaFirst.java
...image/src/main/java/com/yanzuoguang/media/MediaFirst.java
+49
-0
MediaReqVo.java
...image/src/main/java/com/yanzuoguang/media/MediaReqVo.java
+69
-0
MediaResVo.java
...image/src/main/java/com/yanzuoguang/media/MediaResVo.java
+13
-0
readme.md
yzg-util-image/src/main/java/com/yanzuoguang/media/readme.md
+0
-0
No files found.
yzg-util-image/src/main/java/com/yanzuoguang/media/MediaCache.java
0 → 100644
View file @
e580084a
package
com
.
yanzuoguang
.
media
;
/**
* 获取视频是否已经在处理
*
* @author 颜佐光
*/
public
interface
MediaCache
{
/**
* 获取缓存是否正在执行
*
* @param req 需要运行的请求参数
* @param runnable 当没有运行时,需要执行的函数
* @return
*/
MediaResVo
start
(
MediaReqVo
req
,
Runnable
runnable
);
/**
* 获取缓存是否正在运行
*
* @param req
* @return
*/
MediaResVo
get
(
MediaReqVo
req
);
/**
* 写入处理结果到缓存中
*
* @param res
*/
void
put
(
MediaResVo
res
);
}
yzg-util-image/src/main/java/com/yanzuoguang/media/MediaFirst.java
0 → 100644
View file @
e580084a
package
com
.
yanzuoguang
.
media
;
import
com.yanzuoguang.util.helper.JsonHelper
;
import
com.yanzuoguang.util.thread.ThreadHelper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MediaFirst
{
/**
* 判断该视频是否已经实现处理
*/
@Autowired
(
required
=
false
)
private
MediaCache
cache
;
public
MediaResVo
start
(
MediaReqVo
req
)
{
MediaResVo
res
=
cache
.
start
(
req
,
new
Runnable
()
{
@Override
public
void
run
()
{
ThreadHelper
.
runThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
handle
(
req
);
}
});
}
});
return
res
;
}
private
void
handle
(
MediaReqVo
req
)
{
do
{
MediaResVo
res
=
cache
.
get
(
req
);
if
(
res
==
null
)
{
res
=
JsonHelper
.
to
(
req
,
MediaResVo
.
class
);
}
else
if
(
res
.
getCount
()
<
1
)
{
break
;
}
res
.
subCount
();
cache
.
put
(
res
);
ThreadHelper
.
sleep
(
res
.
getSplit
());
}
while
(
true
);
}
}
yzg-util-image/src/main/java/com/yanzuoguang/media/MediaReqVo.java
0 → 100644
View file @
e580084a
package
com
.
yanzuoguang
.
media
;
import
com.yanzuoguang.util.vo.BaseVo
;
import
io.swagger.annotations.ApiModelProperty
;
/**
* 获取视频首页请求参数
*
* @author 颜佐光
*/
public
class
MediaReqVo
extends
BaseVo
{
/**
* 汲取视频的url
*/
@ApiModelProperty
(
notes
=
"m3mu地址"
)
private
String
url
;
/**
* m3mu地址截取次数
*/
@ApiModelProperty
(
notes
=
"m3mu地址截取次数"
)
private
int
count
;
/**
* m3mu地址截取间隔时间
*/
@ApiModelProperty
(
notes
=
"m3mu地址截取间隔时间"
)
private
int
split
;
/**
* m3mu缓存的图片地址
*/
@ApiModelProperty
(
notes
=
"m3mu缓存的图片地址"
)
private
String
imageUrl
;
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
int
getCount
()
{
return
count
;
}
public
void
setCount
(
int
count
)
{
this
.
count
=
count
;
}
public
int
getSplit
()
{
return
split
;
}
public
void
setSplit
(
int
split
)
{
this
.
split
=
split
;
}
public
String
getImageUrl
()
{
return
imageUrl
;
}
public
void
setImageUrl
(
String
imageUrl
)
{
this
.
imageUrl
=
imageUrl
;
}
}
yzg-util-image/src/main/java/com/yanzuoguang/media/MediaResVo.java
0 → 100644
View file @
e580084a
package
com
.
yanzuoguang
.
media
;
/**
* 获取视频结果
*
* @author 颜佐光
*/
public
class
MediaResVo
extends
MediaReqVo
{
public
void
subCount
()
{
this
.
setCount
(
this
.
getCount
()
-
1
);
}
}
yzg-util-image/src/main/java/com/yanzuoguang/media/readme.md
0 → 100755
View file @
e580084a
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment