How to play YouTube video directly in landscape mode in fullscreen? - java

So, I'm using this code to play some video after a button click:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=VYqhW2YFN7k")));
But it just opens the whole youtube web page in the browser with suggested videos and stuff. Is there a way to directly play the video in landscape mode in fullscreen?

If You are using Youtubeplayer APi to view video than you can use this line in onInitializationSuccess Method
youTubePlayer.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE);
youTubePlayer.setFullscreen(true);

Set your screen orientation landscape in android manifestfile.

You can use the new YouTube Data API by Google.
There, you have a lot of control of how to show the video. This includes even putting the view that shows the video into your activity, so you can set whatever orientation you wish for it.

Related

Android inapp camera and video capture

I am trying to implement an in-app camera to my application, which will allow me to take either a still photo or a video, with the result being stored in a variable.
So basically the top tabs (HOME, GALLERY, CAMERA, EFFECTS) are all Fragments. Assuming we are currently on the "CAMERA" tab, inside this view you will have two further tabs at the bottom one for taking still shots and the other for video, the rest of the screen should be taken up by a camera interface showing the cameras view.
The Android developer documentation mainly talks about using androids built in camera and then saving the result in one of my own variables, which I dont want to do.
Resouces I have taken a look at
Android developer documentation
Random Google tutorials & stackoverflow
Android arsenal and 3rd party created libraries.
Material Camera looks good but as soon as I try and add its dependancy to my app, the build gradle throws an error, so that one doesn't work.
CWAC-Cam2 looks really complicated, I don't understand how to implement it.
This is the resource you couldn't find: Using Camera inside app
Basically for taking photo you'll need to access the camera resource through:
Camera.open()
Then create a class for showing the preview like the following:
public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback
For capturing you'll need a PictureCallback.
For video recording checkt the first source at the Capturing videos section; there you'll need a MediaRecorder.

Can you display the real-time output of the device's camera?

I am wondering if it is possible to show the output of the camera running on your device immediately on the screen. Just like the native camera app does.
I have to show the picture, that comes into the camera lens, and additionally add some graphics overlays. That's why I guess, starting an Intent to open the camera activity is not suitable.
I've found some SO Threads, Tutorials and documentation about using the Android Camera API, but they are all able to just take a picture and display it afterwards.
Is it possible at all?
Refer to this link Camera Tutorial for Android (using surfaceview)!
Use the SurfaceView to preview the camera output, then, you can add your graphics overlays as you wish.
Hope this helps :)

Stream Video On Android Like YouTube

I want to play video on my android app with a player like YouTube.
My webapp is using videojs for playing different video formats.
I dont wish to use the native media player on android as i want to show portrait version of it and show the likes and comments beneath the video.
Currently am using a webview on the half of the layout and below that am using the layout for likes, comments etc.
So, What should i go for ? I want to use the player like YouTube. Is it even possible ?
Thanks !

How to avoid video stop when I scroll the screen using youtube API in an android app?

I'm building an app for Android using the YouTube API. The video is in a scroll widget, and when I scroll and the video goes up or down the screen, it stops. I want the video to continue even though isn't in the screen. How can I do that?
i went through the same problem, i open this question:
Android YouTube API video pause when rotate screen or hide player
see the comments to understand better. For the tests I did, the Youtube API knows when the player is not showing on the screen and just pause the video. As a workaround I changed my layout so that the player be fixed on the screen, just as is the official app from youtube.
I use this question as reference:
Scrolling Text Above Buttons, Buttons Fixed At Bottom

Android custom animation when calling activity outside of application?

I know how to use overridePendingTranition to change the animation between activities inside of my own application. My question is how can I get the same result when sending an intent to open a Youtube video for example. It will work correctly but because the Youtube application is not a translucent theme I see a black screen immediately and then the content slide in using my animation. Is there anyway to control the animation starting that activity as well as the animation that will run when the user clicks back to come back to your application?
Thanks

Categories

Resources