android vr商品,GitHub - kaltura/playkit-android-vr

68747470733a2f2f7472617669732d63692e6f72672f6b616c747572612f706c61796b69742d616e64726f69642d76722e7376673f6272616e63683d646576656c6f70

68747470733a2f2f696d672e736869656c64732e696f2f6d6176656e2d63656e7472616c2f762f636f6d2e6b616c747572612e706c61796b69742f7672706c7567696e3f6c6162656c3d446f776e6c6f6164

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4147504c76332d626c61636b2e737667

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d616e64726f69642d677265656e2e737667

playkit-android-vr

About Kaltura VR

The VR module gives ability to play VR and 360 streams

based on the MD360Player4Android having the same playkit player API

VR Integration

VR Module is build on top of the Kaltura Playkit SDK; therefore, to get started, you'll need to add dependencies in your application build.gradle file.

dependencies {

implementation 'com.kaltura:playkit-android-vr:XXX' //instead of XXX use latest version.

}

repositories {

maven { url 'https://jitpack.io' }

}

Next, lets see how to use the VR Module in your application.

There are 2 possibilites to Generate PKMeidaEntry

Using Providers (OVP/Phoenix)

Creating it manualy

VR Module can work in 2 Modes 360 Player or Cardbord Player Mode

for each mode application can cofigure the IntractionMode for each Player.

The default InteractionMode is VRInteractionMode.Touch

public enum VRInteractionMode {

Motion, //360 Player

Touch, //360 Player

MotionWithTouch, //360 Player

CardboardMotion, //Cardbord Player

CardboardMotionWithTouch //Cardbord Player

}

Using Providers:

in case the media entry is generated using the Providers if 360 meida was requested the callback of the provider will create a VRPKMediaEntry instead of

the PKMediaEntry that is created for regular media.

The VRPKMediaEntry will be created with default VRSettings which application can set again or to change specific value using setter methods.

//define app VR configuration

((VRPKMediaEntry) vrMediaEntry).getVrSettings().setVrModeEnabled(isVrModeEnabled());

((VRPKMediaEntry) vrMediaEntry).getVrSettings().setFlingEnabled(isFlingEnabled());

((VRPKMediaEntry) vrMediaEntry).getVrSettings().setInteractionMode(getInteractionMode());

((VRPKMediaEntry) vrMediaEntry).getVrSettings().setZoomWithPinchEnabled(isZoomWithPinchEnabled());

Manual Creation:

//define app VR configuration

VRSettings vrSettings = new VRSettings()

.setVrModeEnabled(isVrModeEnabled())

.setFlingEnabled(isFlingEnabled())

.setInteractionMode(VRInteractionMode.MotionWithTouch)

.setZoomWithPinchEnabled(isZoomWithPinchEnabled());

PKMediaEntry vrMediaEntry = new VRPKMediaEntry().setVRParams(vrSettings);

//Set additional data for the entry.

vrMediaEntry.setId("entryId");

vrMediaEntry.setMediaType(PKMediaEntry.MediaEntryType.Vod);

List mediaSources = createMediaSources();

vrMediaEntry.setSources(mediaSources);```

VR Controller

Once Player is set there are several operartions that can control the VR Module behaviour:

public interface VRController extends PKController {

/**

* When set to true, will split screen in a way that fit to cardboard devices.

* When set to false, content will be displayed in an ordinary 360 way.

* @param shouldEnable - if enable VRMode.

*/

void enableVRMode(boolean shouldEnable);

/**

* When set to true, will allow some continiues motion effect when surface is swiped.

* If disabled, motion will stop whenever MotionEvent.ACTION_UP/MotionEvent.ACTION_CANCEL detected.

* @param shouldEnable - if enable this.

*/

void setFlingEnabled(boolean shouldEnable);

/**

* Set the Interaction mode with 360/VR surface.

* Before applying, application must check if requested mode is supported by the device.

* @param mode - requested mode.

*/

void setInteractionMode(VRInteractionMode mode);

/**

* Allows to enable zooming of the surface with pinch motion.

* @param shouldEnable - if this should be enabled.

*/

void setZoomWithPinchEnabled(boolean shouldEnable);

/**

* Set clickListener on the 360/VR surface. When application wants to detect

* click input on the 360/VR surface it is required to pass it here instead of

* just attaching it to the containerView.

* @param onClickListener - View.ClickListener

*/

void setOnClickListener(View.OnClickListener onClickListener);

/**

* @return - true if in vr mode. otherwise false.

*/

boolean isVRModeEnabled();

/**

* @return - true if pinch is enabled.

*/

boolean isPinchEnabled();

/**

* @return - true if enabled.

*/

boolean isFlingEnabled();

/**

*

* @return - current interaction mode.

*/

VRInteractionMode getInteractionMode();

}

Getting access to the controller

VRController vrController = mPlayer.getController(VRController.class);

Validating Mode Change is supported by device.

Before applying InteractionMode(no matter if by calling api setInteractionMode() or change in in VRSettings setInteractionMode()) you should first check if this mode is supported by the device. In some cases device hardware does not support requested mode(for example InteractionMode.Motion not supported for devices without Gyro)

boolean modeSupported = VRUtil.isModeSupported(context, VRInteractionMode.CardboardMotion);

if (modeSupported) {

vrController.setInteractionMode(VRInteractionMode.CardboardMotion);

}

Example - Change The VR Mode During Playback:

case TOGGLE_VR:

VRController vrController = mPlayer.getController(VRController.class);

boolean currentState = vrController.isVRModeEnabled();

vrController.enableVRMode(!currentState);

break;

}

Example - Listen to clicks on surface

App must pass the click listener via the controller

VRController vrController = mPlayer.getController(VRController.class);

mPlayerControlsView.setVrIconVisibility(true); mPlayerControlsView.setVRActivated(vrController.isVRModeEnabled());

vrController.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

//application code for handaling ui operations

handleContainerClick();

}

});

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值