基于免vip接口的破解视频播放器
第一次,第一篇,新的历程,学习进步,不断前行:
自己简单做了一个基于网页的播放器,菜鸟初出,不喜勿喷,
效果图
代码块
MainActivity.java
package com.example.dawn_.uplayer;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.AdapterView;
public class MainActivity extends AppCompatActivity
{
private String mainUrl="";
@Override
protected void onDestroy()
{
WebView webView = (WebView)findViewById(R.id.webView);//重复声明
super.onDestroy();
//为了使WebView退出时音频或视频关闭
webView.destroy();
}
@Override
protected void onPause ()
{
WebView webView = (WebView)findViewById(R.id.webView);//重复声明
webView.reload ();
super.onPause ();
}
private void Load( String mainUrl)
{
final WebView webView = (WebView)findViewById(R.id.webView);//为什么声明在类下面就闪退
//设置WebView属性,能够执行Javascript脚本
webView.getSettings().setJavaScriptEnabled(true);
// 设置可以支持缩放
// webView.getSettings().setSupportZoom(true);
// 设置出现缩放工具
webView.getSettings().setBuiltInZoomControls(true);
//扩大比例的缩放
webView.getSettings().setUseWideViewPort(true);
//自适应屏幕
webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webView.getSettings().setLoadWithOverviewMode(true);
//加载需要显示的网页
webView.loadUrl(mainUrl);
//设置Web视图
webView.setWebViewClient(new HelloWebViewClient());
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button)findViewById(R.id.button);
//隐藏状态栏
RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.relativeLayout);
// relativeLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
relativeLayout.setSystemUiVisibility(View.INVISIBLE);
Spinner spinner = (Spinner) findViewById(R.id.spinner1);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView parent, View view,int pos, long id)
{
String[] desk = getResources().getStringArray(R.array.desk);
switch(desk[pos].toString())
{
case "搜库":
mainUrl="http://www.soku.com/";
break;
case "爱奇艺":
mainUrl="http://www.iqiyi.com/";
break;
case "腾讯视频":
mainUrl="https://v.qq.com/";
break;
case "乐视视频":
mainUrl="http://www.le.com/";
break;
case "芒果TV":
mainUrl="http://www.mgtv.com/";
break;
case "PPTV":
mainUrl="http://www.pptv.com/";
break;
case "搜狐视频":
mainUrl="http://tv.sohu.com/";
break;
}
Load( mainUrl);//根据内容提供链接
Log.w("1234567890123456789",mainUrl);
}
@Override
public void onNothingSelected(AdapterView parent)
{
Log.w("0","什么也没干");
}
});
{
Load(mainUrl);
}
button.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent intent = new Intent(MainActivity.this,SubWeb.class);
final WebView webView = (WebView)findViewById(R.id.webView);//为什么声明在类下面就闪退
/* 通过Bundle对象存储需要传递的数据 */
Bundle bundle = new Bundle();
/*字符、字符串、布尔、字节数组、浮点数等等,都可以传*/
bundle.putString("Url",webView.getUrl().toString() );
/*把bundle对象assign给Intent*/
intent.putExtras(bundle);
// webView.onPause();//销毁
startActivity(intent);
}
});
}
@Override
//设置回退
//覆盖Activity类的onKeyDown(int keyCoder,KeyEvent event)方法
public boolean onKeyDown(int keyCode, KeyEvent event)
{
final WebView webView = (WebView)findViewById(R.id.webView);
if ((keyCode == android.view.KeyEvent.KEYCODE_BACK) && webView.canGoBack())
{
webView.goBack(); //goBack()表示返回WebView的上一页面
return true;
}
else if (keyCode == android.view.KeyEvent.KEYCODE_BACK )
{
// 创建退出对话框
AlertDialog isExit = new AlertDialog.Builder(this).create();
// 设置对话框标题
isExit.setTitle("系统提示");
// 设置对话框消息
isExit.setMessage("确定要退出吗");
// 添加选择按钮并注册监听
isExit.setButton("确定", listener);
isExit.setButton2("取消", listener);
// 显示对话框
isExit.show();
}
return false;
}
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
switch (which)
{
case AlertDialog.BUTTON_POSITIVE:// "确认"按钮退出程序
finish();
break;
case AlertDialog.BUTTON_NEGATIVE:// "取消"第二个按钮取消对话框
break;
default:
break;
}
}
};
}
//Web视图
class HelloWebViewClient extends WebViewClient
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.startsWith("http:") || url.startsWith("https:") )
{
view.loadUrl(url);
return true;
}
else
{
return false;
}
}
@Override
public void onPageFinished(WebView subWebView, String url)
{
// subWebView.loadUrl("javascript:function setTop(){document.querySelector('.tui__header.action.close').style.display=\"none\";}setTop();");
subWebView.loadUrl("javascript:function setBottom(){document.getElementsByClassName('.tui__header').style.display=\"none\";}setBottom();");
//无效
}
}
SubWeb.java
package com.example.dawn_.uplayer;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.Spinner;
/**
* Created by DAWN_主机 on 2017/9/23.
*/
public class SubWeb extends AppCompatActivity
{
private String subUrl="";
@Override
protected void onDestroy()
{
WebView subWebView = (WebView)findViewById(R.id.subWebView);//重复声明
super.onDestroy();
//为了使WebView退出时音频或视频关闭
subWebView.destroy();
}
private void SubLoad( String subUrl)
{
WebView subWebView = (WebView)findViewById(R.id.subWebView);
WebSettings webSettings = subWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setPluginState(WebSettings.PluginState.ON);
webSettings.setUseWideViewPort(true); // 关键点
webSettings.setAllowFileAccess(true); // 允许访问文件
webSettings.setSupportZoom(true); // 支持缩放
webSettings.setLoadWithOverviewMode(true);
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); // 不加载缓存内容
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
subWebView.getSettings().setUseWideViewPort(true);
//设置WebView属性,能够执行Javascript脚本
subWebView.getSettings().setJavaScriptEnabled(true);
// 设置可以支持缩放
subWebView.getSettings().setSupportZoom(true);
// 设置出现缩放工具
subWebView.getSettings().setBuiltInZoomControls(true);
//扩大比例的缩放
subWebView.getSettings().setUseWideViewPort(true);
//自适应屏幕
subWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
subWebView.getSettings().setLoadWithOverviewMode(true);
/*获取Intent中的Bundle对象*/
Bundle bundle = this.getIntent().getExtras();
//加载需要显示的网页
subWebView.loadUrl(subUrl+bundle.getString("Url"));
Log.w("收到的参数1",bundle.getString("Url"));
Log.w("收到的参数2",subWebView.getUrl());
//设置Web视图
subWebView.setWebViewClient(new HelloWebViewClient());
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.subweb);
Spinner spinner = (Spinner) findViewById(R.id.spinner2);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView parent, View view, int pos, long id) {
String[] desk2 = getResources().getStringArray(R.array.desk2);
switch(desk2[pos].toString())
{
case "接口1":
subUrl="http://www.65yw.com/chaojikan.php?url=";/////////////////////////////////MP4直连、优酷网、、爱奇艺、芒果TV、乐视、PPTV、搜狐视频、腾讯视频
break;
case "接口2":
subUrl="http://g.o.t.o.tutulai.cn/?url=";/////////////////////////////////支持爱奇艺、腾讯、优酷
break;
case "接口3":
subUrl="http://api.baiyug.cn/vip/index.php?url=";/////////////////////////////////百域阁全平台
break;
}
SubLoad( subUrl);//根据内容提供链接
Log.w("接口",subUrl);
}
@Override
public void onNothingSelected(AdapterView parent)
{
Log.w("0","什么也没干");
}
});
{
SubLoad( subUrl);
}
}
}
软件主页> http://www.lichenyang.pw/
欢迎来访>