GithubHelp home page GithubHelp logo

omnivirt / omnivirtvrplayer-android-example Goto Github PK

View Code? Open in Web Editor NEW
23.0 4.0 8.0 848 KB

Play VR Content on your Android application in just a single line of code.

Home Page: https://www.omnivirt.com/vr-player/

Java 100.00%

omnivirtvrplayer-android-example's Introduction

OmniVirt VR Player: 360° Video Player for Android

API

Screenshot

OmniVirt makes the leading player for 360° video experiences across mobile and desktop. Upload your 360° content to OmniVirt and serve it into your app with few easy steps.

Visit omnivirt.com to upload your VR content. Contact us for more info at [email protected].

Add the OmniVirt SDK to your app

Add the following lines to build.gradle of your application module.

dependencies {
    compile 'com.omnivirt:omnivirt-android-sdk:0.14.0'
} 
 
repositories {
    maven {
        url 'https://dl.bintray.com/omnivirt/OmniVirtSDK'
    }
}

Usage

OmniVirt VR Player for Android provides you a really easy way to embed 360° content on your Android application with just few lines of code.

Get Started

  1. Sign up for an account at OmniVirt
  2. Upload your VR / 360° photo or video on OmniVirt.
  3. Keep the Content ID assigned to your content for further use.

Now the content is ready. There are two methods that you can use OmniVirt VR Player to play your VR content on your application.

Method 1: Launch a Fullscreen VR Player

This method lets you play a VR content with just a single line of code !

Usage

First, add the following code to AndroidManifest.xml.

<activity android:name="com.omnivirt.vrkit.FullscreenVRPlayerActivity"
    android:configChanges="orientation|screenSize"></activity>

To launch a fullscreen player, simply call:

FullscreenVRPlayerActivity.launch(MainActivity.this,
                                  CONTENT_ID, // Replace with your Content ID
                                  true,       // Autoplay
                                  Mode.ON     // Run in Cardboard mode
                                  );

And ... done ! That's all !

Extra: Earn Money

Would like to earn money from your 360° content? You can create an Ad Space on OmniVirt and pass the Ad Space ID acquired to the command like shown below to enable ad on the player.

FullscreenVRPlayerActivity.launch(MainActivity.this,
                                  CONTENT_ID, // Replace with your Content ID
                                  true,       // Autoplay
                                  Mode.ON,    // Run in Cardboard mode
                                  ADSPACE_ID  // Replace with your Ad Space ID
                                  );

Once you set it up correctly, user will sometime see an ad among the player and that will turn into your revenue !

Player Callback

Any change on the player could be detected by implementing OnVRPlayerInteractionListener interface inside the caller Activity. Here is the example.

public class PlayerActivity extends AppCompatActivity implements OnVRPlayerInteractionListener {

    ...
    
    private void play() {
        FullscreenVRPlayerActivity.launch(MainActivity.this,
                                          24,
                                          true,       // Autoplay
                                          Mode.ON     // Run in Cardboard mode
                                          );
    }

    /**
     * Called when VR Player Fragment embedded inside the Activity is created
     *************************************************************************/
    void onVRPlayerFragmentCreated() {    
    }
    
    /**
     * Called when VR Player is loaded
     **********************************/
    void onVRPlayerLoaded(Integer maximumQuality, Quality currentQuality, Mode cardboardMode) {    
    }
    
    /**
     * Called when VR Player has started playing
     ********************************************/
    void onVRPlayerStarted() {
    }
    
    /**
     * Called when VR Player is paused
     **********************************/
    void onVRPlayerPaused() {
    }
    
    /**
     * Called when VR Player has finished playing
     *********************************************/
    void onVRPlayerEnded() {
    }
    
    /**
     * Called when video has been skipped for the next one
     ******************************************************/
    void onVRPlayerSkipped() {
    }
    
    /**
     * Called when video duration has been changed
     *
     *   value - new duration in seconds
     **********************************************/
    void onVRPlayerDurationChanged(Double value) {
    }
    
    /**
     * Called when video progress has been changed
     *
     *   value - current progress in seconds
     **********************************************/
    void onVRPlayerProgressChanged(Double value) {
    }
    
    /**
     * Called when video has been buffered
     *
     *   bufferLength - buffer length in seconds
     ********************************************/
    void onVRPlayerBufferChanged(Double bufferLength) {
    }
    
    /**
     * Called when video has been seeked
     *
     *   value - seeked position in second
     *****************************************/
    void onVRPlayerSeekChanged(Double value) {
    }
    
    /**
     * Called when Cardboard mode has been changed
     *
     *   mode - new Cardboard mode (ON, OFF)
     **********************************************/
    void onVRPlayerCardboardChanged(Mode mode) {
    }
    
