Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_26386469
GSYVideoPlayer
提交
caedb3a5
G
GSYVideoPlayer
项目概览
qq_26386469
/
GSYVideoPlayer
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
GSYVideoPlayer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
caedb3a5
编写于
12月 01, 2016
作者:
S
shuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.3.6 init 没有网络的提示
上级
d21dcb6c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
249 addition
and
1 deletion
+249
-1
app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java
...rc/main/java/com/example/gsyvideoplayer/DetailPlayer.java
+1
-1
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/utils/NetworkUtils.java
...ain/java/com/shuyu/gsyvideoplayer/utils/NetworkUtils.java
+241
-0
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java
...om/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java
+6
-0
gsyVideoPlayer/src/main/res/values/strings.xml
gsyVideoPlayer/src/main/res/values/strings.xml
+1
-0
未找到文件。
app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java
浏览文件 @
caedb3a5
...
@@ -40,7 +40,7 @@ public class DetailPlayer extends FragmentActivity {
...
@@ -40,7 +40,7 @@ public class DetailPlayer extends FragmentActivity {
ButterKnife
.
bind
(
this
);
ButterKnife
.
bind
(
this
);
String
url
=
"http://baobab.wdjcdn.com/14564977406580.mp4"
;
String
url
=
"http://baobab.wdjcdn.com/14564977406580.mp4"
;
detailPlayer
.
setUp
(
url
,
true
,
"
"
);
detailPlayer
.
setUp
(
url
,
true
,
null
,
"测试视频
"
);
//增加封面
//增加封面
ImageView
imageView
=
new
ImageView
(
this
);
ImageView
imageView
=
new
ImageView
(
this
);
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/utils/NetworkUtils.java
0 → 100644
浏览文件 @
caedb3a5
package
com.shuyu.gsyvideoplayer.utils
;
/**
* Created by shuyu on 2016/8/10.
*
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2016/8/2
* </pre>
*
*/
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.ConnectivityManager
;
import
android.net.NetworkInfo
;
import
android.telephony.TelephonyManager
;
public
class
NetworkUtils
{
private
NetworkUtils
()
{
}
public
static
final
int
NETWORK_WIFI
=
1
;
// wifi network
public
static
final
int
NETWORK_4G
=
4
;
// "4G" networks
public
static
final
int
NETWORK_3G
=
3
;
// "3G" networks
public
static
final
int
NETWORK_2G
=
2
;
// "2G" networks
public
static
final
int
NETWORK_UNKNOWN
=
5
;
// unknown network
public
static
final
int
NETWORK_NO
=
-
1
;
// no network
private
static
final
int
NETWORK_TYPE_GSM
=
16
;
private
static
final
int
NETWORK_TYPE_TD_SCDMA
=
17
;
private
static
final
int
NETWORK_TYPE_IWLAN
=
18
;
/**
* 打开网络设置界面
* <p>3.0以下打开设置界面</p>
*
* @param context 上下文
*/
public
static
void
openWirelessSettings
(
Context
context
)
{
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>
10
)
{
context
.
startActivity
(
new
Intent
(
android
.
provider
.
Settings
.
ACTION_SETTINGS
));
}
else
{
context
.
startActivity
(
new
Intent
(
android
.
provider
.
Settings
.
ACTION_WIRELESS_SETTINGS
));
}
}
/**
* 获取活动网路信息
*
* @param context 上下文
* @return NetworkInfo
*/
private
static
NetworkInfo
getActiveNetworkInfo
(
Context
context
)
{
ConnectivityManager
cm
=
(
ConnectivityManager
)
context
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
return
cm
.
getActiveNetworkInfo
();
}
/**
* 判断网络是否可用
* <p>需添加权限 android.permission.ACCESS_NETWORK_STATE</p>
*/
public
static
boolean
isAvailable
(
Context
context
)
{
NetworkInfo
info
=
getActiveNetworkInfo
(
context
);
return
info
!=
null
&&
info
.
isAvailable
();
}
/**
* 判断网络是否连接
* <p>需添加权限 android.permission.ACCESS_NETWORK_STATE</p>
*
* @param context 上下文
* @return true: 是<br>false: 否
*/
public
static
boolean
isConnected
(
Context
context
)
{
NetworkInfo
info
=
getActiveNetworkInfo
(
context
);
return
info
!=
null
&&
info
.
isConnected
();
}
/**
* 判断网络是否是4G
* <p>需添加权限 android.permission.ACCESS_NETWORK_STATE</p>
*
* @param context 上下文
* @return true: 是<br>false: 不是
*/
public
static
boolean
is4G
(
Context
context
)
{
NetworkInfo
info
=
getActiveNetworkInfo
(
context
);
return
info
!=
null
&&
info
.
isAvailable
()
&&
info
.
getSubtype
()
==
TelephonyManager
.
NETWORK_TYPE_LTE
;
}
/**
* 判断wifi是否连接状态
* <p>需添加权限 android.permission.ACCESS_NETWORK_STATE</p>
*
* @param context 上下文
* @return true: 连接<br>false: 未连接
*/
public
static
boolean
isWifiConnected
(
Context
context
)
{
ConnectivityManager
cm
=
(
ConnectivityManager
)
context
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
return
cm
!=
null
&&
cm
.
getActiveNetworkInfo
().
getType
()
==
ConnectivityManager
.
TYPE_WIFI
;
}
/**
* 获取移动网络运营商名称
* <p>如中国联通、中国移动、中国电信</p>
*
* @param context 上下文
* @return 移动网络运营商名称
*/
public
static
String
getNetworkOperatorName
(
Context
context
)
{
TelephonyManager
tm
=
(
TelephonyManager
)
context
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
return
tm
!=
null
?
tm
.
getNetworkOperatorName
()
:
null
;
}
/**
* 获取移动终端类型
*
* @param context 上下文
* @return 手机制式
* <ul>
* <li>PHONE_TYPE_NONE : 0 手机制式未知</li>
* <li>PHONE_TYPE_GSM : 1 手机制式为GSM,移动和联通</li>
* <li>PHONE_TYPE_CDMA : 2 手机制式为CDMA,电信</li>
* <li>PHONE_TYPE_SIP : 3</li>
* </ul>
*/
public
static
int
getPhoneType
(
Context
context
)
{
TelephonyManager
tm
=
(
TelephonyManager
)
context
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
return
tm
!=
null
?
tm
.
getPhoneType
()
:
-
1
;
}
/**
* 获取当前的网络类型(WIFI,2G,3G,4G)
* <p>需添加权限 android.permission.ACCESS_NETWORK_STATE</p>
*
* @param context 上下文
* @return 网络类型
* <ul>
* <li>NETWORK_WIFI = 1;</li>
* <li>NETWORK_4G = 4;</li>
* <li>NETWORK_3G = 3;</li>
* <li>NETWORK_2G = 2;</li>
* <li>NETWORK_UNKNOWN = 5;</li>
* <li>NETWORK_NO = -1;</li>
* </ul>
*/
public
static
int
getNetWorkType
(
Context
context
)
{
int
netType
=
NETWORK_NO
;
NetworkInfo
info
=
getActiveNetworkInfo
(
context
);
if
(
info
!=
null
&&
info
.
isAvailable
())
{
if
(
info
.
getType
()
==
ConnectivityManager
.
TYPE_WIFI
)
{
netType
=
NETWORK_WIFI
;
}
else
if
(
info
.
getType
()
==
ConnectivityManager
.
TYPE_MOBILE
)
{
switch
(
info
.
getSubtype
())
{
case
NETWORK_TYPE_GSM:
case
TelephonyManager
.
NETWORK_TYPE_GPRS
:
case
TelephonyManager
.
NETWORK_TYPE_CDMA
:
case
TelephonyManager
.
NETWORK_TYPE_EDGE
:
case
TelephonyManager
.
NETWORK_TYPE_1xRTT
:
case
TelephonyManager
.
NETWORK_TYPE_IDEN
:
netType
=
NETWORK_2G
;
break
;
case
NETWORK_TYPE_TD_SCDMA:
case
TelephonyManager
.
NETWORK_TYPE_EVDO_A
:
case
TelephonyManager
.
NETWORK_TYPE_UMTS
:
case
TelephonyManager
.
NETWORK_TYPE_EVDO_0
:
case
TelephonyManager
.
NETWORK_TYPE_HSDPA
:
case
TelephonyManager
.
NETWORK_TYPE_HSUPA
:
case
TelephonyManager
.
NETWORK_TYPE_HSPA
:
case
TelephonyManager
.
NETWORK_TYPE_EVDO_B
:
case
TelephonyManager
.
NETWORK_TYPE_EHRPD
:
case
TelephonyManager
.
NETWORK_TYPE_HSPAP
:
netType
=
NETWORK_3G
;
break
;
case
NETWORK_TYPE_IWLAN:
case
TelephonyManager
.
NETWORK_TYPE_LTE
:
netType
=
NETWORK_4G
;
break
;
default
:
String
subtypeName
=
info
.
getSubtypeName
();
if
(
subtypeName
.
equalsIgnoreCase
(
"TD-SCDMA"
)
||
subtypeName
.
equalsIgnoreCase
(
"WCDMA"
)
||
subtypeName
.
equalsIgnoreCase
(
"CDMA2000"
))
{
netType
=
NETWORK_3G
;
}
else
{
netType
=
NETWORK_UNKNOWN
;
}
break
;
}
}
else
{
netType
=
NETWORK_UNKNOWN
;
}
}
return
netType
;
}
/**
* 获取当前的网络类型(WIFI,2G,3G,4G)
* <p>依赖上面的方法</p>
*
* @param context 上下文
* @return 网络类型名称
* <ul>
* <li>NETWORK_WIFI </li>
* <li>NETWORK_4G </li>
* <li>NETWORK_3G </li>
* <li>NETWORK_2G </li>
* <li>NETWORK_UNKNOWN</li>
* <li>NETWORK_NO </li>
* </ul>
*/
public
static
String
getNetWorkTypeName
(
Context
context
)
{
switch
(
getNetWorkType
(
context
))
{
case
NETWORK_WIFI:
return
"NETWORK_WIFI"
;
case
NETWORK_4G:
return
"NETWORK_4G"
;
case
NETWORK_3G:
return
"NETWORK_3G"
;
case
NETWORK_2G:
return
"NETWORK_2G"
;
case
NETWORK_NO:
return
"NETWORK_NO"
;
default
:
return
"NETWORK_UNKNOWN"
;
}
}
}
\ No newline at end of file
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java
浏览文件 @
caedb3a5
...
@@ -29,6 +29,7 @@ import com.shuyu.gsyvideoplayer.R;
...
@@ -29,6 +29,7 @@ import com.shuyu.gsyvideoplayer.R;
import
com.shuyu.gsyvideoplayer.listener.StandardVideoAllCallBack
;
import
com.shuyu.gsyvideoplayer.listener.StandardVideoAllCallBack
;
import
com.shuyu.gsyvideoplayer.utils.CommonUtil
;
import
com.shuyu.gsyvideoplayer.utils.CommonUtil
;
import
com.shuyu.gsyvideoplayer.utils.Debuger
;
import
com.shuyu.gsyvideoplayer.utils.Debuger
;
import
com.shuyu.gsyvideoplayer.utils.NetworkUtils
;
import
java.io.File
;
import
java.io.File
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -267,6 +268,10 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
...
@@ -267,6 +268,10 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
@Override
@Override
public
void
showWifiDialog
()
{
public
void
showWifiDialog
()
{
super
.
showWifiDialog
();
super
.
showWifiDialog
();
if
(!
NetworkUtils
.
isAvailable
(
mContext
))
{
Toast
.
makeText
(
mContext
,
getResources
().
getString
(
R
.
string
.
no_net
),
Toast
.
LENGTH_LONG
).
show
();
return
;
}
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
getContext
());
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
getContext
());
builder
.
setMessage
(
getResources
().
getString
(
R
.
string
.
tips_not_wifi
));
builder
.
setMessage
(
getResources
().
getString
(
R
.
string
.
tips_not_wifi
));
builder
.
setPositiveButton
(
getResources
().
getString
(
R
.
string
.
tips_not_wifi_confirm
),
new
DialogInterface
.
OnClickListener
()
{
builder
.
setPositiveButton
(
getResources
().
getString
(
R
.
string
.
tips_not_wifi_confirm
),
new
DialogInterface
.
OnClickListener
()
{
...
@@ -802,4 +807,5 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
...
@@ -802,4 +807,5 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
public
RelativeLayout
getThumbImageViewLayout
()
{
public
RelativeLayout
getThumbImageViewLayout
()
{
return
mThumbImageViewLayout
;
return
mThumbImageViewLayout
;
}
}
}
}
gsyVideoPlayer/src/main/res/values/strings.xml
浏览文件 @
caedb3a5
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
<string
name=
"tips_not_wifi"
>
您当前正在使用移动网络,继续播放将消耗流量
</string>
<string
name=
"tips_not_wifi"
>
您当前正在使用移动网络,继续播放将消耗流量
</string>
<string
name=
"tips_not_wifi_confirm"
>
继续播放
</string>
<string
name=
"tips_not_wifi_confirm"
>
继续播放
</string>
<string
name=
"no_net"
>
当前找不到网络
</string>
<string
name=
"tips_not_wifi_cancel"
>
停止播放
</string>
<string
name=
"tips_not_wifi_cancel"
>
停止播放
</string>
<string
name=
"no_url"
>
播放地址无效
</string>
<string
name=
"no_url"
>
播放地址无效
</string>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录