Exoplayer how can you detect if someone clicks on the Play Button? - android

I know I could test with PlayerStateChanged if something is playing or not but I need the moment someone presses the play button... Does somebody know the code for this ?

I want to make the player prepare(mediasource) only when the user clicks on the play button so I can save ressources otherwise it will keep loading everytime a video when I go into the feed.
Then you can just simply add a button to your layout and call prepare(mediaSource) whenever button is clicked.
BTW : you can override the control view of ExoPlayer to achieve the same

Related

YouTube Player next prev buttons aren't visible for the first video

I'm trying to implement built-in YouTube player in my app (API: https://developers.google.com/youtube/android/player/)
I load more than one video id for playback (list of video IDs)
youTubePlayer.loadVideos(idList)
But when player starts prev and next buttons aren't available until the first video finishes and switches to the next one, only then buttons appears and I can switch between videos from my video list
Whenever you got the answer.... please lemme know
It started to work normally after some time

Android - can we open camera in one activity and use it in another

guys. I want to make a game in which I want to start camera when play button is pressed. There is a problem - it takes too long to open the camera (5-6 seconds). So can I open the camera when the user is in the options menu and when he/she press play button just to get the camera and put the camera view where I want. In that way the user would not wait 5-6 second.
And if there is no way to do this, I can just write "Loading ..." with some picture while the camera is loading, but how can I understand when the camera is ready to remove "Loading..." ?
Thanks in advance !
The answer given by zgc7009 in more detail: http://developer.android.com/training/basics/intents/result.html
As for me, you can initialize camera when your application has started. Just set your SurfaceView invisible or gone. When the user clicks play button set SurfaceView like visible. In this case you don't wait.

If using MediaPlayer to play Button click sound, what happens to default click sound?

For the record, I am not asking how to play a sound programmatically with the MediaPlayer. I know how to do that quite well.
I first searched how to replace the default click sound of a Button in the XML. But I have not found out if that is possible. Most answers suggest to use the MediaPlayer to play a sound effect somewhere in/from the onClick() event of the Button, so I assume that's the best way to go?
If I use the MediaPlayer to play a sound when a Button is clicked, do I have to disable the default click sound as well, or will both play, or will Android just know to ignore the default click sound? Should I call setSoundEffectsEnabled(false) on the Button before I play my own sound?
It seems very strange to me that I can't just replace the default click sound of a Button (is it possible to do that?)
Just set android:soundEffectsEnabled=false in your theme defined into your res/styles.xml
or programatically:
myButton.setSoundEffectsEnabled(false);
you may wish to check this link as well: Playing sound effect (CLICK/NAVIGATION_RIGHT) for button clicks - Android
seems that sound effects are kept as android.view.SoundEffectConstants.<value>
correspondingly, there might be a way of adding your own custom sound
it is all about passing the value of sound effect you'd like to hear, into <view variable>.playSoundEffect(<sound effect value>); so you may try to add your sound into res and call that method with its R value

How to make a button appear pressed when it is not?

I have a button that plays a sound clip when it is pressed. I would like the button to appear pressed during the duration of the sound clip. By that, I mean that I would like the button to take on the default pressed-button appearance while the sound is playing. How can I implement this? I have tried using a number of things in the onClickListener (such as setSelected, requestFocus, etc), but none of those do the trick. I have also tried changing the onClickListener to an onTouchListener, again with no dice. Am I wrong in assuming that there must be a way to simply set the button image to appear pressed? (BTW, the button object is of type Button, not ImageButton).
Thanks for any advice!
Please see this question. It details a couple of different ways this can be done.
Lookup 'selector' drawables and let android take care of this for you.

how to draw black screen during pause state in video view

Hello
our tester want to stop function in video player.
so I add stop button and call seekto(0) and pause when user press stop key.
but I has one problem. videoview is not clear play screen.
please help me.
instead of using video view try media player present in android.mediaplayer.mediaplayer so when you need to stop the player you can just call mediaplayerobject.stop() and then mediaplayerobject.release() thats all it will be easy

Categories

Resources