Hi I am developing an application that play video in android player.
But i am stuck in between. I used videoView to play video on that.
But inbetween if any incomming call, incomming message come that after
by video can not be resume.
Even if battery low message come than also i can't resume my video.
What exactly happens when you return to the screen from the interrupt? You could save the "state" of the playback in internal storage and resume to the point at which it was before. Try utilizing the onResume and onStop methods of your activity.
Check the first image here for more http://developer.android.com/reference/android/app/Activity.html
Related
I want to modify the ExoPlayer demo to allow audio playback to continue when the screen gets locked (this should work regardless of whether the media being played is audio or video). Based on some hints (e.g. 1, 2) this is what I came up with so far:
https://github.com/google/ExoPlayer/compare/release-v2...sedubois:background-playback
This is directly based on the ExoPlayer demo code, currently in version 2.12.1. It adds a "foreground" permission, registers a service, and creates a notification in that service (according to the documentation this notification is required for background playback). The service is started when initializing the player.
I can start the player and the demo looks as illustrated below with an audio stream. At this point the notification gets created properly, it shows the player details (title, description, progress bar) and control buttons (see picture below), which work (I can play/pause, restart from the beginning and skip backwards/forwards).
However the playback still stops when I minimize the application or when I lock the screen by pressing the power button. What is the proper way to make this work?
Just to make sure we are on same page. I'm testing on dev-v2 branch of exoplayer repo here
onStop() method in PlayerActivity.java is releasing player, So when app goes in background then onStop() is being called and it is releasing player with method releasePlayer.
If you'll comment out that method i.e. dont release player in onStop(), then player will play in background.
I'm currently playing with the great sample application CastVideos-android, but can't get it to resume video playback on phone after disconnecting from Cast device.
I see this functionality prepared in LocalPlayerActivity.java with comment
this will be the case only if we are coming from the
CastControllerActivity by disconnecting from a device
but it's never called (mShouldStartPlayback is always false).
Is there a simple way how to get it working? I'd be thankful for any pointers on where to start.
Thank you in advance!
That feature is not there in that sample due to the structure of the app. For example, you are casting Movie A, then you go back and start browsing and click on Movie B to go to the detail page for that movie. Now Movie A is casting and you are looking at Movie B's detail page. If you disconnect at that time, should it replace the Video B with the Movie A and resume that? That won't be the best user experience. Due to the way the app is structured, that is not implemented.
i have designed a call screen by using the concept of broadcast receiver.my requirement is to implement a video call screen,so that when some one calls to my device at that time a video file will be played in the call screen and previous normal ringtone will be stopped.
I basically have an audio application that will be playing some music. I want to be able to pause/stop/mute the music when there is an interrupt.
These interrupts include: GPS directions, Phone Call, GPS, etc. (if there are more audio interupts, please let me know)
I already implemented the phone call interrupt, stops the music when phone call received and plays after phone call ends.
How would I do the other interrupts?
EDIT:
I noticed that Android's Play Music application does this. But I am unable to find the source code of that, not sure if that would be helpful.
Make sure you correctly ask for and release Audio Focus as described here:
http://developer.android.com/training/managing-audio/audio-focus.html
With multiple apps potentially playing audio it's important to think about how they should interact. To avoid every music app playing at the same time, Android uses audio focus to moderate audio playback—only apps that hold the audio focus should play audio.
Basically this allows the framework to handle interrupts properly as you cannot specifically code for every situation.
In my application I want to get start time of music player when user started and end time when it stops.I don't want to start any music player in my app. I just want to track user activity in device. So i want my application to get any notification when user started the music .
Do I get any intent for music player started and it stopped.Or do I get any intent for when user opens music files.
Is there any other method other than intent to capture the start time and and time when user starts music player.
Well you can implement the interface 'AudioManager.OnAudioFocusChangeListener' in which there is a method 'onAudioFocusChange' which lets you know if audio focus has been changed, and it can also tell if focus was gained or lost.
See this link, it explains the Audio Focus in detail. An application must gain audio focus through a request, and you can implement the 'AudioManager.OnAudioFocusChangeListener' and if there is focus gain, you can detect if the media player is running, (because some other application such as you tube may gain focus to play its audio), see this to see how to detect which application or service is currently running. You can find if audio has started to play, and if it was the media player or not.
Hope this helps. It was interesting question and I have learned some new things while searching for the answer!