android-mediaplayer

How to mute a soundpool?

怎甘沉沦 提交于 2019-12-13 02:27:07
问题 I want to allow the user to mute the app with a button and someone advised me to ''stick a boolean on your MediaPlayerPool that you set to false when the mute button is pressed. Then in your playSound method, do nothing if the value is false.''but i dont know how to do that. Could someone post an example code pls. The pool code : public class MediaPlayerPool { private static MediaPlayerPool instance = null; private Context context; private List<MediaPlayer> pool; public static MediaPlayerPool

android alarm manager sound after reboot

馋奶兔 提交于 2019-12-13 02:17:38
问题 I'm working on a service-like application using android's AlarmManager. The app basically connects to a server and calls a remote procedure. If the value returned is True, it plays a sound: MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_RING); try { mediaPlayer.setDataSource(getApplicationContext(), Uri.parse("file:///system/media/audio/ringtones/Rolling_tone.ogg")); } ... mediaPlayer.start(); This works all and well when the application is

MediaPlayer create method return null object Android

a 夏天 提交于 2019-12-13 00:47:35
问题 I followed many guides about the music player, but my problem is the create method because when i try to do start() the activity crash saying to me that musicplayer is null, here is the code: MediaPlayer mediaPlayer; mediaPlayer = MediaPlayer.create(CustomMediaPlayer.this, R.raw.aud_0101); ... mediaPlayer.start(); the audio file is right inside the raw directory, so I don't know how could be the problem of this nullPointer, anyone have some idea? 来源: https://stackoverflow.com/questions

Android: Multiple video error

。_饼干妹妹 提交于 2019-12-13 00:08:17
问题 I have four videos that are loading on one activity from a url. Now the problem is that when i start the activity all videos plays at the same time. What actually i want is to stop all videos at start and when user clicks on the play button the selected video should be played. If someone has any tutorial or any help with code regarding this problem please help me. Edit: Here is my Activity code. MediaController mediaController; private static String Video_url="http://mywebsite.com/files

How can I add persistent media controls like Apollo or Google music

孤街醉人 提交于 2019-12-12 21:46:46
问题 I would like to add music controls such as play/pause, next, and back as well as show a thumbnail and song title to the bottom of an application like in the Google music app. When the thumbnail or title is tapped on, I want to bring up a detailed view of song, including a seek bar. I am wondering what the best approach for this would be. Should I just add a relative layout the the bottom of my apps xml, and add on click listeners, or can this be accomplished simply with something like the

VideoView Disappears for a second when video is changed

自作多情 提交于 2019-12-12 19:35:58
问题 In my application there are some buttons on top of the screen and a video view under that. In the oncreate event I start playing a mainvideo.mp4 in the VideoView and set it for looping. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.main); VideoView videoView = (VideoView)this.findViewById(R.id.videoView); videoView.setVideoURI("android.resource://"+getPackageName() + "/"+R.raw.mainvideo); videoView.requestFocus(

Playing a video from memory

拟墨画扇 提交于 2019-12-12 18:27:20
问题 Is it possible to play a video directly from memory, using the MemoryFile class? I tried: AssetFileDescriptor afd = getResources().openRawResourceFd(videoResId); InputStream is = getResources().openRawResource(videoResId); // BufferedReader br = new BufferedReader(new InputStreamReader(is)); try { memoryFile = new MemoryFile("myvideo", (int) afd.getDeclaredLength()); byte[] buffer = new byte[8192]; int bytesRead, totalBytesRead = 0; while ((bytesRead = is.read(buffer)) != -1) { memoryFile

How to use MediaSession.setMediaButtonReceiver(PendingIntent) to resume playback

て烟熏妆下的殇ゞ 提交于 2019-12-12 18:15:12
问题 I'm trying to be able to start music playback from my app when the headset buttons are clicked while my app is stopped. I can use MediaSession.Callback onMediaButtonEvent() or the now deprecated registerMediaButtonEventReceiver() to listen for media button click WHILE my app is playing music, but if I pause the music for a minute, with my Activity and playback Service still running, and then I press the headset button, I see that I have lost the ability to receive the media button broadcast.

How to .release() the MediaPlayer instantiated by RingtoneManager?

╄→尐↘猪︶ㄣ 提交于 2019-12-12 16:24:17
问题 I'm getting a default Ringtone in my Activity: remindRingtoneView = (TextView) findViewById(R.id.remind_ringtone); remindRingtoneView.setText(RingtoneManager.getRingtone( NewReminder.this, ringtone_uri).getTitle( NewReminder.this)); After this line I've got a debug line in LogCat with tag = 'Ringtone' and message = 'Successfully created a local player'. When I finished Activity and system garbage collector do it's good job I got a warn message in LogCat = 'MediaPlayer finalized without being

Videoview behavior on differents smartphone (with different stagefright)

风流意气都作罢 提交于 2019-12-12 12:42:15
问题 I'm having compatibility problems using videoview (or MediaPlayer) for play rtsp streams in multiple videoviews in the same activity. I have opened another question on this problem here but now I know that isn't my code the responsible, because I test same software on different phones and it work. Viewing logcat Info messages for RTSP setup I see that each phone has different implementation of stagefright (android multimedia framework): (A) I/RTSPEngine(147): User-Agent: Player/LG Player 1.0