android-mediaplayer

Audio not working in Android WebView using shouldInterceptRequest()

跟風遠走 提交于 2019-12-24 03:01:50
问题 My Android app is showing an html5 e-book in a WebView. I have a zipped file containing an e-book with all its resources: text, images and audio (mp3 files). In order to unzip the book I use shouldInterceptRequest(), which intercepts the file:///... requests, and returns the data via a WebResourceResponse object. The code works fine for text and images. When I get to audio resources, I get runtime errors, and the audio file is not played. Note: I do see the unzipped file is returned with the

Streaming audio from an Android device to another

亡梦爱人 提交于 2019-12-24 00:23:41
问题 How would I go about streaming audio from one device to another over the internet? I'm aware of sending basic data using Java sockets, but wondering how to: Start streaming midway through a file (say, during the middle of a song) What format is needed for the data being sent. MediaPlayer can take a url as a data source, so how should the audio be represented when being sent from the server side? Thanks 回答1: Having implemented a music streaming app, I can share a little with you. If you want

App crash on headset button click

◇◆丶佛笑我妖孽 提交于 2019-12-23 19:42:02
问题 I have build an audioplayer which is deployed in android google playstore. I'm using crashlytics to monitor crashes and ANRs. Recently I have been getting a lot of crashes MediaButtonReceiver. The headset clicks work fine in many devices. But some devices are giving this problem. Crashlytics report - Fatal Exception: java.lang.RuntimeException: Unable to start receiver android.support.v4.media.session.MediaButtonReceiver: java.lang.IllegalStateException: Could not find any Service that

Multiple songs are playing when I click on listview in mediaplayer

我的未来我决定 提交于 2019-12-23 16:05:13
问题 Hello I am creating Music player app. I have a problem in that when I click on listview it plays song. When once again I clicked on listview then songs are playing together. Previous song doesn't stop. I followed many tuts and blogs and stackoverflow answers but nothing is worked. Here is my Activity which contains songs list view :- public class songlist extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { private ListView lv_songlist; public Cursor cursor;

Setting background colour for VideoView hides the video

拜拜、爱过 提交于 2019-12-23 13:19:12
问题 I am using a VideoView in my app and when I set the background colour with either the layout properties, or in the code itself, the background colour is laid over the top of my video and I cannot see it. 回答1: VideoView extends SurfaceView , which relies on PorterDuff.Mode.CLEAR to cut a hole in the view hierarchy so that you can see a native rendering surface underneath. If you make it fill itself back in with a solid color, you will not be able to see the video. While the video is playing,

Issue with audio playback using setNextMediaPlayer

牧云@^-^@ 提交于 2019-12-23 12:45:38
问题 I need to play an audio without gaps between lopping, the audio needs to be looped forever without gaps. Using setNextMediaPlayer only merge two audio tracks without gaps, after that it automatically stops playing the audio, it is not looping for ever. Thanks in advance. mp1 = MediaPlayer.create(getApplicationContext(), R.raw.loop); mp2 = MediaPlayer.create(getApplicationContext(), R.raw.loop); protected void play() { // TODO Auto-generated method stub mp1.start(); mp1.setNextMediaPlayer(mp2)

RecyclerView + MediaPlayer + Toggle Button + String Uri

放肆的年华 提交于 2019-12-23 10:15:16
问题 Background: I'm working on an Fitness app. Everything is working good till now but problem came when I was working with audio files MediaPlayer in android. I have checked resources and found ListView but couldn't find anything on RecyclerView + MediaPlayer. I want to know how to make it work while working with RecyclerView + Toggle Button + String Uri (Offline - Raw folder) Problem: Right now it is playing the first .mp3 file on every click event (for Eng: R.raw.sample_one_eng is played and

MediaPlayer Streaming issues on Android 4.4 (API 19)

南楼画角 提交于 2019-12-23 09:38:12
问题 My app is having issues with the MediaPlayer streaming, specifically on Nexus 5. I'm not sure if this is Nexus 5 or API level 19 causing the problem. Basically my MediaPlayer gets prepared and I call MediaPlayer.start() , but the MediaPlayer doesn't begin streaming. This happens at random and only on my Nexus 5 device. When this happens, if I try seeking the MediaPlayer it begins to play. Is anyone else experiencing this? UPDATE: I've filed a bug against Android: https://code.google.com/p

Android MediaPlayer SeekTo function workaround

旧街凉风 提交于 2019-12-23 09:30:47
问题 I am creating a very simple media player app. I would like to resume the song from the SeekTo position that I have captured using getCurrentPosition. However seekTo does not start from the position I have captured but from the beginning. Code to capture current position, pause and change button text to Click to resume int media_length = mediaplayer.getCurrentPosition(); Toast.makeText(this,"media length is"+media_length, Toast.LENGTH_LONG).show(); mbutton.setText("Click to Resume");

How to read length of video recorded with MediaRecorder into private app storage directory constructed via context.getFilesDir()?

你说的曾经没有我的故事 提交于 2019-12-23 07:55:50
问题 I am having a weird issue reading the length/duration of a video file recorded with a device's camera by using MediaRecorder. The file is recorded into the application's private storage directory, which is set like so: mMediaRecorder.setOutputFile(context.getFilesDir() + "/recordings/webcam.3gpp"); After recording is complete, I attempt to read the length of the video with these methods: Method 1: MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();