Google VR SDK-cardborad 播放vr视频-Android



废话不多说,直接上代码

package com.google.vr.sdk.samples.simplevideowidget;

import com.google.vr.sdk.widgets.video.VrVideoEventListener;
import com.google.vr.sdk.widgets.video.VrVideoView;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;

import java.io.IOException;

/**
 * A test activity that renders a 360 video using {@link VrVideoView}.
 * It loads the video in the assets by default. User can use it to load any video files using the
 * command:
 *   adb shell am start -a android.intent.action.VIEW \
 *     -n com.google.vr.sdk.samples.simplevideowidget/.SimpleVrVideoActivity
 *     -d file://sdcard/FILENAME.MP4
 */
public class SimpleVrVideoActivity extends Activity {
  private static final String TAG = SimpleVrVideoActivity.class.getSimpleName();

  /**
   * Preserve the video's state when rotating the phone.
   */
  private static final String STATE_IS_PAUSED = "isPaused";
  private static final String STATE_PROGRESS_TIME = "progressTime";
  /**
   * The video duration doesn't need to be preserved, but it is saved in this example. This allows
   * the seekBar to be configured during {@link #onRestoreInstanceState(Bundle)} rather than waiting
   * for the video to be reloaded and analyzed. This avoid UI jank.
   */
  private static final String STATE_VIDEO_DURATION = "videoDuration";

  /**
   * Arbitrary constants and variable to track load status. In this example, this variable should
   * only be accessed on the UI thread. In a real app, this variable would be code that performs
   * some UI actions when the video is fully loaded.
   */
  public static final int LOAD_VIDEO_STATUS_UNKNOWN = 0;
  public static final int LOAD_VIDEO_STATUS_SUCCESS = 1;
  public static final int LOAD_VIDEO_STATUS_ERROR = 2;

  private int loadVideoStatus = LOAD_VIDEO_STATUS_UNKNOWN;

  public int getLoadVideoStatus() {
    return loadVideoStatus;
  }

  /** Tracks the file to be loaded across the lifetime of this app. **/
  private Uri fileUri;
  private VideoLoaderTask backgroundVideoLoaderTask;

  /**
   * The video view and its custom UI elements.
   */
  private VrVideoView videoWidgetView;

  /**
   * Seeking UI & progress indicator. The seekBar's progress value represents milliseconds in the
   * video.
   */
  private SeekBar seekBar;
  private TextView statusText;

  /**
   * By default, the video will start playing as soon as it is loaded. This can be changed by using
   * {@link VrVideoView#pauseVideo()} after loading the video.
   */
  private boolean isPaused = false;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceS
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值