media-player

MediaPlayer.setDataSource() and prepare() not working - android

懵懂的女人 提交于 2019-11-27 04:32:07
I'm having a crack at using the MediaPlayer object and not having much success. If I add a sound asset to my raw folder and call it using the int value within R, it works fine. But I want to be able to pull things off of url. According to all of the documentation I've read setDataSource() should accept a string param with a url to a file. I keep getting an IO exception on the prepare() statement. I've even tried copying the file locally and still no dice. Anyone have any ideas? MediaPlayer mp = new MediaPlayer(); try { mp.setDataSource("http://www.urltofile.com/file.mp3"); mp.prepare(); mp

android mediaRecorder.setAudioSource failed

萝らか妹 提交于 2019-11-27 04:27:17
I have android G1 firmware 1.6, I am trying to record voice from the app with the follow code. MediaRecorder recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(PATH_NAME); recorder.prepare(); recorder.start(); my manifest.xml has: <uses-permission android:name="android.permission.RECORD_AUDIO" /> I got: 09-23 14:41:05.531: ERROR/AndroidRuntime(1718): Uncaught handler: thread main exiting due to uncaught

camera app not working?

核能气质少年 提交于 2019-11-27 04:07:03
问题 I got following stack trace 04-17 12:11:56.378: D/ATRecorder(10379): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@40528b78 04-17 12:11:56.408: D/WindowManagerImpl(10379): addView, new view, mViews[0]: com.android.internal.policy.impl.PhoneWindow$DecorView@40520738 04-17 12:11:56.428: D/WindowManagerImpl(10379): addView, new view, mViews[1]: android.widget.LinearLayout@40525d00 04-17 12:11:56.438: D/WindowManagerImpl(10379): finishRemoveViewLocked, mViews[1]:

Media Player start stop start

99封情书 提交于 2019-11-27 03:56:09
问题 I am making a new android sound application. I made a clickable button to play sound when I click on it. But I also want it to stop playing sound when I click for the second time. That part works fine now here is the problem, when I click again on button to play sound again, it doesn't play it, Media player is completely stopped. I was looking on forums but I can't seem to find an answer that could help me. Here is my Activity: MediaPlayer mpButtonClick1; MediaPlayer mpButtonClick2; @Override

how to play audio file in android

亡梦爱人 提交于 2019-11-27 03:55:19
I have a mp3 file in my android mobile, lets it's a xyz.mp3 somewhere in my sdcard. How to play it through my application? Simply you can use MediaPlayer and play the audio file. Check out this nice example for playing Audio: public void audioPlayer(String path, String fileName){ //set up MediaPlayer MediaPlayer mp = new MediaPlayer(); try { mp.setDataSource(path + File.separator + fileName); mp.prepare(); mp.start(); } catch (Exception e) { e.printStackTrace(); } } Suv @Niranjan, If you are using a raw file from res/raw folder, ie., reading a file stored inside the project, we can use:

controlling volume in MediaPlayer

强颜欢笑 提交于 2019-11-27 03:38:03
问题 I'm playing audio (narration) in an audiobook. The audio files are in .ogg format, between 10 and 15 seconds long each. Edit to add: I'm using Android 2.2, API 8, and I have this in my Manifest: <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> I've got setVolumeControlStream(AudioManager.STREAM_MUSIC); in my onCreate() method. My sounds are being played via code similar to this: mp = MediaPlayer.create(mContext, resource); mp.setOnCompletionListener(this); mp.seekTo

How do I stream video and play it?

牧云@^-^@ 提交于 2019-11-27 02:55:50
问题 How can I stream video data from the network and play it on an iPhone? 回答1: First, are you developing a Web app optimized for iPhone or a native application ? In the first case, your only option is to transcode your video files to Quicktime H.264 (m4v or mp4 extension). You can use Quicktime Pro (use the export menu) or VLC (as a free alternative). Then simply add a hyperlink to the video file on your HTTP server. Make sure it presents the right content-type and stuff (read Safari Web Content

play/pause button image in notification ,Android

有些话、适合烂在心里 提交于 2019-11-27 02:24:07
问题 I have implemented music player which fires a custom notification when stream audio is playing. Everything is working and I can play/pause the audio using the button in the notification. The only problem is the image button: it can't change the image on a click of a button to indicate play/pause. Using remoteViews.setImageViewResource() in RemoteReceiver is not working. The control is done using BroadcastReceiver and this is the code of firing the notification from the player activity: public

Capture OSX media control buttons in Swift

风流意气都作罢 提交于 2019-11-27 02:24:03
问题 I would like my app to respond to the F7 , F8 and F9 keyboard media control buttons. I am aware of this lovely library but it is not working in combination with Swift: https://github.com/nevyn/SPMediaKeyTap 回答1: I actually solved this problem myself just the other day. I wrote a blog post on it, as well as a Gist I'll embed the blog post and final code just in case the blog or Gist ever go away. Note: This is a very long post that goes into detail about how the class in constructed and what

Android: How to stop media (mp3) in playing when specific milliseconds come?

こ雲淡風輕ζ 提交于 2019-11-27 02:18:34
问题 I have an mp3 file and I want to play a specific word in it. I have a start time ( 6889 ms ) and end time ( 7254 ms ). I have these codes: package com.example.playword; import java.io.IOException; import android.app.Activity; import android.media.MediaPlayer; import android.os.Bundle; import android.widget.TextView; public class PlayWord extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate