Event for VideoView playback state or MediaController play/pause

If you’re using the MediaController in combination with a VideoView, it should be relatively easy to extend the latter and add your own listener to it. The custom VideoView would then look something like this in its most basic form: public class CustomVideoView extends VideoView { private PlayPauseListener mListener; public CustomVideoView(Context context) { super(context); } … Read more

How can I know users click fast forward and fast rewind buttons on the playback controls in iPhone

I got the answer by myself. That is using UIApplication’s beginReceivingRemoteControlEvents. In an appropriate place (like viewWillAppear:) put the following code [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; [self becomeFirstResponder]; And the view controller should implement the following method returning YES – (BOOL)canBecomeFirstResponder { return YES; } And then you can receive remote controller event in the following method. … Read more

Background music Android

If you want to play background music for your app only, then play it in a thread launched from your app/use AsyncTask class to do it for you. The concept of services is to run in the background; By background, the meaning is usually when your app UI is NOT VISIBLE. True, it can be … Read more

MediaPlayer stop playing after about 5 seconds

I had this problem too. It was probably due to having the MediaPlayer-object only existing within a method. For example: //ERROR, stops after 5 sec! public static void playMusic(int id) { MediaPlayer mediaPlayer = MediaPlayer.create(context, id); mediaPlayer.setLooping(true); mediaPlayer.start(); } It is most likely that the garbage collector will come in and clean away the MediaPlayer-object. … Read more

Trouble playing wav in Java

I’m not sure why the second approach you linked to starts another thread; I believe the audio will be played in its own thread anyway. Is the problem that your application finishes before the clip has finished playing? import javax.sound.sampled.*; import java.io.File; import java.io.IOException; import javax.sound.sampled.LineEvent.Type; private static void playClip(File clipFile) throws IOException, UnsupportedAudioFileException, LineUnavailableException, … Read more

playback video full screen

No need to do any coding for playing video to full screen mode Apply the following layout format over the xml containing the videoview it will for sure will play the video in full screen mode. as it is running mine. <?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” > <VideoView android:id=”@+id/myvideoview” android:layout_width=”fill_parent” android:layout_alignParentRight=”true” android:layout_alignParentLeft=”true” android:layout_alignParentTop=”true” … Read more

MediaPlayer stutters at start of mp3 playback

AFAIK the buffers that MediaPlayer creates internally are for storing decompressed samples, not for storing prefetched compressed data. I suspect your stuttering comes from I/O slowness as it loads more MP3 data for decompression. I recently had to solve a similar problem with video playback. Thanks to MediaPlayer being unable to play an arbitrary InputStream … Read more