Skip to content

Commit

Permalink
Update Interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin20150405 committed Apr 7, 2017
1 parent 5ca8b6f commit 908a3f4
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 29 deletions.
9 changes: 7 additions & 2 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```

Expand All @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```

Expand All @@ -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) {
Expand Down
Binary file modified pano360demo/pano360demo-release.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.view.View;
import android.view.WindowManager;

import com.martin.ads.vrlib.PanoPlayerActivity;
import com.martin.ads.vrlib.PanoViewWrapper;

/**
Expand All @@ -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) {
Expand All @@ -60,7 +62,6 @@ protected void onPause(){
@Override
protected void onResume(){
super.onResume();

panoViewWrapper.onResume();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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);
}
});
Expand All @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pano360demo/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
android:background="#66A9F4"
android:orientation="horizontal">
<CheckBox
android:text="Plane Video"
android:text="Plane Mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/plane_mode" />
Expand Down
10 changes: 6 additions & 4 deletions vrlib/src/main/java/com/martin/ads/vrlib/PanoPlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
Expand All @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions vrlib/src/main/java/com/martin/ads/vrlib/PanoRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class PanoRender
private OrthoFilter orthoFilter;
private FilterGroup customizedFilters;

private String filePath;

private PanoRender() {

}
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down
17 changes: 13 additions & 4 deletions vrlib/src/main/java/com/martin/ads/vrlib/PanoViewWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -62,6 +63,7 @@ public void renderImmediately() {
.setPanoMediaPlayerWrapper(mPnoVideoPlayer)
.setImageMode(imageMode)
.setPlaneMode(planeMode)
.setFilePath(uri.toString())
.setFilterMode(PanoRender.FILTER_MODE_AFTER_PROJECTION)
.init();

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 908a3f4

Please sign in to comment.