Screen rotation stops the video transmission - android

I am relatively new to the Flex/Air application development.
I am involved in development of an app that transmits and receives the video stream.
The bug that I am working on now is on Android device, when you are rotating the screen during video being played, the video just freezes after rotation is completed.
The class that is used for video streaming is NetStream.
I am not quit sure which peace of code I need to post here since there are really a lot of code involved in this whole video part.
My first assumption is that in process of screen rotation, Flex/Air just kills my stream, but now sure if that's true.
So, I am just wondering if anyone else had problem with video during rotation.
We also have separate function for audio and during rotation audio works pretty well.
So please any ideas would be very helpful.

Have you tried pausing the stream before rotating and resuming after? You might also be able to save the current location of the stream and re-init the stream at that point after rotation. Just a couple of quick ideas.

Related

Android Video on Chromebook dropping First Few Frames

I have an app which plays a lot of video files. It's been all good on every phone and tablet I've tested on. I just tested on an Acer Chromebook and the first few frames (maybe up to a 1/4 second) are being dropped on all video files, so the video appears to start just slightly beyond 0. Some of the videos have audio that starts immediately and so it's obvious to the user that the video is clipped at the start. I'm wondering if anyone else has seen this issue, maybe on a Chromebook or other device and if there is some simple way to deal with it?
There is absolutely nothing fancy about my code. I'm using VideoView, preload the video with setVideoURI(), then call videoView.start() on a button press.
Thanks!
This problem only appears if I make a call to seek(0). So rather than doing that to replay the video I have to load the video each time it's requested. That workaround resolves the problem.

How to detect if a video is playing on android platform?

Is there some api or method to know if some video is playing on android platform?
I want to stop some background job when a video is playing at foreground.
The api or method had better comes from surfaceflinger, window manager service etc. framework modules.
Thanks.
The SurfaceFlinger process can know that it is receiving frames at a consistent rate, but it can't know if it's a video or just app animation.
The mediaserver process is responsible for managing the hardware video decoders. It can know if a video is being decoded, but it can't know if the video is being displayed. It won't be involved if the app is using a custom software-only decoder.
There isn't an unequivocal way to detect that a video is being played and presented on the display.

android videoview stream - struggling to get it running smoothly

So I have an IP camera that outputs a video stream I can connect to via the rtsp protocol. I want to display this in my android application, so I've set up a videoview using the following code;
VideoView vv = (VideoView)this.findViewById(R.id.videoView);
Uri uri = Uri.parse("rtsp://username:password#192.168.0.1:554/1/stream3");
vv.setVideoURI(uri);
vv.requestFocus();
vv.start();
I'm putting this in the onCreate() of the main activity class, so when the app loads up it automatically connects and starts streaming. My experience with this is that it works - but eventually gets choppy and or just stops randomnly and doesn't seem to ever get back to running again. I have to close the app and clear it from memory and restart it to get it back - but then it loses connection shortly after, meaning its pretty much useless.
I also found it seemed to lag a bit when touching on the screen objects like menus or buttons but that might just be a coincidence - I can't say for sure.
The thing is the stream is perfect from a PC on the same network via VLC using the same URL. So what am I doing wrong, and is there any better method of handling streaming video? I ultimately wanted to mate the videoview with some overlaid text and buttons, and potentially take screenshots when necessary. At the moment I'm lucky if I get video for a few seconds before it cuts out...
Some additional comments;
I've had some success running it for a longer frame of time - so it's
not always bad which makes things difficult to diagnose. But when it stops it stops.
Does videoview actively try to reconnect if it has lost a connection?
Is there a way of demonstrating this with a progress indicator perhaps -
so it doesn't look like it's doing nothing?

Keep video playing even on orientation change inside fragment?

A question like this is already posted but in my situation, there is some difference.
I have different layout design for landscape and portrait modes (both modes have VideoView) of the fragment that's why I can not use configChanges as below:
android:configChanges="screenSize|orientation|keyboardHidden"
Now when I rotate everything recreate.
I tried retainState/saveInstanceState but does not get success.
I want my video to play continuously without stopping like YouTube app.
Any help would be appreciated.
If you are using the MediaPlayer classes for video playback I would suggest against doing so. YouTube app uses a library called ExoPlayer that is far superior in terms of video support on Android devices. It is a little harder to get setup and operating but once it is that success in playing videos across all the android devices is much better.
That being said. You will still need to stop the video and resume playing at that specific time frame. The best way to do this would be to get the timestamp on rotation and once the surface being played to is ready again (onSurfaceCreateed or onSurfaceChanged events if using the ExoPlayer library) start the video again at that time stamp.

Android Reverse Playback and Frame by Frame

I am trying to create an app with the following features:
normal video playback
slower video playback
frame by frame
reverse video playback (normal, slower, frame by frame)
seekable to specific times
video scrubbing
no video sound needed
video is recorded via the device's camera
The closest comparison to an app, would be the Ubersense Coach app for iOS and Coach's Eye on Android, though there are a few others, and they have all these features.
I have looked into several choices so far:
First the built in Android Media Player, which can't really do anything I need.
Then the MediaExtractor/decoder, looking through the code for Grafika (https://github.com/google/grafika), which can't play backwards.
Tried to pull out each frame as needed with the MediaMetadataRetriever, which is too slow (100ms per frame) and the GC is in the way.
Looked for a library that could potentially solve the issue, without luck so far.
With MediaExtractor I already have the ability to play back video, forward frame by frame or full speed. But I do not have that luxury in reverse, and the seeking does take some time since I need it without artifacts.
When trying to go in reverse, even trying to seek to a previous sync and advancing to the frame, before the one I currently had, it is not doable without huge lag (as expected).
I am wondering if there is a better codec I could use, or a library I have yet to stumble upon. And would rather avoid having to create something custom in native code if possible.
Thanks in advance
Michael

Categories

Resources