How to stop video player on samsung Smart TV App without to show the black screen - samsung-smart-tv

Hi I'm developing Samsung app with SDK and emulator 4.5. I have a issue..The App shows by videoPlayer some videos loaded on server. My issue is: when the video play and I push button STOP, the video stops and the screen becomes black..I'd like to show the screen with the first frame of the video.
I have tried to do:
sf.service.VideoPlayer.setKeyHandler(tvKey.KEY_STOP, function()
{
if(Popup.getPopup()==Popup.getNPOPUP() && Similars.getOpenS()==false){
//videoPlayer.enterVideo(videoPlayer.url,videoPlayer.title,videoPlayer.from,videoPlayer.axoid,videoPlayer.nid); //riparte l'esecuzione del video
sf.service.VideoPlayer.stop();
videoPlayer.play();//insert function play
sf.service.VideoPlayer.pause();// stop video
videoPlayer.setFullScreen();
sf.service.VideoPlayer.show();
sf.service.VideoPlayer.pause();//stefa
}
});
I have inserted:
videoPlayer.play();//insert function play
sf.service.VideoPlayer.pause();// stop video
The play works but the pausa command not work
How can I do? Have you got a solution?
Thanks

I have inserted below
sf.service.VideoPlayer.stop();
setTimeout(function(){sf.service.VideoPlayer.pause();},2000); //delay function called of 2000 millisecond
I resolved my issue.
if delay time is not enough, you can increase the time to get the finish request.

Related

Android: Custom video recording app and its quality

I followed the tutorial to create a basic video recorder using the button ("Capture" & "Stop")
Generally it works well but I noticed that if we tap too rapidly on the button to toggle between "Capture to Stop" or from "Stop to Capture", the app stop responding and crashes.
May I know the reason(s) why and how can we solve this issue?
My guess is that it takes time for the app to start the processes of Capture/Stop respectively, and by rapidly tapping the button, the respective processes are force to stop?
Also, I notice the quality of my video recorder is not as good as the default Camera App that comes with Android. (The custom video recorder seems to capture videos of darker and dimmer quality)
Can this issue be solve by adjusting the Camera parameters?
(For e.g. adjust the exposure compensation?)

Using Ti.Media.VideoPlayer video does not loop on iPhone 4

Having a weird problem with my app.
Trying to play a video in a loop (see the code below). VideoPlayer repeatMode is set to Ti.Media.VIDEO_REPEAT_MODE_ONE.
Works in simulator, works on iPhone 4s, works on iPad Air... does not work on iPhone 4 (all of them running iOS 7.1.1 apart from simulator - 7.1).
Exact symptoms: after one play, video should restart from beginning, but it stops. If controls are available, I can press play to start playing it again, then after reaching the end it stops again.
I could swear that it worked on iPhone 4 before the 7.1 upgrade, but somehow it stopped.
Anyone could replicate this issue? Or have any idea?
Sys info:
Titanium SDK: Tested with 3.2.3.GA; 3.2.2.GA; 3.2.1.GA; 3.2.0.GA
Platform & version: iOS 7.1.1 (11D201)
Device: works on iPhone 4s, iPad Air, simulator; fails on iPhone 4
Host Operating System: OSX 10.9.2
Titanium Studio: 3.2.3.201404181442
Xcode: 5.1.1 (5B1008)
Alloy: 1.3.1
Code for basic Alloy project to replicate:
index.js
var videoPlayer = Titanium.Media.createVideoPlayer({
autoplay : true,
fullscreen : false,
mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
repeatMode: Ti.Media.VIDEO_REPEAT_MODE_ONE,
scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT
});
//Video is 12s long so it is easy to notice that it does not loop.
videoPlayer.url = "video/candles.mp4";
$.index.add(videoPlayer);
$.index.open();
index.xml
<Alloy>
<Window class="container">
</Window>
</Alloy>
I would appreciate any suggestions.
I have done some research and played around with the Titanium.Media.VideoPlayer and managed to work around the issue. Below you can find the solution in case anyone else encounter this problem.
First of all, some info on the problem.
I have found some forum boards where developers were having very similar problem with MPMoviePlayerController on iPad 1st gen. Looped video was less or more randomly freezing on loop. So I think there is a problem with the Apple video player on some devices, and not necessary with Titanium implementation.
My first approach was to try replay video on complete event that is fired when video stops playing, instead of using repeatMode.
So far so good. It worked on the first time, yay! But the happiness was rather short. During an hour of test of videoPlayer.play() on event complete, the video sometimes was repeating 10-30 times fine and then suddenly was freezing. What gives? Turns out the video player had some sort of a hiccup.
Normal sequence of events was as follows:
video ends, playbackstate changes to 2,
complete event is fired
I restart video on complete
playbackstate changes to 1, video is playing until the end.
For a mysterious reason once in a while this sequence got additional something happening:
video reaches the end - playbackstate changes to 2,
complete event is fired.
video gets restarted on complete
playbackstate changes to 1, video starts playing
suddenly playbackstate changes to 1, video stops, without firing complete event.
Solution
So, knowing all this, I have set up listeners to listen to playbackstate instead of complete and when I hear playbackstate: 1 then I restart video and tadaaa! Everything works!.
Caveat: not 'everything' unfortunately. I am using custom video controls, so I have lost pause, and stop ability (every time video playback state changes to 'stopped' I restart it forcefully). To make it work I have to remember to remove listener every time I press 'pause/stop' buttons and then reattach it afterwards.
Hope that helps someone.

