本文整理汇总了Java中com.danikula.videocache.HttpProxyCacheServer.getProxyUrl方法的典型用法代码示例。如果您正苦于以下问题:Java HttpProxyCacheServer.getProxyUrl方法的具体用法?Java HttpProxyCacheServer.getProxyUrl怎么用?Java HttpProxyCacheServer.getProxyUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.danikula.videocache.HttpProxyCacheServer
的用法示例。
在下文中一共展示了HttpProxyCacheServer.getProxyUrl方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readProxyResponse
import com.danikula.videocache.HttpProxyCacheServer; //导入方法依赖的package包/类
public static Response readProxyResponse(HttpProxyCacheServer proxy, String url, int offset) throws IOException {
String proxyUrl = proxy.getProxyUrl(url, false);
if (!proxyUrl.startsWith("http://127.0.0.1")) {
throw new IllegalStateException("Proxy url " + proxyUrl + " is not proxied! Original url is " + url);
}
URL proxiedUrl = new URL(proxyUrl);
HttpURLConnection connection = (HttpURLConnection) proxiedUrl.openConnection();
try {
if (offset >= 0) {
connection.setRequestProperty("Range", "bytes=" + offset + "-");
}
return new Response(connection);
} finally {
connection.disconnect();
}
}
示例2: startPrepare
import com.danikula.videocache.HttpProxyCacheServer; //导入方法依赖的package包/类
/**
* 开始准备播放(直接播放)
*/
protected void startPrepare() {
if (mCurrentUrl == null || mCurrentUrl.trim().equals("")) return;
try {
if (isCache) {
HttpProxyCacheServer cacheServer = getCacheServer();
String proxyPath = cacheServer.getProxyUrl(mCurrentUrl);
cacheServer.registerCacheListener(cacheListener, mCurrentUrl);
if (cacheServer.isCached(mCurrentUrl)) {
bufferPercentage = 100;
}
mMediaPlayer.setDataSource(proxyPath);
} else {
mMediaPlayer.setDataSource(mCurrentUrl);
}
mMediaPlayer.prepareAsync();
mCurrentState = STATE_PREPARING;
setPlayState(mCurrentState);
setPlayerState(isFullScreen() ? PLAYER_FULL_SCREEN : PLAYER_NORMAL);
} catch (Exception e) {
mCurrentState = STATE_ERROR;
setPlayState(mCurrentState);
e.printStackTrace();
}
}
示例3: resolveChangeUrl
import com.danikula.videocache.HttpProxyCacheServer; //导入方法依赖的package包/类
private void resolveChangeUrl(boolean cacheWithPlay, File cachePath, String url) {
if (mTmpManager != null) {
mCache = cacheWithPlay;
mCachePath = cachePath;
mOriginUrl = url;
if (cacheWithPlay && url.startsWith("http") && !url.contains("127.0.0.1") && !url.contains(".m3u8")) {
HttpProxyCacheServer proxy = (cachePath != null) ?
mTmpManager.newProxy(getActivityContext().getApplicationContext(), cachePath) : mTmpManager.newProxy(getActivityContext().getApplicationContext());
//此处转换了url,然后再赋值给mUrl。
url = proxy.getProxyUrl(url);
mCacheFile = (!url.startsWith("http"));
mTmpManager.setProxy(proxy);
//注册上缓冲监听
if (!mCacheFile && GSYVideoManager.instance() != null) {
proxy.registerCacheListener(GSYVideoManager.instance(), mOriginUrl);
}
} else if (!cacheWithPlay && (!url.startsWith("http") && !url.startsWith("rtmp")
&& !url.startsWith("rtsp") && !url.contains(".m3u8"))) {
mCacheFile = true;
}
this.mUrl = url;
}
}
示例4: readProxyResponse
import com.danikula.videocache.HttpProxyCacheServer; //导入方法依赖的package包/类
public static Response readProxyResponse(HttpProxyCacheServer proxy, String url, int offset) throws IOException {
String proxyUrl = proxy.getProxyUrl(url);
if (!proxyUrl.startsWith("http://127.0.0.1")) {
throw new IllegalStateException("Url " + url + " is not proxied!");
}
URL proxiedUrl = new URL(proxyUrl);
HttpURLConnection connection = (HttpURLConnection) proxiedUrl.openConnection();
try {
if (offset >= 0) {
connection.setRequestProperty("Range", "bytes=" + offset + "-");
}
return new Response(connection);
} finally {
connection.disconnect();
}
}
示例5: startVideo
import com.danikula.videocache.HttpProxyCacheServer; //导入方法依赖的package包/类
private void startVideo() {
HttpProxyCacheServer proxy = App.getProxy(getActivity());
proxy.registerCacheListener(this, url);
String proxyUrl = proxy.getProxyUrl(url);
Log.d(LOG_TAG, "Use proxy url " + proxyUrl + " instead of original url " + url);
videoView.setVideoPath(proxyUrl);
videoView.start();
}
示例6: getPort
import com.danikula.videocache.HttpProxyCacheServer; //导入方法依赖的package包/类
public static int getPort(HttpProxyCacheServer server) {
String proxyUrl = server.getProxyUrl("test");
Pattern pattern = Pattern.compile("http://127.0.0.1:(\\d*)/test");
Matcher matcher = pattern.matcher(proxyUrl);
assertThat(matcher.find()).isTrue();
String portAsString = matcher.group(1);
return Integer.parseInt(portAsString);
}
示例7: display
import com.danikula.videocache.HttpProxyCacheServer; //导入方法依赖的package包/类
@Override
public void display(Context context, ViewGroup layout) {
/* Proxy Url for caching */
HttpProxyCacheServer proxy = VideoCacheProxyManager.getProxy(context);
String proxyUrl = proxy.getProxyUrl(mUrl);
mVideoView = addOrReplaceViewByType(layout, context, VideoView.class);
//Use a media controller so that you can scroll the video contents
//and also to pause, start the video.
MediaController mediaController = new MediaController(context);
mediaController.setAnchorView(mVideoView);
mVideoView.setMediaController(mediaController);
mVideoView.setVideoPath(proxyUrl);
mVideoView.setOnCompletionListener(onMediaCompletionListener);
}
示例8: setUp
import com.danikula.videocache.HttpProxyCacheServer; //导入方法依赖的package包/类
/**
* 设置播放URL
*
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param title title
* @return
*/
public boolean setUp(String url, boolean cacheWithPlay, File cachePath, String title) {
mCache = cacheWithPlay;
mCachePath = cachePath;
mOriginUrl = url;
if (isCurrentMediaListener() &&
(System.currentTimeMillis() - mSaveChangeViewTIme) < CHANGE_DELAY_TIME)
return false;
mCurrentState = CURRENT_STATE_NORMAL;
if (cacheWithPlay && url.startsWith("http") && !url.contains("127.0.0.1") && !url.contains(".m3u8")) {
HttpProxyCacheServer proxy = GSYVideoManager.getProxy(getActivityContext().getApplicationContext(), cachePath);
//此处转换了url,然后再赋值给mUrl。
url = proxy.getProxyUrl(url);
mCacheFile = (!url.startsWith("http"));
//注册上缓冲监听
if (!mCacheFile && GSYVideoManager.instance() != null) {
proxy.registerCacheListener(GSYVideoManager.instance(), mOriginUrl);
}
} else if (!cacheWithPlay && (!url.startsWith("http") && !url.startsWith("rtmp")
&& !url.startsWith("rtsp") && !url.contains(".m3u8"))) {
mCacheFile = true;
}
this.mUrl = url;
this.mTitle = title;
setStateAndUi(CURRENT_STATE_NORMAL);
return true;
}
示例9: onCreate
import com.danikula.videocache.HttpProxyCacheServer; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_view);
Intent intent=getIntent();
String videourl= intent.getStringExtra("video");
/*
Uri uri = Uri.parse(videourl);
//调用系统自带的播放器
intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "video/mp4");
startActivity(intent);
finish();*/
//Uri uri = Uri.parse(videourl);
UniversalVideoView videoView=(UniversalVideoView) findViewById(R.id.video_v);
HttpProxyCacheServer proxy = getProxy();
String proxyUrl = proxy.getProxyUrl(videourl);
videoView.setVideoPath(proxyUrl);
//videoView.setMediaController(new MediaController(this));
videoView.setMediaController(new UniversalMediaController(this));
videoView.setFullscreen(true);
videoView.setFitXY(true);
videoView.start();
videoView.requestFocus();
}
示例10: proxyURL
import com.danikula.videocache.HttpProxyCacheServer; //导入方法依赖的package包/类
public static String proxyURL(Context context, SharedPreferences preferences, String url) {
if(preferences.getBoolean("prefCacheVideos", false)) {
long cacheLimit = Integer.parseInt(preferences.getString("prefCacheLimit", "512"));
HttpProxyCacheServer proxy = getProxy(context,
cacheLimit * 1024 * 1024);
return proxy.getProxyUrl(url);
} else {
return url;
}
}