    /**
     * Called when volume level has been changed
     *
     *   volume - new volume level
     ********************************************/
    void onVRPlayerVolumeChanged(Double volume) {
    }
    
    /**
     * Called when video quality has been changed
     *
     *  quality - new video quality (QualitySD, QualityHD, QualitySHD and Quality4K)
     ******************************************************************************/
    void onVRPlayerQualityChanged(Quality quality) {
    }
    
    /**
     * Called when VR player has been expanded fullscreen
     *****************************************************/
    void onVRPlayerExpanded() {
    }    

    /**
     * Called when VR player has been restored to embedded size
     ***********************************************************/
    void onVRPlayerCollapsed() {
    }
    
    /**
     * Called when video angle in y-axis has been changed
     *
     *   latitude - new angle in degree
     *****************************************************/
    void onVRPlayerLatitudeChanged(Double latitude) {
    }    

    /**
     * Called when video angle in x-axis has been changed
     *
     *   longitude - new angle in degree
     *****************************************************/
    void onVRPlayerLongitudeChanged(Double longitude) {
    }
    
    /**
     * Called when video scene has been switched
     *
     *   scaneName - the name of new scene
     *   history - list of scenes navigated
     *****************************************/
    void onVRPlayerSwitched(String sceneName, Array history) {
    }

}

Method 2: Embed a VR Player on an Activity with VRPlayerFragment

OmniVirt VR Player also provides you a Fragment that allows you to embed a VR Player on your Activity.

Usage

Add this fragment tag to your activity layout xml file.

<fragment
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.omnivirt.vrkit.VRPlayerFragment"
    android:id="@+id/vrplayer_fragment" />

To start playing, add the following snippet to your activity and replace CONTENT_ID with your VR Content's.

VRPlayerFragment player = (VRPlayerFragment) getFragmentManager()
    .findFragmentById(R.id.vrplayer_fragment);
player.load(CONTENT_ID);
player.setCardboard(Mode.OFF);

Player callback could also be retrieved by the same approach as sample above.

Support Library v4 Fragment

Support Library v4 Fragment is also available in com.omnivirt.vrkit.VRPlayerSupportFragment class. Usage is still be the same as stock Fragment one.

<fragment
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.omnivirt.vrkit.VRPlayerSupportFragment"
    android:id="@+id/vrplayer_fragment" />

QR Code for Cardboard Alignment

To launch QR Code scanner to scan a QR Code comes along with the Cardboard, call this following function.

// Stock Fragment
QRReaderFragment.launchCardboardQRScanner(MainActivity.this);

// Support Fragment v4
QRReaderSupportFragment.launchCardboardQRScanner(MainActivity.this);

Questions?

Please feel free to email us at [email protected] !

omnivirtvrplayer-android-example's People

Contributors

nuuneoi avatar mafoai avatar

Stargazers

Nico Yip avatar Stéphane ZÉ-OGIER avatar Kotchaphan Muangsan avatar  avatar  avatar Steve Fisher avatar Eko Setyo Purnomo avatar sobhan zp avatar Ajinkya Puar avatar Achin verma avatar  avatar Sultan Abubakar avatar PS avatar  avatar Renato avatar Yurii Poudanien avatar Rakshit Sorathiya avatar Piyush Malaviya avatar  avatar Oliver Guo avatar Jonathan Allen Grant avatar Sultan Keshwani avatar

Watchers

Krzysztof Nowicki avatar Sultan Keshwani avatar James Cloos avatar Jatupon Sukkasem avatar

omnivirtvrplayer-android-example's Issues

Slow content playing in app

I have successfully integrated a full screen VR Player into my android app, but once loaded in full screen, the content loads slowly to the point that it buffers. I guess that either a process is running in background and consuming resources on the mobile, or something about the VR Player launch process is running incorrectly and rendering the app unstable. Any ideas about how to get to the bottom of what is causing this issue?

Error in some Locales

"OmniVirt.api.sendMessage('deviceorientation', " + String.format("{alpha: %f, beta: %f, gamma: %f, orientation: %d}", alpha, beta, gamma, Integer.valueOf(screenOrientation)) + ", document.getElementsByTagName('iframe')[0], false)"

But in some locales (for example Russian) String.format("%f") return number with a comma not a dot. So device orientation not working in some locales

Load content

Hi,

I would like to know if there is any way to store local video and load to the player ?

Second question, could you tell me in which files I have to add this code

FullscreenVRPlayer.launch(MainActivity.this,
                          CONTENT_ID, // Replace with your Content ID
                          true,       // Autoplay
                          false       // Run in Cardboard mode
                          );

Thanks for your help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.