diff --git a/pano360demo/pano360demo-release.apk b/pano360demo/pano360demo-release.apk
index 1823cd6..e86c724 100644
Binary files a/pano360demo/pano360demo-release.apk and b/pano360demo/pano360demo-release.apk differ
diff --git a/pano360demo/src/main/AndroidManifest.xml b/pano360demo/src/main/AndroidManifest.xml
index b61acda..735aba6 100644
--- a/pano360demo/src/main/AndroidManifest.xml
+++ b/pano360demo/src/main/AndroidManifest.xml
@@ -20,8 +20,6 @@
-
diff --git a/pano360demo/src/main/java/com/martin/ads/pano360demo/DemoWithGLSurfaceView.java b/pano360demo/src/main/java/com/martin/ads/pano360demo/DemoWithGLSurfaceView.java
index 89bcff9..a86aaa1 100644
--- a/pano360demo/src/main/java/com/martin/ads/pano360demo/DemoWithGLSurfaceView.java
+++ b/pano360demo/src/main/java/com/martin/ads/pano360demo/DemoWithGLSurfaceView.java
@@ -8,7 +8,8 @@
import android.view.View;
import android.view.WindowManager;
-import com.martin.ads.vrlib.PanoPlayerActivity;
+import com.martin.ads.vrlib.ui.Pano360ConfigBundle;
+import com.martin.ads.vrlib.ui.PanoPlayerActivity;
import com.martin.ads.vrlib.PanoViewWrapper;
/**
@@ -34,16 +35,16 @@ protected void onCreate(Bundle savedInstanceState) {
}
private void init(){
-
- String filePath=getIntent().getStringExtra(PanoPlayerActivity.FILE_PATH);
+ Pano360ConfigBundle configBundle= (Pano360ConfigBundle) getIntent().getSerializableExtra(PanoPlayerActivity.CONFIG_BUNDLE);
+ if(configBundle==null){
+ configBundle=Pano360ConfigBundle.newInstance();
+ }
+ configBundle.setRemoveHotspot(true);
GLSurfaceView glSurfaceView=(GLSurfaceView) findViewById(R.id.surface_view);
panoViewWrapper =PanoViewWrapper.with(this)
- .setFilePath(filePath)
+ .setConfig(configBundle)
.setGlSurfaceView(glSurfaceView)
- .setImageMode(false)
- .setPlaneMode(false)
- .init()
- .removeDefaultHotSpot();
+ .init();
glSurfaceView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
diff --git a/pano360demo/src/main/java/com/martin/ads/pano360demo/HomeActivity.java b/pano360demo/src/main/java/com/martin/ads/pano360demo/HomeActivity.java
index 9e427ed..a264273 100644
--- a/pano360demo/src/main/java/com/martin/ads/pano360demo/HomeActivity.java
+++ b/pano360demo/src/main/java/com/martin/ads/pano360demo/HomeActivity.java
@@ -11,7 +11,8 @@
import com.github.rubensousa.viewpagercards.CardItem;
import com.github.rubensousa.viewpagercards.CardPagerAdapter;
import com.github.rubensousa.viewpagercards.ShadowTransformer;
-import com.martin.ads.vrlib.PanoPlayerActivity;
+import com.martin.ads.vrlib.ui.Pano360ConfigBundle;
+import com.martin.ads.vrlib.ui.PanoPlayerActivity;
import com.martin.ads.vrlib.ext.GirlFriendNotFoundException;
import com.nbsp.materialfilepicker.ui.FilePickerActivity;
@@ -25,10 +26,13 @@ public class HomeActivity extends AppCompatActivity {
private ShadowTransformer mCardShadowTransformer;
private CheckBox planeMode;
- private CheckBox windowMode;
- private String filePath="~(~ ̄▽ ̄)~";
private boolean flag;
+ private String filePath="~(~ ̄▽ ̄)~";
+ private String videoHotspotPath;
+ private boolean imageModeEnabled;
+ private boolean planeModeEnabled;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -44,38 +48,32 @@ protected void onCreate(Bundle savedInstanceState) {
mCardAdapter.addCardItem(new CardItem(R.string.title_6, R.string.content_text_6));
planeMode= (CheckBox) findViewById(R.id.plane_mode);
- windowMode = (CheckBox) findViewById(R.id.window_mode);
mCardAdapter.setOnClickCallback(new CardPagerAdapter.OnClickCallback() {
@Override
public void onClick(int position) {
- boolean imageMode=false;
- Intent intent=new Intent();
- intent.setClass(HomeActivity.this, PanoPlayerActivity.class);
- Log.d(TAG, "onClick: "+position);
+ imageModeEnabled=false;
+ videoHotspotPath=null;
switch (position){
case 0:
filePath= "android.resource://" + getPackageName() + "/" + R.raw.demo_video;
break;
case 1:
- intent.setClass(HomeActivity.this, FilePickerActivity.class);
+ Intent intent=new Intent(HomeActivity.this, FilePickerActivity.class);
intent.putExtra(FilePickerActivity.ARG_FILTER, Pattern.compile("(.*\\.mp4$)||(.*\\.avi$)||(.*\\.wmv$)"));
startActivityForResult(intent, 1);
return;
case 2:
filePath="images/vr_cinema.jpg";
- intent.putExtra(PanoPlayerActivity.VIDEO_HOTSPOT_PATH, "android.resource://" + getPackageName() + "/" + R.raw.demo_video);
- imageMode=true;
+ videoHotspotPath="android.resource://" + getPackageName() + "/" + R.raw.demo_video;
+ imageModeEnabled=true;
break;
case 3:
filePath="images/texture_360_n.jpg";
- imageMode=true;
+ imageModeEnabled=true;
break;
case 4:
filePath="http://cache.utovr.com/201508270528174780.m3u8";
- if(windowMode.isChecked()){
- intent.setClass(HomeActivity.this, PlanePlayerActivity.class);
- }
break;
case 5:
if(flag) throw new GirlFriendNotFoundException();
@@ -85,12 +83,8 @@ public void onClick(int position) {
}
return;
}
- intent.putExtra(PanoPlayerActivity.FILE_PATH, filePath);
- intent.putExtra(PanoPlayerActivity.IMAGE_MODE, imageMode);
- intent.putExtra(PanoPlayerActivity.PLANE_MODE, planeMode.isChecked());
- intent.putExtra(PanoPlayerActivity.WINDOW_MODE, windowMode.isChecked());
- intent.putExtra("removeHotspot", false);
- startActivity(intent);
+ planeModeEnabled=planeMode.isChecked();
+ start(true);
}
});
mCardShadowTransformer = new ShadowTransformer(mViewPager, mCardAdapter);
@@ -103,18 +97,30 @@ public void onClick(int position) {
mCardShadowTransformer.enableScaling(true);
}
+ private void start(boolean usingDefaultActivity){
+ Pano360ConfigBundle configBundle=Pano360ConfigBundle
+ .newInstance()
+ .setFilePath(filePath)
+ .setImageModeEnabled(imageModeEnabled)
+ .setPlaneModeEnabled(planeModeEnabled)
+ .setRemoveHotspot(false)
+ .setVideoHotspotPath(videoHotspotPath);
+ if(usingDefaultActivity)
+ configBundle.startEmbeddedActivity(this);
+ else {
+ Intent intent=new Intent(this,DemoWithGLSurfaceView.class);
+ intent.putExtra(PanoPlayerActivity.CONFIG_BUNDLE,configBundle);
+ startActivity(intent);
+ }
+ }
+
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1 && resultCode == RESULT_OK) {
- String filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);
- Intent intent=new Intent(HomeActivity.this,PanoPlayerActivity.class);
- //Intent intent=new Intent(HomeActivity.this,DemoWithGLSurfaceView.class);
- intent.putExtra(PanoPlayerActivity.FILE_PATH, filePath);
- intent.putExtra(PanoPlayerActivity.IMAGE_MODE, false);
- intent.putExtra(PanoPlayerActivity.PLANE_MODE, planeMode.isChecked());
- intent.putExtra("removeHotspot", true);
- startActivity(intent);
+ filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);
+ planeModeEnabled=planeMode.isChecked();
+ start(true);
}
}
diff --git a/pano360demo/src/main/java/com/martin/ads/pano360demo/MainActivity.java b/pano360demo/src/main/java/com/martin/ads/pano360demo/MainActivity.java
deleted file mode 100644
index 562ff4f..0000000
--- a/pano360demo/src/main/java/com/martin/ads/pano360demo/MainActivity.java
+++ /dev/null
@@ -1,138 +0,0 @@
-package com.martin.ads.pano360demo;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.design.widget.FloatingActionButton;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.EditText;
-
-import com.martin.ads.vrlib.PanoPlayerActivity;
-import com.nbsp.materialfilepicker.ui.FilePickerActivity;
-
-import java.util.regex.Pattern;
-
-@Deprecated
-public class MainActivity extends AppCompatActivity {
-
- private Button playURL;
- private Button playDemo;
- private EditText url;
- private CheckBox planeMode;
- private CheckBox windowMode;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main_old);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- planeMode= (CheckBox) findViewById(R.id.plane_mode);
- windowMode = (CheckBox) findViewById(R.id.window_mode);
-
- playURL=(Button)findViewById(R.id.play_url);
- url= (EditText) findViewById(R.id.edit_text_url);
- url.setText("http://cache.utovr.com/201508270528174780.m3u8");
- playURL.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String filePath= url.getText().toString();
- Intent intent = new Intent();
- if(windowMode.isChecked()){
- intent.setClass(MainActivity.this, PlanePlayerActivity.class);
- }else{
- intent.setClass(MainActivity.this, PanoPlayerActivity.class);
- }
- intent.putExtra(PanoPlayerActivity.FILE_PATH, filePath);
- intent.putExtra(PanoPlayerActivity.IMAGE_MODE, false);
- intent.putExtra(PanoPlayerActivity.PLANE_MODE, planeMode.isChecked());
- intent.putExtra(PanoPlayerActivity.WINDOW_MODE, windowMode.isChecked());
- startActivity(intent);
- }
- });
-
- playDemo=(Button)findViewById(R.id.play_local_demo);
- playDemo.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String filePath= "android.resource://" + getPackageName() + "/" + R.raw.demo_video;
- Intent intent=new Intent(MainActivity.this,PanoPlayerActivity.class);
- intent.putExtra(PanoPlayerActivity.FILE_PATH, filePath);
- intent.putExtra(PanoPlayerActivity.IMAGE_MODE, false);
- intent.putExtra(PanoPlayerActivity.PLANE_MODE, planeMode.isChecked());
- startActivity(intent);
- }
- });
-
- findViewById(R.id.play_local_demo_image).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- //...
- String filePath= "android.resource://" + getPackageName() + "/" + R.raw.demo_video;
- Intent intent=new Intent(MainActivity.this,PanoPlayerActivity.class);
- intent.putExtra(PanoPlayerActivity.FILE_PATH, filePath);
- intent.putExtra(PanoPlayerActivity.IMAGE_MODE, true);
- intent.putExtra(PanoPlayerActivity.PLANE_MODE, planeMode.isChecked());
- startActivity(intent);
- }
- });
-
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
-// String filePath= Environment.getExternalStorageDirectory().getPath()+"/360Video/video.mp4";
-// Intent intent=new Intent(HomeActivity.this,PanoPlayerActivity.class);
-// intent.putExtra("videoPath",filePath);
-// startActivity(intent);
-
- Intent intent = new Intent(MainActivity.this, FilePickerActivity.class);
- intent.putExtra(FilePickerActivity.ARG_FILTER, Pattern.compile("(.*\\.mp4$)||(.*\\.avi$)||(.*\\.wmv$)"));
- startActivityForResult(intent, 1);
- }
- });
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.menu_main, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
-
- //noinspection SimplifiableIfStatement
- if (id == R.id.action_settings) {
- return true;
- }
-
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
-
- if (requestCode == 1 && resultCode == RESULT_OK) {
- String filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);
- Intent intent=new Intent(MainActivity.this,PanoPlayerActivity.class);
- //Intent intent=new Intent(HomeActivity.this,DemoWithGLSurfaceView.class);
- intent.putExtra(PanoPlayerActivity.FILE_PATH, filePath);
- intent.putExtra(PanoPlayerActivity.IMAGE_MODE, false);
- intent.putExtra(PanoPlayerActivity.PLANE_MODE, planeMode.isChecked());
- startActivity(intent);
- }
- }
-}
diff --git a/pano360demo/src/main/java/com/martin/ads/pano360demo/PlanePlayerActivity.java b/pano360demo/src/main/java/com/martin/ads/pano360demo/PlanePlayerActivity.java
deleted file mode 100644
index 1d94b55..0000000
--- a/pano360demo/src/main/java/com/martin/ads/pano360demo/PlanePlayerActivity.java
+++ /dev/null
@@ -1,274 +0,0 @@
-package com.martin.ads.pano360demo;
-
-import android.content.pm.ActivityInfo;
-import android.content.res.Configuration;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.opengl.GLSurfaceView;
-import android.os.Bundle;
-import android.os.Handler;
-import android.provider.Settings;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AppCompatActivity;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.Window;
-import android.view.WindowManager;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import com.martin.ads.pano360demo.util.DimenUtils;
-import com.martin.ads.vrlib.PanoMediaPlayerWrapper;
-import com.martin.ads.vrlib.PanoPlayerActivity;
-import com.martin.ads.vrlib.PanoUIController;
-import com.martin.ads.vrlib.PanoViewWrapper;
-import com.martin.ads.vrlib.constant.PanoMode;
-import com.martin.ads.vrlib.constant.PanoStatus;
-import com.martin.ads.vrlib.filters.advanced.FilterType;
-import com.martin.ads.vrlib.utils.UIUtils;
-
-/**
- * Created by zhouyou on 2017/3/2.
- * Class desc:
- */
-public class PlanePlayerActivity extends AppCompatActivity implements View.OnClickListener {
-
- private PanoUIController mPanoUIController;
- private PanoViewWrapper mPanoViewWrapper;
- private RelativeLayout mRltContent;
- private ImageView mImgBufferAnim;
-
- /** 是否是全屏播放 */
- private boolean mIsFullScreen = false;
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
-
- setContentView(R.layout.activity_plane_player);
-
- getContentResolver().registerContentObserver(Settings.System.getUriFor(
- Settings.System.ACCELEROMETER_ROTATION), true, rotationObserver);
-
- init();
- }
-
- private ContentObserver rotationObserver = new ContentObserver(new Handler()) {
- @Override
- public void onChange(boolean selfChange) {
- if (selfChange) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
- }
- }
- };
-
- private void init(){
- String filePath = getIntent().getStringExtra(PanoPlayerActivity.FILE_PATH);
- boolean imageMode = getIntent().getBooleanExtra(PanoPlayerActivity.IMAGE_MODE, false);
- boolean planeMode = getIntent().getBooleanExtra(PanoPlayerActivity.PLANE_MODE, false);
- boolean windowMode = getIntent().getBooleanExtra(PanoPlayerActivity.WINDOW_MODE, false);
-
- ImageView imgFullScreen = (ImageView) findViewById(R.id.img_full_screen);
- imgFullScreen.setVisibility(windowMode ? View.VISIBLE : View.GONE);
- imgFullScreen.setOnClickListener(this);
- mRltContent = (RelativeLayout) findViewById(R.id.rlt_content);
-
- mImgBufferAnim = (ImageView) findViewById(R.id.activity_imgBuffer);
- UIUtils.setBufferVisibility(mImgBufferAnim, !imageMode);
- mPanoUIController = new PanoUIController(
- (RelativeLayout)findViewById(R.id.player_toolbar_control),
- (RelativeLayout)findViewById(R.id.player_toolbar_progress),
- this, imageMode);
-
- TextView title = (TextView) findViewById(R.id.video_title);
- title.setText(Uri.parse(filePath).getLastPathSegment());
-
- GLSurfaceView glSurfaceView = (GLSurfaceView) findViewById(R.id.surface_view);
- mPanoViewWrapper = PanoViewWrapper.with(this)
- .setFilePath(filePath)
- .setGlSurfaceView(glSurfaceView)
- .setImageMode(imageMode)
- .setPlaneMode(planeMode)
- .init();
- glSurfaceView.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- mPanoUIController.startHideControllerTimer();
- return mPanoViewWrapper.handleTouchEvent(event);
- }
- });
- mPanoUIController.setAutoHideController(true);
- mPanoUIController.setUiCallback(new PanoUIController.UICallback() {
- @Override
- public void requestScreenshot() {
- mPanoViewWrapper.getTouchHelper().shotScreen();
- }
-
- @Override
- public void requestFinish() {
- if (mIsFullScreen) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }else{
- finish();
- }
- }
-
- @Override
- public void changeDisPlayMode() {
- if (mPanoViewWrapper.getStatusHelper().getPanoDisPlayMode()== PanoMode.DUAL_SCREEN)
- mPanoViewWrapper.getStatusHelper().setPanoDisPlayMode(PanoMode.SINGLE_SCREEN);
- else mPanoViewWrapper.getStatusHelper().setPanoDisPlayMode(PanoMode.DUAL_SCREEN);
- }
-
- @Override
- public void changeInteractiveMode() {
- if (mPanoViewWrapper.getStatusHelper().getPanoInteractiveMode()== PanoMode.MOTION)
- mPanoViewWrapper.getStatusHelper().setPanoInteractiveMode(PanoMode.TOUCH);
- else mPanoViewWrapper.getStatusHelper().setPanoInteractiveMode(PanoMode.MOTION);
- }
-
- @Override
- public void changePlayingStatus() {
- if (mPanoViewWrapper.getStatusHelper().getPanoStatus()== PanoStatus.PLAYING){
- mPanoViewWrapper.getMediaPlayer().pauseByUser();
- }else if (mPanoViewWrapper.getStatusHelper().getPanoStatus()== PanoStatus.PAUSED_BY_USER){
- mPanoViewWrapper.getMediaPlayer().start();
- }
- }
-
- @Override
- public void playerSeekTo(int pos) {
- mPanoViewWrapper.getMediaPlayer().seekTo(pos);
- }
-
- @Override
- public int getPlayerDuration() {
- return mPanoViewWrapper.getMediaPlayer().getDuration();
- }
-
- @Override
- public int getPlayerCurrentPosition() {
- return mPanoViewWrapper.getMediaPlayer().getCurrentPosition();
- }
-
- @Override
- public void addFilter(FilterType filterType) {
- mPanoViewWrapper.getRenderer().switchFilter();
- }
- });
- mPanoViewWrapper.getTouchHelper().setPanoUIController(mPanoUIController);
-
- if(!imageMode){
- mPanoViewWrapper.getMediaPlayer().setPlayerCallback(new PanoMediaPlayerWrapper.PlayerCallback() {
- @Override
- public void updateProgress() {
- mPanoUIController.updateProgress();
- }
-
- @Override
- public void updateInfo() {
- UIUtils.setBufferVisibility(mImgBufferAnim,false);
- mPanoUIController.startHideControllerTimer();
- mPanoUIController.setInfo();
- }
-
- @Override
- public void requestFinish() {
- if(mIsFullScreen){
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }
- }
- });
- }else mPanoUIController.startHideControllerTimer();
- }
-
- @Override
- protected void onPause(){
- super.onPause();
- mPanoViewWrapper.onPause();
- }
-
- @Override
- protected void onResume(){
- super.onResume();
- mPanoViewWrapper.onResume();
- }
-
- @Override
- protected void onDestroy(){
- super.onDestroy();
- mPanoViewWrapper.releaseResources();
- getContentResolver().unregisterContentObserver(rotationObserver);
- }
-
- @Override
- public void onClick(View view) {
- switch (view.getId()){
- case R.id.img_full_screen:
- if (!mIsFullScreen) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }
- break;
- }
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
- setFullScreenPlay();
- } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
- setWindowScreenPlay();
- }
- }
-
- private void setFullScreenPlay(){
- mIsFullScreen = true;
-
- // 设置全屏即隐藏状态栏
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
-
- // 设置视频充满全屏
- LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mRltContent.getLayoutParams();
- layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
- layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
- mRltContent.setLayoutParams(layoutParams);
- }
-
- private void setWindowScreenPlay(){
- mIsFullScreen = false;
-
- // 恢复状态栏
- WindowManager.LayoutParams attrs = getWindow().getAttributes();
- attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
- getWindow().setAttributes(attrs);
- getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
-
- // 设置显示视频固定大小
- LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mRltContent.getLayoutParams();
- layoutParams.height = DimenUtils.dp2px(this, 230);
- layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
- mRltContent.setLayoutParams(layoutParams);
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if(keyCode == KeyEvent.KEYCODE_BACK){
- if (mIsFullScreen) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- return true;
- }
- }
- return super.onKeyDown(keyCode, event);
- }
-}
diff --git a/pano360demo/src/main/res/layout/activity_main.xml b/pano360demo/src/main/res/layout/activity_main.xml
index 70dad92..4e62e29 100644
--- a/pano360demo/src/main/res/layout/activity_main.xml
+++ b/pano360demo/src/main/res/layout/activity_main.xml
@@ -51,11 +51,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/plane_mode" />
-
diff --git a/pano360demo/src/main/res/layout/activity_main_old.xml b/pano360demo/src/main/res/layout/activity_main_old.xml
deleted file mode 100644
index e1f4942..0000000
--- a/pano360demo/src/main/res/layout/activity_main_old.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pano360demo/src/main/res/layout/activity_plane_player.xml b/pano360demo/src/main/res/layout/activity_plane_player.xml
deleted file mode 100644
index 09c98e6..0000000
--- a/pano360demo/src/main/res/layout/activity_plane_player.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/pano360demo/src/main/res/layout/adapter.xml b/pano360demo/src/main/res/layout/adapter.xml
index caffd6d..8ebc59b 100644
--- a/pano360demo/src/main/res/layout/adapter.xml
+++ b/pano360demo/src/main/res/layout/adapter.xml
@@ -10,8 +10,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/vrlib/build.gradle b/vrlib/build.gradle
index dccbc96..f4f1701 100644
--- a/vrlib/build.gradle
+++ b/vrlib/build.gradle
@@ -8,7 +8,7 @@ android {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
- versionName "1.1"
+ versionName "1.1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
diff --git a/vrlib/src/main/AndroidManifest.xml b/vrlib/src/main/AndroidManifest.xml
index fbfdd53..54fd724 100644
--- a/vrlib/src/main/AndroidManifest.xml
+++ b/vrlib/src/main/AndroidManifest.xml
@@ -7,7 +7,7 @@
-
diff --git a/vrlib/src/main/java/com/martin/ads/vrlib/PanoViewWrapper.java b/vrlib/src/main/java/com/martin/ads/vrlib/PanoViewWrapper.java
index d9ac9f6..9b8e5d2 100644
--- a/vrlib/src/main/java/com/martin/ads/vrlib/PanoViewWrapper.java
+++ b/vrlib/src/main/java/com/martin/ads/vrlib/PanoViewWrapper.java
@@ -16,6 +16,7 @@
import com.martin.ads.vrlib.filters.vr.ImageHotspot;
import com.martin.ads.vrlib.filters.vr.VideoHotspot;
import com.martin.ads.vrlib.math.PositionOrientation;
+import com.martin.ads.vrlib.ui.Pano360ConfigBundle;
import com.martin.ads.vrlib.utils.StatusHelper;
import com.martin.ads.vrlib.utils.TextImageGenerator;
@@ -50,6 +51,14 @@ public PanoViewWrapper init(){
return this;
}
+ public PanoViewWrapper setConfig(Pano360ConfigBundle configBundle){
+ filePath=configBundle.getFilePath();
+ videoHotspotPath=configBundle.getVideoHotspotPath();
+ planeMode=configBundle.isPlaneModeEnabled();
+ imageMode=configBundle.isImageModeEnabled();
+ return this;
+ }
+
private void init(Context context, Uri uri){
glSurfaceView.setEGLContextClientVersion(2);
@@ -197,31 +206,11 @@ public TouchHelper getTouchHelper() {
return touchHelper;
}
- public PanoViewWrapper setImageMode(boolean imageMode) {
- this.imageMode = imageMode;
- return this;
- }
-
- public PanoViewWrapper setPlaneMode(boolean planeMode) {
- this.planeMode = planeMode;
- return this;
- }
-
public PanoViewWrapper setGlSurfaceView(GLSurfaceView glSurfaceView) {
this.glSurfaceView = glSurfaceView;
return this;
}
- public PanoViewWrapper setFilePath(String filePath) {
- this.filePath = filePath;
- return this;
- }
-
- public PanoViewWrapper setVideoHotspotPath(String videoHotspotPath) {
- this.videoHotspotPath = videoHotspotPath;
- return this;
- }
-
public boolean clearHotSpot(){
if(hotspotList ==null) return false;
hotspotList.clear();
diff --git a/vrlib/src/main/java/com/martin/ads/vrlib/TouchHelper.java b/vrlib/src/main/java/com/martin/ads/vrlib/TouchHelper.java
index 290ba85..87f1320 100644
--- a/vrlib/src/main/java/com/martin/ads/vrlib/TouchHelper.java
+++ b/vrlib/src/main/java/com/martin/ads/vrlib/TouchHelper.java
@@ -1,15 +1,12 @@
package com.martin.ads.vrlib;
import android.content.res.Resources;
-import android.opengl.GLSurfaceView;
-import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
-import android.widget.Toast;
import com.martin.ads.vrlib.constant.PanoMode;
-import com.martin.ads.vrlib.utils.BitmapUtils;
+import com.martin.ads.vrlib.ui.PanoUIController;
import com.martin.ads.vrlib.utils.StatusHelper;
/**
diff --git a/vrlib/src/main/java/com/martin/ads/vrlib/ui/Pano360ConfigBundle.java b/vrlib/src/main/java/com/martin/ads/vrlib/ui/Pano360ConfigBundle.java
new file mode 100644
index 0000000..3e08a70
--- /dev/null
+++ b/vrlib/src/main/java/com/martin/ads/vrlib/ui/Pano360ConfigBundle.java
@@ -0,0 +1,87 @@
+package com.martin.ads.vrlib.ui;
+
+import android.content.Context;
+import android.content.Intent;
+
+import java.io.Serializable;
+
+/**
+ * Created by Ads on 2017/4/12.
+ */
+
+public class Pano360ConfigBundle implements Serializable{
+ private String filePath;
+ private String videoHotspotPath;
+ private boolean imageModeEnabled;
+ private boolean planeModeEnabled;
+ private boolean windowModeEnabled;
+ private boolean removeHotspot;
+
+ public Pano360ConfigBundle() {
+ filePath=null;
+ videoHotspotPath=null;
+ imageModeEnabled=false;
+ planeModeEnabled=false;
+ windowModeEnabled=false;
+ removeHotspot=false;
+ }
+
+ public static Pano360ConfigBundle newInstance(){
+ return new Pano360ConfigBundle();
+ }
+
+ public void startEmbeddedActivity(Context context){
+ Intent intent=new Intent(context,PanoPlayerActivity.class);
+ intent.putExtra(PanoPlayerActivity.CONFIG_BUNDLE,this);
+ context.startActivity(intent);
+ }
+
+ public String getFilePath() {
+ return filePath;
+ }
+
+ public Pano360ConfigBundle setFilePath(String filePath) {
+ this.filePath = filePath;
+ return this;
+ }
+
+ public String getVideoHotspotPath() {
+ return videoHotspotPath;
+ }
+
+ public Pano360ConfigBundle setVideoHotspotPath(String videoHotspotPath) {
+ this.videoHotspotPath = videoHotspotPath;
+ return this;
+ }
+
+ public boolean isImageModeEnabled() {
+ return imageModeEnabled;
+ }
+
+ public Pano360ConfigBundle setImageModeEnabled(boolean imageModeEnabled) {
+ this.imageModeEnabled = imageModeEnabled;
+ return this;
+ }
+
+ public boolean isPlaneModeEnabled() {
+ return planeModeEnabled;
+ }
+
+ public Pano360ConfigBundle setPlaneModeEnabled(boolean planeModeEnabled) {
+ this.planeModeEnabled = planeModeEnabled;
+ return this;
+ }
+
+ public boolean isWindowModeEnabled() {
+ return windowModeEnabled;
+ }
+
+ public boolean isRemoveHotspot() {
+ return removeHotspot;
+ }
+
+ public Pano360ConfigBundle setRemoveHotspot(boolean removeHotspot) {
+ this.removeHotspot = removeHotspot;
+ return this;
+ }
+}
diff --git a/vrlib/src/main/java/com/martin/ads/vrlib/PanoPlayerActivity.java b/vrlib/src/main/java/com/martin/ads/vrlib/ui/PanoPlayerActivity.java
similarity index 80%
rename from vrlib/src/main/java/com/martin/ads/vrlib/PanoPlayerActivity.java
rename to vrlib/src/main/java/com/martin/ads/vrlib/ui/PanoPlayerActivity.java
index 58df65d..20b44ff 100644
--- a/vrlib/src/main/java/com/martin/ads/vrlib/PanoPlayerActivity.java
+++ b/vrlib/src/main/java/com/martin/ads/vrlib/ui/PanoPlayerActivity.java
@@ -1,4 +1,4 @@
-package com.martin.ads.vrlib;
+package com.martin.ads.vrlib.ui;
import android.app.Activity;
import android.content.pm.ActivityInfo;
@@ -12,6 +12,9 @@
import android.widget.RelativeLayout;
import android.widget.TextView;
+import com.martin.ads.vrlib.PanoMediaPlayerWrapper;
+import com.martin.ads.vrlib.PanoViewWrapper;
+import com.martin.ads.vrlib.R;
import com.martin.ads.vrlib.constant.PanoMode;
import com.martin.ads.vrlib.constant.PanoStatus;
import com.martin.ads.vrlib.filters.advanced.FilterType;
@@ -24,15 +27,12 @@
//FIXME:looks so lame.
public class PanoPlayerActivity extends Activity {
- public static final String FILE_PATH = "filePath";
- public static final String VIDEO_HOTSPOT_PATH = "videoHotspotPath";
- public static final String IMAGE_MODE = "imageMode";
- public static final String PLANE_MODE = "planeMode";
- public static final String WINDOW_MODE = "windowMode";
+ public static final String CONFIG_BUNDLE = "configBundle";
private PanoUIController mPanoUIController;
private PanoViewWrapper mPanoViewWrapper;
private ImageView mImgBufferAnim;
+ private Pano360ConfigBundle configBundle;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -48,35 +48,30 @@ protected void onCreate(Bundle savedInstanceState) {
}
private void init(){
- //TODO: consider using a builder
- String filePath = getIntent().getStringExtra(FILE_PATH);
- String videoHotspotPath = getIntent().getStringExtra(VIDEO_HOTSPOT_PATH);
- boolean imageMode = getIntent().getBooleanExtra(IMAGE_MODE, false);
- boolean planeMode = getIntent().getBooleanExtra(PLANE_MODE, false);
- boolean windowMode = getIntent().getBooleanExtra(WINDOW_MODE, false);
+ configBundle= (Pano360ConfigBundle) getIntent().getSerializableExtra(CONFIG_BUNDLE);
+ if(configBundle==null){
+ configBundle=Pano360ConfigBundle.newInstance();
+ }
- findViewById(R.id.img_full_screen).setVisibility(windowMode ? View.VISIBLE : View.GONE);
+ findViewById(R.id.img_full_screen).setVisibility(configBundle.isWindowModeEnabled() ? View.VISIBLE : View.GONE);
mImgBufferAnim = (ImageView) findViewById(R.id.activity_imgBuffer);
- UIUtils.setBufferVisibility(mImgBufferAnim, !imageMode);
+ UIUtils.setBufferVisibility(mImgBufferAnim, !configBundle.isImageModeEnabled());
mPanoUIController = new PanoUIController(
(RelativeLayout)findViewById(R.id.player_toolbar_control),
(RelativeLayout)findViewById(R.id.player_toolbar_progress),
- this, imageMode);
+ this, configBundle.isImageModeEnabled());
TextView title = (TextView) findViewById(R.id.video_title);
- title.setText(Uri.parse(filePath).getLastPathSegment());
+ title.setText(Uri.parse(configBundle.getFilePath()).getLastPathSegment());
GLSurfaceView glSurfaceView = (GLSurfaceView) findViewById(R.id.surface_view);
- boolean removeHotspot=getIntent().getBooleanExtra("removeHotspot",false);
mPanoViewWrapper = PanoViewWrapper.with(this)
- .setFilePath(filePath)
+ .setConfig(configBundle)
.setGlSurfaceView(glSurfaceView)
- .setImageMode(imageMode)
- .setPlaneMode(planeMode)
- .setVideoHotspotPath(videoHotspotPath)
.init();
- if(removeHotspot) mPanoViewWrapper.removeDefaultHotSpot();
+ if(configBundle.isRemoveHotspot())
+ mPanoViewWrapper.removeDefaultHotSpot();
glSurfaceView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
@@ -141,7 +136,7 @@ public void addFilter(FilterType filterType) {
});
mPanoViewWrapper.getTouchHelper().setPanoUIController(mPanoUIController);
- if(!imageMode){
+ if(!configBundle.isImageModeEnabled()){
mPanoViewWrapper.getMediaPlayer().setPlayerCallback(new PanoMediaPlayerWrapper.PlayerCallback() {
@Override
public void updateProgress() {
diff --git a/vrlib/src/main/java/com/martin/ads/vrlib/PanoUIController.java b/vrlib/src/main/java/com/martin/ads/vrlib/ui/PanoUIController.java
similarity index 99%
rename from vrlib/src/main/java/com/martin/ads/vrlib/PanoUIController.java
rename to vrlib/src/main/java/com/martin/ads/vrlib/ui/PanoUIController.java
index 45fb002..dac8cdc 100644
--- a/vrlib/src/main/java/com/martin/ads/vrlib/PanoUIController.java
+++ b/vrlib/src/main/java/com/martin/ads/vrlib/ui/PanoUIController.java
@@ -1,4 +1,4 @@
-package com.martin.ads.vrlib;
+package com.martin.ads.vrlib.ui;
import android.app.Activity;
import android.content.Context;
@@ -11,6 +11,7 @@
import android.widget.TextView;
import android.widget.ToggleButton;
+import com.martin.ads.vrlib.R;
import com.martin.ads.vrlib.filters.advanced.FilterType;
import com.martin.ads.vrlib.utils.UIUtils;