android-mediaplayer

i'm trying to add music to my game but it stops after

孤街醉人 提交于 2020-01-06 06:52:11
问题 so i am very new to scripting and this is my first application i build followed a tutorial but now i want to add music to it found a small code online but the music stops after 1 min while music should last 7 mins? anyone here who can help me with this? and also how could i make a song loop? i did get this " MediaPlayer.setLooping(true); " but i don't know if it's gonna work so wanted to ask with this question too :p Thanks already for you'r time. i've looked for similar questions and used

android - error using multiple instance of VideoView

戏子无情 提交于 2020-01-05 14:02:18
问题 I want an activity that show two (or more) videoview in a linear layout. Using videoview with local files as datasource all works fine, but using video by stream rtsp I have a Mediaplayer error code like (1,1), usually the first video show correctly and second show error. I try the two stream one at time, and they works, so there aren't format errors. I read something about resource release of mediaplayer (link) , but I need that each real-time video are shown. this is code in my Activity :

media player does not work in my code

谁说胖子不能爱 提交于 2020-01-04 07:04:21
问题 Listview with audios does not play Hello how are you? I'm trying to make a listview of audios everything seems to flow as it should, but when I click on a listitem the audio should reproduce but instead it appears "the app stopped working" I do not understand what's wrong with my code someone can help me I'm at times breaking my head but I can not solve this problem. Below is the logcat, and then my code, please someone help me make it work. -Thank you Logcat MainActivity.class public class

android mediacontroller - defining the mediacontroller in the layout xml

丶灬走出姿态 提交于 2020-01-04 06:55:21
问题 In the android documentation on the MediaController widget I read Functions like show() and hide() have no effect when MediaController is created in an xml layout. which points to the fact the the mediacontroller can be defined in the xml layout. As I want a controller which never hides and also doesn't take the focus so that it is possible to click buttons on the rest of the screen I tried to go the xml layout way. As I can't get this to work I am looking for an example on how to use

Can a service get a reference to the activity during onBind?

微笑、不失礼 提交于 2020-01-04 06:07:21
问题 I have a service that basically manages a MediaPlayer instance for playing podcasts . Once an activity binds to the service it can do things like play, pause, stop, etc. I used a service because I want the podcast to continue playing even after the activity is destroyed. I'd like the service to be able to send messages back to the activity in case of an error or for normal status updates . Is it possible for the service to get a reference to the activity that's trying to bind to it? Doesn't

mute just the background music of my app

 ̄綄美尐妖づ 提交于 2020-01-03 04:54:47
问题 i build an app, and in main menu i want to create a button to control whether the user wants to use music (unmute) or not (mute) only for this application (not the device) and the background music is played on another layout.. This is my method to call media player (in class Question.java): public void playSound(int arg) { try { if(player != null) { if (player.isPlaying()) { player.stop(); player.reset(); player.release(); } } } catch(Exception e) { } if (arg == 2) { player = MediaPlayer

play an mp3 with MediaPlayer class on Android issues

不想你离开。 提交于 2020-01-03 03:16:28
问题 What is wrong with my code? I have a toggle button and i would like to play/stop an mp3. I guess that the code should be as follows: package com.android.iFocus; import android.app.Activity; import android.media.MediaPlayer; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ToggleButton; public class iFocusActivity extends Activity implements OnClickListener { public int count; MediaPlayer mediaPlayer = MediaPlayer.create(this,

How to use a MediaPlayer Singleton

我的梦境 提交于 2020-01-03 02:57:27
问题 I am new to Android developing and am starting with a simple soundboard application. I started developing a soundboard using multiple fragments until I realized that I was using multiple instances of MediaPlayer. This is not good because I want only one sound to play at a time. I realized that I'd have to use a MediaPlayer Singleton to solve my problem. The only problem is that I can't find many sources or examples of the MediaPlayer Singleton online. Here's what I originally put into every

How to use a MediaPlayer Singleton

帅比萌擦擦* 提交于 2020-01-03 02:57:13
问题 I am new to Android developing and am starting with a simple soundboard application. I started developing a soundboard using multiple fragments until I realized that I was using multiple instances of MediaPlayer. This is not good because I want only one sound to play at a time. I realized that I'd have to use a MediaPlayer Singleton to solve my problem. The only problem is that I can't find many sources or examples of the MediaPlayer Singleton online. Here's what I originally put into every

MediaPlayer.prepare() throws IllegalStateException on Android L

有些话、适合烂在心里 提交于 2020-01-02 05:12:14
问题 I have code that plays mp3 file from assets directory: MediaPlayer mediaPlayer = new MediaPlayer(); descriptor = context.getAssets().openFd("beep.mp3"); mediaPlayer.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength()); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.setVolume(soundLevel, soundLevel); descriptor.close(); mediaPlayer.setLooping(false); mediaPlayer.prepare(); mediaPlayer.start(); This code was working fine on