AirPlay flickering when switching between movies

I have an app that shows list of movies in a table view. When I play them one after another on device it works just great. But when I switch to Apple TV over AirPlay it doesn't work anymore. It play's the first video on ATV ok but after a switch to the next video the screen on ATV start blinking/flickering and after a few seconds it falls back playing on a device. I am using MPMoviePlayerController for playing stream videos.
I also found out that if previous video finished playing over AirPlay it tries to start the next one over AirPlay also. Is this intended behaviour?
Is this kind a related with property allowsAirPlay?
I think I've found a solution. Before you switch playing another video you should stop the previous one:
[self.moviePlayer stop];
This is not needed if you are not playing via AirPlay cos the next video will automatically stop previous one by nature - you can not play two videos at once.
But If you do play video over AirPlay you need to stop previous one first and than play the next one.
This solution works for me.

barcodereader sample application

I am using the barcodereader sample application provided in the cascades samples to embed a QRCode scanner into my application.
As it stands the sample is great, but I want the scanner to open as soon as the user navigates to my screen and I want to get rid of the opening slider images that are in the sample.
Firstly, I have tried removing the images and their animations and adding the action:
onCreationCompleted: {
camera.open()
}
to the Page. This opens the camera perfectly as expected, but for some reason, the bacrode just doesn't scan.
So, I wound back a step, and this time I just put the code in exactly as is and just changed the code to read:
onCreationCompleted: {
startupAnimation.play()
}
As expected, the screen open, plays the annimation, but still it fails to read barcodes, however, if I invoke the animation again (by tapping the screen), the animation plays again and the scanner reads the barcode without any issues at all.
All I can think of is that this is a timing issue and that I need some sort of delay after the screen has been created before the camera can be started as a barcode reader?
Anyone able to help?
Thanks,
Douglas
To get scanning right away at application launch, you need to make sure the camera is actually set up and initialized.
Basically, in onCreationComplete, open the camera. In onCameraOpened, start the viewfinder. In onViewfinderStarted, set the barcode detector camera to be the camera.

Continuous background audio with MPMoviePlayerController?

I am using MPMoviePlayerController to play streaming audio. I'm trying to get background audio working correctly. Right now, audio continues to play when you exit the app - the lock-screen and multi-tasking bar controls even work.
When a song finishes, the app is supposed to advance to the next track and play it. It works when the app is open but not when it is in the background (a song finishes but does not advance to the next track). If a song finishes and you re-open the app, however, the next song will start up immediately.
I am currently using NSNotificationCenter to keep track of when tracks end to advance to the next track (in my app delegate). Again, it works like a charm when the app is open. Is there a better way to do this to keep audio playing after a song is done?
I had this issue lately. Hope the answer helps other people.
If you have a playlist for example and want to play the next song while in background mode or lock mode add this line of code on your viewDidLoad:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
This makes the app supports remote control events.