GithubHelp home page GithubHelp logo

fbsamples / 360-video-player-for-android Goto Github PK

View Code? Open in Web Editor NEW
617.0 96.0 165.0 47.35 MB

Sample code for creating a 360 video player on Android. Creates an OpenGL ES scene that renders a sphere textured with video frames from MediaPlayer playback. Does not use the NDK. This is a simple example of the core elements of 360 video rendering and is not intended to be production quality code. The code may be unstable. This is won't be maintained.

License: Other

Java 98.73% GLSL 1.27%

360-video-player-for-android's Introduction

360 Video Player for Android

360 video is the new hotness in interactive media. Imagine teleporting yourself to the most interesting places in the world, training with Lebron James, or speeding across the Jakku desert from Star Wars. These are the kinds of immersive experiences that 360 video enables.

Enclosed you'll find a sample Android application that demonstrates how to playback 360 video, specifically equirectangular video, using MediaPlayer, TextureView, and OpenGL ES. Touch and drag is supported to adjust the yaw and the pitch to see more of the 360 video.

The launch activity will load a sample 360 video included in: res/raw/sample360.mp4

Today's 360 cameras generally either output directly in equirectangular format or provide software to convert to equirectangular. Facebook ingests 360 videos in equirectangular format.

Visit:

Disclaimer

  • This code is intended as an example and is by no means production quality.
  • It may not be entirely stable.
  • It has been tested on limited high end Android devices
    • Works on Genymotion with Nexus 5 (5.1.0).
    • Didn't work on the new Android Studio 2.1 Preview 1 emulator (Nexus 5X AVD with HAX enabled).
  • It's not intended as a demonstration of "the right way" to do things.
  • It will not be supported.

Requirements

Requires Android OS version KitKat (4.0) or higher.

To build you'll need the Android SDK with build tools.

Note: the gradle project was created with Android Studio Preview 2.1 Preview 1

The included sample video is 4k 30fps so be sure to use an Android device that can handle that video decode.

GearVR compatible devices such as the Note4, Note5, S6, S7, should have no issues with video decode performance.

Usage

Android Studio

Open the directory in Android Studio and the gradle project should be imported. Run & Debug options should allow you to build the project.

Command Line

Assure you have a local.properties file in the top level directory with: sdk.dir=/path/to/your/Android/sdk

$ gradlew installDebug
$ adb shell am start -n com.oculus.sample/.SphericalPlayerActivity

360-video-player-for-android's People

Contributors

03lafaye avatar jamesgpearce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

360-video-player-for-android's Issues

Play Video On Button Click Not Working

Button btn_play = (Button)findViewById(R.id.btn_play);
btn_play.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {

                    videoPlayer = (SphericalVideoPlayer) findViewById(R.id.spherical_video_player);
                    videoPlayer.setVideoURIPath(SAMPLE_VIDEO_PATH);
                    videoPlayer.playWhenReady();
                    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
                    requestExternalStoragePermission();

        }
        });

Not working....Please Help!!!!!!!!

Play multiple videos

I want to show multiple videos, say 4 videos inside the 360 sphere. Is it possible to do that? So basically these 4 videos are "tiles" of the original equirectangular video, being played by 4 simultaneous media players! So eventually it brings the impression of watching a single video!

Does not play video in Samsung note 4, SM-N900,v4.4.2

I have build this. 360 video player in Android Studio v2.1 beta3. gradle:2.1.0-beta3
Can't play video placed in asset folder. Toast saying "Prepairing video..."
Log:
04-20 17:00:47.436: V/MediaPlayer(7065): prepareAsync
04-20 17:00:47.441: V/MediaPlayer(7065): message received msg=300, ext1=0, ext2=0
04-20 17:00:47.441: V/MediaPlayer(7065): Received SEC_MM_PLAYER_CONTEXT_AWARE
04-20 17:00:47.441: V/MediaPlayer(7065): callback application
04-20 17:00:47.441: V/MediaPlayer(7065): back from callback
04-20 17:00:47.441: V/MediaPlayer(7065): message received msg=100, ext1=1, ext2=-2147483648
04-20 17:00:47.441: E/MediaPlayer(7065): error (1, -2147483648)
04-20 17:00:47.441: V/MediaPlayer(7065): callback application
04-20 17:00:47.441: V/MediaPlayer(7065): back from callback
04-20 17:00:47.481: I/MediaPlayer(7065): send context aware event
04-20 17:00:47.486: I/MediaPlayer(7065): sendBroadcast CONTEXT_AWARE_MUSIC_INFO - type(error) - id (29)
04-20 17:00:47.486: E/MediaPlayer(7065): Error (1,-2147483648)

License

CC-NC on unsupported sample code? :/ Can somebody change this to a less restrictive license? Thanks

Issue with replay function

Since you are using "setLooping(true), the internal MediaPlayer replays from the start once the video is finished . However 1 time on 2 its freezing, it goes like this for me :

1- plays the video normally
2- reaches completion after the video has been entirely displayed
3- replays the video it but its frozen ("MSG_FRAME_AVAILABLE" is only sent once)
4- reaches completion after like 2 seconds ()
5- go back to 1)

No errors in the log, maybe its a bug with my device ? I'm using a sony Xperia z1 and a personal 360 video (equirectangular) for testing.

I've removed "setLooping(true)" and added "setOnCompletionHandler" instead, that does mediaPlayer.start() once its called, but there is still this frozen replay bug.

In another project that reads a video with mediaplayer and surfaceView (without the opengl layer), it works fine.

Any idea ?
Thanks in advance.

360 Video Texture Flipped Horizontally

@03lafaye Thanks for sharing this superb work with the community.

Hi all,
I managed to run this project successfully and play 360 video. Everything ok except I notice that the video texture is flipped. Please see the attached image.

Please help with fixing this
Thanks

screenshot_20170329-163743

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.