media-player

IllegalStateException calling MediaPlayer.reset()

*爱你&永不变心* 提交于 2019-11-29 11:15:09
问题 The documentation for the Android MediaPlayer shows that there are no invalid states for the reset() call: http://developer.android.com/reference/android/media/MediaPlayer.html#Valid_and_Invalid_States (the invalid states are listed as {}, or "none."). However, I have seen an IllegalStateException thrown while calling reset() : java.lang.IllegalStateException at android.media.MediaPlayer._reset(Native Method) at android.media.MediaPlayer.reset(MediaPlayer.java:1061) at com.example.android

MP4 unsupported in JavaFX?

折月煮酒 提交于 2019-11-29 10:59:58
So I've recently started working with JavaFX to try and insert video and audio into my java programs. Audio has worked just fine, but for some reason every time I try and play a video file, it returns a MEDIA_UNSUPPORTED exception. I've read around and saw that the video file needed to be MP4 (which it is), so I tried converting it to a different type then re-converting it to MP4 (H.264 & AAC) with a few different converters and nothing changes. Here's the code I'm working with: import java.net.URL; import javax.swing.JFrame; import javax.swing.SwingUtilities; import javafx.application

Video not playing in Android

大兔子大兔子 提交于 2019-11-29 09:32:34
问题 Video not working properly in the below mentioned code. What could be the problem for this? MediaController mediaController = new MediaController(getBaseContext()); mediaController.setAnchorView(videoweb); Uri video = Uri.parse("http://www.youtube.com/v/wwI2w2YHkCQ?fs=1"); videoweb.setMediaController(mediaController); videoweb.setVideoURI(video); videoweb.start(); Error: Cannot play video Sorry,this video cannot be played. 回答1: The link you have provided, http://www.youtube.com/v/wwI2w2YHkCQ

Android: How to use mediaController in service class?

橙三吉。 提交于 2019-11-29 08:20:21
I have a app that plays radio via MediaPlayer as a service. Is it possible to use MediaController in Service class? The problem is that I can use findViewById. I try to get my LinearLayout in onPrepeared methiod ... public class RadioPlayer extends Service implements OnPreparedListener, MediaController.MediaPlayerControl { @Override public void onCreate() { super.onCreate(); mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.setOnPreparedListener(this); mediaController = new MediaController(this, false); mediaPlayer.setDataSource(url);

Android MediaPlayer error: MediaPlayer error(1, -2147483648) on Stream from internet

泄露秘密 提交于 2019-11-29 07:54:10
I'm trying to stream audio from a URL. The code works fine with other URLs, but in one of those it fails in the OnPrepared method, returning this error code: (1, -2147483648). I've read some people saying it's because of permissions, but it's a remote file, so I can't set permissions. I've tried the URL with other apps like VLC and iTunes, and it's working fine. My code is here: private void prepareradio() { player = new MediaPlayer(); player.setAudioStreamType(MODE_WORLD_READABLE); try { player.setDataSource(url); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch

Create mediaplayer with inputstream in android

ぐ巨炮叔叔 提交于 2019-11-29 07:47:05
How to I create mediaplayer instance with inputstream? I see only 4 function for setDataSource. And there is no function getting inputstream ? is it a must to use FileDescriptor to mediaplayer ? It seems so basic. but, I couldnot find a way. In j2me, there is a function that Manager.createPlayer(InputStream) . And you can use inputstream to create a media player. Is there a way to create a mediaplayer like j2me ? One approach can be to write your stream to a File and then give it to the MediaPlayer for playback. How about making a HTTP server on the recieveing side (a thread on the phone) that

Android mediaplayer MediaPlayer(658): error (1, -2147483648)

[亡魂溺海] 提交于 2019-11-29 07:28:46
I get this error when playing a streaming audio in Android: MediaPlayer(658): error (1, -2147483648) mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.setDataSource(url); mediaPlayer.prepareAsync(); I don't know about playing streams but I was getting the same error from trying to play a file residing on the device. The solution was that the MediaPlayer didn't have the right permissions to read the video file. This article helped me out tremendously. http://www.weston-fl.com/blog/?p=2988 I was also getting the same error on Froyo & Gingerbread. In higher Androids the same

android MediaPlayer not playing mp3 file

烂漫一生 提交于 2019-11-29 07:24:43
问题 I have written the most basic application I can think of to try to play an mp3 file, but it is not working. I don't get any errors, but when the application starts up, the sound is not played. public class soundtest extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); MediaPlayer mp = new MediaPlayer(); mp.create(getApplicationContext(), R.raw.norm

Calling another activity when mediaplayer get finished playing

a 夏天 提交于 2019-11-29 05:12:57
Hi I used the following code to call an activity when audio play get finished. But I want to play the audio in current activity, when play get finished it has to jump for the next activity. But here it jumps to the next activity and play the audio. Any suggestions. package com.fsp.mus; import java.io.File; import java.io.IOException; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.media.MediaPlayer; import android.os.Bundle; import android.os.Environment; import

Using WakeLock to Keep A Stream Playing

自闭症网瘾萝莉.ら 提交于 2019-11-29 04:09:50
I have a MediaPlayer running in a Service that's playing audio from a URL (streaming). As of now it appears to work well, and even continues playing when I put the phone in standby. I currently do not acquire a wakelock. My question is: Is it actually necessary to acquire a wakelock in my situation? If it is necessary, what type of wakelock should I acquire? And yes, this is a legitimate use-case for wakelock, because my users explicitly want the audio to continue playing. MediaPlayer does not do this for you automatically by default. However, instead of you having to acquire a wake lock, it