FinweLtd / orion360-sdk-basic-hello-android

Other
1 stars 0 forks source link

Proper way to go to next video #4

Closed ameenmaheen closed 7 years ago

ameenmaheen commented 7 years ago

Hi team

When ever i start a video in the player

Couldn't open https://particularvideo.mp4: java.io.FileNotFoundException: No content provider:https://particularvideo.mp4 setDataSource IOException | SecurityException happend : java.io.FileNotFoundException: No content provider: https://particularvideo.mp4 at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1137) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:988) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:911) at android.media.MediaPlayer.attemptDataSource(MediaPlayer.java:1102) at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1093) at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1052) at fi.finwe.orion360.OrionVideoPlayer.openVideo(OrionVideoPlayer.java:161) at fi.finwe.orion360.OrionVideoPlayer.setVideoURI(OrionVideoPlayer.java:73) at fi.finwe.orion360.OrionVideoPlayerAsync$PlayerHandler.processInitialize(OrionVideoPlayerAsync.java:242) at fi.finwe.orion360.OrionVideoPlayerAsync$PlayerHandler.handleMessage(OrionVideoPlayerAsync.java:200) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.os.HandlerThread.run(HandlerThread.java:61)

I get like this and video starts playing , and when ever i try to play next video by using mOrionVideoView.prepare(videoUri); this error was not shown and video is not playing , What is the reason for this exception , and can you point out best way to play next video after dealing with the first video .

trantako commented 7 years ago

Hi,

Android MediaPlayer backend uses a Java exception as a part of its internal control structure. In practice, it will print a warning message to logcat for all video files that are accessed this way, but you can simply skip the warning.

To move on to next video, you really shouldn't need to do anything special. Calling prepare() method to OrionVideoView component with a proper URI should work.

I just tested this with Hello World example, both by setting a Handler that called the prepare() method after 10 seconds and also by setting onCompletionListener to play next video when the first one ends. In the latter case, I simply added this to the end of the onCreate() method:

    mOrionVideoView.setOnCompletionListener(new OrionVideoView.OnCompletionListener() {
        @Override
        public void onCompletion(OrionVideoView orionVideoView) {
            try {
                mOrionVideoView.prepare(
                        "https://s3.amazonaws.com/orion360-us/Orion360_test_video_2d_equi_360x180deg_1920x960pix_30fps_30sec_x264.mp4");
            } catch (OrionVideoView.LicenseVerificationException e) {
                Log.e("OrionVideoView", "Orion360 SDK license could not be verified!", e);
            }
        }
    });
ameenmaheen commented 7 years ago

I wanted to change the video before the current video completes , So i calledmOrionVideoView.reset() and mOrionVideoView.prepare("Url") but the previous video is still on the videoview , Is there any way to show the black screen at that time ?

trantako commented 7 years ago

Yes, there are several ways.

One option would be to use a placeholder image e.g. from the app's /assets folder. This could be a photo or just a black rectangle to produce a black screen. When it is time hide the current video, you'd call prepare() method with this local image file as the URI. Screen would go black immediately, and then you could call the prepare() method again with the next video's URI.

However, there is a smarter way to achieve this. Orion360 SDK supports rendering a preview image. Consider it as another layer on top of the video that contains an equirectangular image. You should use that for drawing a placeholder photo or a black screen instead of the main layer. Then you can easily switch between the main layer (video) and the preview image layer (placeholder / black screen) by adjusting the layer's alpha value, which also allows a nice crossfade effect!

Example: https://github.com/FinweLtd/orion360-sdk-basic-examples-android#example-preview-image

Code: https://github.com/FinweLtd/orion360-sdk-basic-examples-android/blob/master/app/src/main/java/fi/finwe/orion360/sdk/basic/examples/examples/PreviewImage.java

Finally, if you really just need a black screen, you can use the preview image without initialising it with an image at all. No content set results to black screen. So, all you need to do is to adjust the alpha value. Use the code line below and try values between 0.0f and 1.0f to see what happens :)

mOrionVideoView.setPreviewAlpha(animatedValue);

ameenmaheen commented 7 years ago

thank you for the assist @trantako