Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
蒋秀川
/
miniProject
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 70c670ed
authored
Sep 22, 2023
by
Tianqing Liu
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: 增加编码检查函数
1 parent
d9f65254
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
0 deletions
h5/src/components/vionPlayer/utils.js
h5/src/components/vionPlayer/utils.js
View file @
70c670e
...
@@ -52,3 +52,109 @@ export function getWatermarkCanvasImg(width, height, text, image) {
...
@@ -52,3 +52,109 @@ export function getWatermarkCanvasImg(width, height, text, image) {
return
canvas
;
return
canvas
;
// return canvas.toDataURL('image/png');
// return canvas.toDataURL('image/png');
}
}
// 支持MSE H265解码
export
function
checkSupportMSEHevc
()
{
return
window
.
MediaSource
&&
window
.
MediaSource
.
isTypeSupported
(
'video/mp4; codecs="hev1.1.6.L123.b0"'
);
}
// 支持Webcodecs H265解码
export
function
checkSupportWCSHevc
()
{
const
browserInfo
=
getBrowser
();
const
supportWCS
=
checkSupportWCS
();
return
supportWCS
&&
browserInfo
.
type
.
toLowerCase
()
===
'chrome'
&&
browserInfo
.
version
>=
107
&&
(
location
.
protocol
===
'https:'
||
location
.
hostname
===
'localhost'
);
}
// 支持WASM解码
export
function
checkSupportWasm
()
{
try
{
if
(
typeof
window
.
WebAssembly
===
'object'
&&
typeof
window
.
WebAssembly
.
instantiate
===
'function'
)
{
const
module
=
new
window
.
WebAssembly
.
Module
(
Uint8Array
.
of
(
0x0
,
0x61
,
0x73
,
0x6d
,
0x01
,
0x00
,
0x00
,
0x00
));
if
(
module
instanceof
window
.
WebAssembly
.
Module
)
{
return
new
window
.
WebAssembly
.
Instance
(
module
)
instanceof
window
.
WebAssembly
.
Instance
;
}
}
return
false
;
}
catch
(
e
)
{
return
false
;
}
}
// 支持WASM SIMD解码
export
function
checkSupportSIMD
()
{
return
WebAssembly
&&
WebAssembly
.
validate
(
new
Uint8Array
([
0
,
97
,
115
,
109
,
1
,
0
,
0
,
0
,
1
,
5
,
1
,
96
,
0
,
1
,
123
,
3
,
2
,
1
,
0
,
10
,
10
,
1
,
8
,
0
,
65
,
0
,
253
,
15
,
253
,
98
,
11
]));
}
function
checkSupportWCS
()
{
return
"VideoEncoder"
in
window
;
}
function
getBrowser
()
{
const
UserAgent
=
window
.
navigator
.
userAgent
.
toLowerCase
()
||
''
;
let
browserInfo
=
{
type
:
''
,
version
:
''
};
var
browserArray
=
{
IE
:
window
.
ActiveXObject
||
"ActiveXObject"
in
window
,
// IE
Chrome
:
UserAgent
.
indexOf
(
'chrome'
)
>
-
1
&&
UserAgent
.
indexOf
(
'safari'
)
>
-
1
,
// Chrome浏览器
Firefox
:
UserAgent
.
indexOf
(
'firefox'
)
>
-
1
,
// 火狐浏览器
Opera
:
UserAgent
.
indexOf
(
'opera'
)
>
-
1
,
// Opera浏览器
Safari
:
UserAgent
.
indexOf
(
'safari'
)
>
-
1
&&
UserAgent
.
indexOf
(
'chrome'
)
==
-
1
,
// safari浏览器
Edge
:
UserAgent
.
indexOf
(
'edge'
)
>
-
1
,
// Edge浏览器
QQBrowser
:
/qqbrowser/
.
test
(
UserAgent
),
// qq浏览器
WeixinBrowser
:
/MicroMessenger/i
.
test
(
UserAgent
)
// 微信浏览器
};
// console.log(browserArray)
for
(
let
i
in
browserArray
)
{
if
(
browserArray
[
i
])
{
let
versions
=
''
;
if
(
i
===
'IE'
)
{
const
versionArray
=
UserAgent
.
match
(
/
(
msie
\s
|trident.*rv:
)([\w
.
]
+
)
/
)
if
(
versionArray
&&
versionArray
.
length
>
2
)
{
versions
=
UserAgent
.
match
(
/
(
msie
\s
|trident.*rv:
)([\w
.
]
+
)
/
)[
2
];
}
}
else
if
(
i
===
'Chrome'
)
{
for
(
let
mt
in
navigator
.
mimeTypes
)
{
//检测是否是360浏览器(测试只有pc端的360才起作用)
if
(
navigator
.
mimeTypes
[
mt
][
'type'
]
===
'application/360softmgrplugin'
)
{
i
=
'360'
;
}
}
const
versionArray
=
UserAgent
.
match
(
/chrome
\/([\d
.
]
+
)
/
);
if
(
versionArray
&&
versionArray
.
length
>
1
)
{
versions
=
versionArray
[
1
];
}
}
else
if
(
i
===
'Firefox'
)
{
const
versionArray
=
UserAgent
.
match
(
/firefox
\/([\d
.
]
+
)
/
);
if
(
versionArray
&&
versionArray
.
length
>
1
)
{
versions
=
versionArray
[
1
];
}
}
else
if
(
i
===
'Opera'
)
{
const
versionArray
=
UserAgent
.
match
(
/opera
\/([\d
.
]
+
)
/
);
if
(
versionArray
&&
versionArray
.
length
>
1
)
{
versions
=
versionArray
[
1
];
}
}
else
if
(
i
===
'Safari'
)
{
const
versionArray
=
UserAgent
.
match
(
/version
\/([\d
.
]
+
)
/
);
if
(
versionArray
&&
versionArray
.
length
>
1
)
{
versions
=
versionArray
[
1
];
}
}
else
if
(
i
===
'Edge'
)
{
const
versionArray
=
UserAgent
.
match
(
/edge
\/([\d
.
]
+
)
/
);
if
(
versionArray
&&
versionArray
.
length
>
1
)
{
versions
=
versionArray
[
1
];
}
}
else
if
(
i
===
'QQBrowser'
)
{
const
versionArray
=
UserAgent
.
match
(
/qqbrowser
\/([\d
.
]
+
)
/
);
if
(
versionArray
&&
versionArray
.
length
>
1
)
{
versions
=
versionArray
[
1
];
}
}
browserInfo
.
type
=
i
;
browserInfo
.
version
=
parseInt
(
versions
);
}
}
return
browserInfo
;
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment