media-player

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

与世无争的帅哥 提交于 2019-11-28 08:34:25
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(savedInstanceState); setContentView(R.layout.main); final TextView tv = new TextView(this); tv.setText("Playing...")

Android : How to set MediaPlayer volume programmatically?

柔情痞子 提交于 2019-11-28 05:15:19
How to set the mediaplayer volume programmatically. I use it for alarm notification. Any help is highly appreciated and thanks in advance. Using AudioManager you can control the volume of media player. AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 20, 0); also from MediaPlayer (But I didn't try that) public void setVolume (float leftVolume, float rightVolume) Since: API Level 1 Sets the volume on this player. This API is recommended for balancing the output of audio streams within an application.

Intent to open android playlist activity

爱⌒轻易说出口 提交于 2019-11-28 05:00:02
问题 I am creating an application in which the list of the playlist already created by user in the native music application will be shown in a list and their onclick shall take them to that specific playlist page. Following is the code which i am using Button open = (Button)findViewById(R.id.ope_playlist); cursor = playlist.this.managedQuery(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, null , null, null, null); cursor.moveToFirst(); final String playlistid = cursor.getString(cursor

How to Play Streaming Audio/Video from a url?

北城以北 提交于 2019-11-28 04:34:00
I am new in Android. I am using android os 2.2. I am trying to play streaming audio and video from url. I don't know what to do for that. after 3 days og googling i come to know that I have to use mediaPlayer and MediaController classes. I had use different differend combination of codes found on internet but not succeed. Can anybody guide me what to do for streaming audio/video playing. What about the UI if we use MediaPlayer or Controller class. is there any thing to related these in xml file of layout. if not then even please tell me what may be the code for that. please help me. Sathish

MP4 unsupported in JavaFX?

左心房为你撑大大i 提交于 2019-11-28 04:21:14
问题 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

Streaming to the Android MediaPlayer

一笑奈何 提交于 2019-11-28 03:29:40
I'm trying to write a light-weight HTTP server in my app to feed dynamically generated MP3 data to the built-in Android MediaPlayer . I am not permitted to store my content on the SD card . My input data is essentially of an infinite length. I tell MediaPlayer that its data source should basically be something like "http://localhost/myfile.mp3" . I've a simple server set up that waits for MediaPlayer to make this request. However, MediaPlayer isn't very cooperative. At first, it makes an HTTP GET and tries to grab the whole file. It times out if we try and simply dump data into the socket so

android video, hear sound but no video

て烟熏妆下的殇ゞ 提交于 2019-11-28 01:56:28
I have tried several different examples but I cannot get any video to show. I hear sound but no video. I thought maybe I just had a incorrect video format so I downloaded a fiat commercial in 3gp format and still no joy. I am using the Eclipse Java EE with android sdk and my app targets the 1.5 sdk (Api Level 3) without google api. Could someone please post a link to a video known to play in android or point out my problem with the code. I have tried all I could think of .. with/without prepare .. different layouts etc. Here is my onCreate in activity /** Called when the activity is first

Android: How to use mediaController in service class?

淺唱寂寞╮ 提交于 2019-11-28 01:40:20
问题 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

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

人盡茶涼 提交于 2019-11-28 01:22:35
问题 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 {

java wav player adding pause and continue

青春壹個敷衍的年華 提交于 2019-11-28 00:36:33
I have this code which plays wav files from a folder with play and stop. How can I add pause and continue? import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import java.applet.AudioClip; import java.net.URL; public class JukeBox extends JFrame { private JComboBox musicCombo; private JButton stopButton, playButton; private AudioClip[] music; private AudioClip current; public JukeBox(String title) { super(title); getContentPane().add(new JukeBoxControls()); } public static void main(String [] args) { JukeBox myf = new JukeBox ("WAV COMBOBOX"); myf