diff --git a/README.en.md b/README.en.md index cd52f17..28e3cb3 100644 --- a/README.en.md +++ b/README.en.md @@ -38,7 +38,7 @@ Pure Java library to play 360 degree panorama video (VR video) on Android. Using * Start an `Activity` provided by library ```java Intent intent=new Intent(MainActivity.this,PanoPlayerActivity.class); -intent.putExtra("videoPath",filePath); +intent.putExtra("filePath",filePath); startActivity(intent); ``` @@ -51,7 +51,12 @@ startActivity(intent); ``` ```java GLSurfaceView glSurfaceView=(GLSurfaceView) findViewById(R.id.surface_view); -panoViewWrapper =new PanoViewWrapper(this,videoPath, glSurfaceView); +panoViewWrapper =PanoViewWrapper.with(this) + .setVideoPath(filePath) + .setGlSurfaceView(glSurfaceView) + .setImageMode(false) + .setPlaneMode(false) + .init(); glSurfaceView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { diff --git a/README.md b/README.md index bff1b3d..3d8906f 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Pano 360 是一个Android平台下纯Java的全景(360度/VR)视频播放库 * 使用带播放控制的`Activity` (由类库提供) ```java Intent intent=new Intent(MainActivity.this,PanoPlayerActivity.class); -intent.putExtra("videoPath",filePath); +intent.putExtra("filePath",filePath); startActivity(intent); ``` @@ -58,7 +58,12 @@ startActivity(intent); ``` ```java GLSurfaceView glSurfaceView=(GLSurfaceView) findViewById(R.id.surface_view); -panoViewWrapper =new PanoViewWrapper(this,videoPath, glSurfaceView); +panoViewWrapper =PanoViewWrapper.with(this) + .setVideoPath(filePath) + .setGlSurfaceView(glSurfaceView) + .setImageMode(false) + .setPlaneMode(false) + .init(); glSurfaceView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { diff --git a/pano360demo/pano360demo-release.apk b/pano360demo/pano360demo-release.apk index a55712a..1163279 100644 Binary files a/pano360demo/pano360demo-release.apk and b/pano360demo/pano360demo-release.apk differ 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 85d6097..89bcff9 100644 --- a/pano360demo/src/main/java/com/martin/ads/pano360demo/DemoWithGLSurfaceView.java +++ b/pano360demo/src/main/java/com/martin/ads/pano360demo/DemoWithGLSurfaceView.java @@ -8,6 +8,7 @@ import android.view.View; import android.view.WindowManager; +import com.martin.ads.vrlib.PanoPlayerActivity; import com.martin.ads.vrlib.PanoViewWrapper; /** @@ -34,14 +35,15 @@ protected void onCreate(Bundle savedInstanceState) { private void init(){ - String videoPath=getIntent().getStringExtra("videoPath"); + String filePath=getIntent().getStringExtra(PanoPlayerActivity.FILE_PATH); GLSurfaceView glSurfaceView=(GLSurfaceView) findViewById(R.id.surface_view); panoViewWrapper =PanoViewWrapper.with(this) - .setVideoPath(videoPath) + .setFilePath(filePath) .setGlSurfaceView(glSurfaceView) .setImageMode(false) .setPlaneMode(false) - .init(); + .init() + .removeDefaultHotSpot(); glSurfaceView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { @@ -60,7 +62,6 @@ protected void onPause(){ @Override protected void onResume(){ super.onResume(); - panoViewWrapper.onResume(); } 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 77ab396..6fb0044 100644 --- a/pano360demo/src/main/java/com/martin/ads/pano360demo/HomeActivity.java +++ b/pano360demo/src/main/java/com/martin/ads/pano360demo/HomeActivity.java @@ -26,7 +26,7 @@ public class HomeActivity extends AppCompatActivity { private CheckBox planeMode; private CheckBox windowMode; - private String filePath="= ="; + private String filePath="~(~ ̄▽ ̄)~"; private boolean flag; @Override @@ -62,6 +62,7 @@ public void onClick(int position) { startActivityForResult(intent, 1); return; case 2: + filePath="images/texture_360_n.jpg"; imageMode=true; break; case 3: @@ -78,10 +79,11 @@ public void onClick(int position) { } return; } - intent.putExtra(PanoPlayerActivity.VIDEO_PATH, filePath); + 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); } }); @@ -102,9 +104,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { 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.VIDEO_PATH, filePath); + 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); } } diff --git a/pano360demo/src/main/java/com/martin/ads/pano360demo/MainActivity.java b/pano360demo/src/main/java/com/martin/ads/pano360demo/MainActivity.java index d45dce4..562ff4f 100644 --- a/pano360demo/src/main/java/com/martin/ads/pano360demo/MainActivity.java +++ b/pano360demo/src/main/java/com/martin/ads/pano360demo/MainActivity.java @@ -49,7 +49,7 @@ public void onClick(View v) { }else{ intent.setClass(MainActivity.this, PanoPlayerActivity.class); } - intent.putExtra(PanoPlayerActivity.VIDEO_PATH, filePath); + 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()); @@ -63,7 +63,7 @@ public void onClick(View v) { 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.VIDEO_PATH, filePath); + intent.putExtra(PanoPlayerActivity.FILE_PATH, filePath); intent.putExtra(PanoPlayerActivity.IMAGE_MODE, false); intent.putExtra(PanoPlayerActivity.PLANE_MODE, planeMode.isChecked()); startActivity(intent); @@ -76,7 +76,7 @@ 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.VIDEO_PATH, filePath); + intent.putExtra(PanoPlayerActivity.FILE_PATH, filePath); intent.putExtra(PanoPlayerActivity.IMAGE_MODE, true); intent.putExtra(PanoPlayerActivity.PLANE_MODE, planeMode.isChecked()); startActivity(intent); @@ -129,7 +129,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { 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.VIDEO_PATH, filePath); + 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 index 726425f..1d94b55 100644 --- a/pano360demo/src/main/java/com/martin/ads/pano360demo/PlanePlayerActivity.java +++ b/pano360demo/src/main/java/com/martin/ads/pano360demo/PlanePlayerActivity.java @@ -70,7 +70,7 @@ public void onChange(boolean selfChange) { }; private void init(){ - String videoPath = getIntent().getStringExtra(PanoPlayerActivity.VIDEO_PATH); + 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); @@ -88,11 +88,11 @@ private void init(){ this, imageMode); TextView title = (TextView) findViewById(R.id.video_title); - title.setText(Uri.parse(videoPath).getLastPathSegment()); + title.setText(Uri.parse(filePath).getLastPathSegment()); GLSurfaceView glSurfaceView = (GLSurfaceView) findViewById(R.id.surface_view); mPanoViewWrapper = PanoViewWrapper.with(this) - .setVideoPath(videoPath) + .setFilePath(filePath) .setGlSurfaceView(glSurfaceView) .setImageMode(imageMode) .setPlaneMode(planeMode) diff --git a/pano360demo/src/main/res/layout/activity_main.xml b/pano360demo/src/main/res/layout/activity_main.xml index eb1e9ca..70dad92 100644 --- a/pano360demo/src/main/res/layout/activity_main.xml +++ b/pano360demo/src/main/res/layout/activity_main.xml @@ -47,7 +47,7 @@ android:background="#66A9F4" android:orientation="horizontal"> diff --git a/vrlib/src/main/java/com/martin/ads/vrlib/PanoPlayerActivity.java b/vrlib/src/main/java/com/martin/ads/vrlib/PanoPlayerActivity.java index f2e50ab..05b410b 100644 --- a/vrlib/src/main/java/com/martin/ads/vrlib/PanoPlayerActivity.java +++ b/vrlib/src/main/java/com/martin/ads/vrlib/PanoPlayerActivity.java @@ -24,7 +24,7 @@ //FIXME:looks so lame. public class PanoPlayerActivity extends Activity { - public static final String VIDEO_PATH = "videoPath"; + public static final String FILE_PATH = "filePath"; public static final String IMAGE_MODE = "imageMode"; public static final String PLANE_MODE = "planeMode"; public static final String WINDOW_MODE = "windowMode"; @@ -47,7 +47,7 @@ protected void onCreate(Bundle savedInstanceState) { } private void init(){ - String videoPath = getIntent().getStringExtra(VIDEO_PATH); + String filePath = getIntent().getStringExtra(FILE_PATH); boolean imageMode = getIntent().getBooleanExtra(IMAGE_MODE, false); boolean planeMode = getIntent().getBooleanExtra(PLANE_MODE, false); boolean windowMode = getIntent().getBooleanExtra(WINDOW_MODE, false); @@ -62,15 +62,17 @@ private void init(){ this, imageMode); TextView title = (TextView) findViewById(R.id.video_title); - title.setText(Uri.parse(videoPath).getLastPathSegment()); + title.setText(Uri.parse(filePath).getLastPathSegment()); GLSurfaceView glSurfaceView = (GLSurfaceView) findViewById(R.id.surface_view); + boolean removeHotspot=getIntent().getBooleanExtra("removeHotspot",false); mPanoViewWrapper = PanoViewWrapper.with(this) - .setVideoPath(videoPath) + .setFilePath(filePath) .setGlSurfaceView(glSurfaceView) .setImageMode(imageMode) .setPlaneMode(planeMode) .init(); + if(removeHotspot) mPanoViewWrapper.removeDefaultHotSpot(); glSurfaceView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { diff --git a/vrlib/src/main/java/com/martin/ads/vrlib/PanoRender.java b/vrlib/src/main/java/com/martin/ads/vrlib/PanoRender.java index df990f6..6755345 100644 --- a/vrlib/src/main/java/com/martin/ads/vrlib/PanoRender.java +++ b/vrlib/src/main/java/com/martin/ads/vrlib/PanoRender.java @@ -42,6 +42,8 @@ public class PanoRender private OrthoFilter orthoFilter; private FilterGroup customizedFilters; + private String filePath; + private PanoRender() { } @@ -56,8 +58,7 @@ public PanoRender init(){ }else{ firstPassFilter=new DrawImageFilter( statusHelper.getContext(), - //TODO: where is my UI????? - "images/texture_360_n.jpg", + filePath, AdjustingMode.ADJUSTING_MODE_STRETCH); } filterGroup.addFilter(firstPassFilter); @@ -167,6 +168,11 @@ public PanoRender setFilterMode(int filterMode) { return this; } + public PanoRender setFilePath(String filePath) { + this.filePath = filePath; + return this; + } + public static PanoRender newInstance(){ return new PanoRender(); } 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 2c4b5a0..6fdd8d1 100644 --- a/vrlib/src/main/java/com/martin/ads/vrlib/PanoViewWrapper.java +++ b/vrlib/src/main/java/com/martin/ads/vrlib/PanoViewWrapper.java @@ -4,6 +4,7 @@ import android.net.Uri; import android.opengl.GLSurfaceView; import android.os.Build; +import android.util.Log; import android.view.MotionEvent; import com.martin.ads.vrlib.constant.PanoMode; @@ -24,14 +25,14 @@ public class PanoViewWrapper { private boolean planeMode; private Context context; - private String videoPath; + private String filePath; private PanoViewWrapper(Context context) { this.context=context; } public PanoViewWrapper init(){ - Uri uri=Uri.parse(videoPath); + Uri uri=Uri.parse(filePath); init(context,uri); return this; } @@ -62,6 +63,7 @@ public void renderImmediately() { .setPanoMediaPlayerWrapper(mPnoVideoPlayer) .setImageMode(imageMode) .setPlaneMode(planeMode) + .setFilePath(uri.toString()) .setFilterMode(PanoRender.FILTER_MODE_AFTER_PROJECTION) .init(); @@ -147,8 +149,15 @@ public PanoViewWrapper setGlSurfaceView(GLSurfaceView glSurfaceView) { return this; } - public PanoViewWrapper setVideoPath(String videoPath) { - this.videoPath = videoPath; + public PanoViewWrapper setFilePath(String filePath) { + this.filePath = filePath; + return this; + } + + //TODO:add real interface to control hot spot + // & head pose control + public PanoViewWrapper removeDefaultHotSpot(){ + getRenderer().getSpherePlugin().clearHotSpot(); return this; }