Resuming video on phone after disconnecting from chromecast in CastVideos-android - android

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.

Related

AdMob's RewardedVideoAd destroys activity it was started from after video is watched

I am using AdMob's RewardedVideoAd.
What I've done is when user opens a chat activity, I ask him to view a video to be able to chat to another user (by simply switching visibility of the chat elements). Then, after the video is watched, I make the chat elements visible.
It works well on the emulator. However, when I tested it on my phone, the chat activity is closed after video is watched. I cannot understand why this is happening.
It only happens if a user watches the video till the end (onRewarded() is called).
Any suggestions?
Ok, I worked it out.
It happened, because I did not forward the lifecycle events. After I called resume(context), pause(c), destroy(c) according to my Activity lifecycle, it worked.
God knows why it worked fine on the emulator and did not on my phone.

Recording a Android Activity while it is not in the foreground

My task is to show a demo of users data in video to the user.
To solve it my idea is to display data in animations and record all those animations in the background as a video.
I want to know if I is there anyway I can record the same even before displaying it and directly show to user as a video.(Without that activiy is not in onResume state or the user is not viewing the animations demo).
If there are any other options please help me.
Yes you can record your actions.
In Android studio, go to ANDROID MONITOR, then you can see a PLAY icon on the left top,Second icon.
Press on that to start recording your actions on your Device.

Cast companion library change video without restarting activity?

I have built an application that uses Cast Companion Library (CCL) to remotely play video to cast comparable devices. Every thing is working find but I need to be able to change video files and not kill and restart the activity and fragment.
I have implemented my own custom version of the VideoCastControllerActivity that implements the same interface but I am re-using the VideoCastControllerFragment that CCL comes with. One problem is that the VideoCastControllerFragment does not really give specific notice when the end of a video file is reached. It somewhat does by calling closeActivity() from the IVideoCastController interface so I tried to use that event to know when to load the next video file. But loading the next video file by calling
getCastManager().loadMedia( mSelectedMedia, autoPlay, position );
but doing that results in another call to close activity and a loop until the end of the playlist is reached without playing any video.
Is there another way to go about this without re-writing my own VideoCastControllerFragment?
To answer your first question (or observation), you can listen to various callback events directly in your implementation of VideoCastControllerActivity; you have access to the VideoCastManager so you know when your media status goes to IDLE with the reason FINISHED. Outside of that, you seem to be trying to implement some sort of playlist functionality in your sender while the right place for that is on the receiver (i.e. you need to write a custom receiver); if your playlist knowledge/logic lives on your phone, then the whole thing becomes dependent on your phone so if it goes to sleep, you chromecast doesn't know what to do. In addition, if a second device connects to the same cast device, it cannot correctly reflect the playlist, etc. So a phone device can let user form a playlist and then it has to send the information about that playlist to your custom receiver and your custom receiver should handle playing them in queue and your sender(s) should be able to send custom messages to move to the next/prev, etc and your receiver should do the right thing accordingly. We have a very rudimentary sample on our GitHub repo that shows how you can do video playlist on the receiver.

How to manage activity for playing a music

I am working on live radio app.
I parse list of channels and show in list view , My problem is when i click on particular channel first time than it plays that channel according to assign link. but when you go out of application and come back and again you click on same channel (Which is playing currently ) it restart the media-player and start playing it again.
so to solve this problem i used manifest "singleTask" to solve this problem.But now when i try to click another link ( other than currently playing) than it wont play the current selected channel from Listview item and its assign link..
So can anybody please tell me How can i have code for activity and service to solve this problem , I am student so i don't have much experience.
Also I am checking for internet if you are connected to internet than it parse the json otherwise it will show message but it only check once when you start your application So how can i check net connection background?
Thank you
You need to set up a Service to play music in background.
There is a sample project called RandomMusicPlayer embedded with the SDK which could help you a lot to achieve it. (In Eclipse: New Project > Android > Android Sample Project)
Move your player to the Service, bind it in activity a send commands from your activity, there is plenty tutorials for this.
Similar question
Service activity communication
Service media player

Handling Interrupt in my Android application

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

Categories

Resources