media-player

Playing short .wav files - Android

柔情痞子 提交于 2019-11-26 16:05:03
问题 I would like to play sound after touching the button. MediaPlayer works fine, but I read somewhere that this library is for long .wav (like music). Is there any better way to play short .wav(2-3 sec.)? 回答1: The SoundPool is the correct class for this. The below code is an example of how to use it. It is also the code I use in several apps of mine to manage the sounds. You can have as may sounds as you like (or as memory permits). public class SoundPoolPlayer { private SoundPool mShortPlayer=

How to stream audio/video files such as MP3, MP4, AVI, etc using a Servlet

丶灬走出姿态 提交于 2019-11-26 15:26:31
I would like to stream my audio/video files to web using servlet. I made an attempt with the following servlet: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { File file = new File("/Users/myfolder/Documents/workspace/love.mp3"); response.setContentType(getServletContext().getMimeType(file.getName())); response.setContentLength((int) file.length()); Files.copy(file.toPath(), response.getOutputStream()); } And the following HTML: <a href="/media" data-format="mp3 ogg">Click Here!</a> However, the player is just loading...

Dealing with video (DVDs, .avi .mkv) in Java

我的未来我决定 提交于 2019-11-26 15:26:18
问题 After looking around for a decent library for playing videos in Java, I've come unstuck. Everyone around is screaming not to use JMF because it's outdated, old and requires the user to install it, other alternatives such as VLCJ seem good if they work but are still relatively unstable and rely on hefty amounts of native code, and as for dealing with DVDs, that seems like gold dust to find in a free library! Current Options: Now JavaFX 2 is gaining momentum it's been something I've been

Android: MediaPlayer setVolume function

℡╲_俬逩灬. 提交于 2019-11-26 15:06:06
about the params Set what to make the player no sound and full sound Thanks This function is actualy wonderful. Thanks to it you can create a volume scale with any number of steps! Let's assume you want 50 steps: int maxVolume = 50; Then to set setVolume to any value in this range (0-49) you do this: float log1=(float)(Math.log(maxVolume-currVolume)/Math.log(maxVolume)); yourMediaPlayer.setVolume(log1,log1); //set volume takes two paramater Nice and easy! And DON'T use AudioManager to set volume! It will cause many side effects such as disabling silent mode, which will make your users mad!

Stopping & Starting music on incoming calls

我的梦境 提交于 2019-11-26 15:05:19
I have implemented an Activity that plays media from a URL in android In order to add pause functionality when the incoming call is incoming I created a receiver that sets a a variable when the call is coming. The activity reads this variable and then pauses the music in its onPause() method and resets is when the call is done and the activity resumes the music in its onResume() method This works fine as long the activity has the focus. If I go back to home screen while the music is playing, and then the call comes, the activity's onpause is not called & hence i can' stop & start the music

Unity load medias from folder and display on RawImage

时光总嘲笑我的痴心妄想 提交于 2019-11-26 14:49:38
问题 I am trying to create a media player in Unity that reads all media files from a static folder and plays trough all medias (images static duration, videos for the length of the video). First I am trying to get it to work with just images. I'm very new with Unity and not good with C#. I'm able to get all media file sources (images) to an array but next I need to convert them to a texture and place on the RawImage -component. I'm stuck with this part. If I have the src (ex. C:\medias\img1.jpg)

MediaButtonIntentReceiver not working in Android 4.0+

天涯浪子 提交于 2019-11-26 14:38:40
问题 The goal is to intercept broadcasts from the headset, as well as bluetooth eventually, to respond to different types of clicks from the headset to alter the mediaplayer. This solution works fine for all versions prior to ICS. Here is some of the code and things I have tried: .... private BroadcastReceiver mediaButtonReceiver = new MediaButtonIntentReceiver(); .... public void onCreate() { ... IntentFilter mediaFilter = new IntentFilter(Intent.ACTION_MEDIA_BUTTON); mediaFilter.setPriority

Android Stop Background Music

寵の児 提交于 2019-11-26 12:59:21
问题 EDIT - FOUND A EASY 5-10 LINE SOLUTION!!! See MY OWN ANSWER BELOW!!! YAY!!!!!!!!! I\'ve searched for 5 hours, dozens of SO posts, no answers, and this seems like the most simple obvious freaking thing!!! EDIT- btw, this is NOT a music player app, just an app to view pics and text, opens multiple activities like menu and about, view diff types of pictures etc. I just want to play some simple background music while looking thru the pics and text, why is that so difficult? another EDIT - it

How to resume the mediaplayer?

雨燕双飞 提交于 2019-11-26 12:58:48
问题 I am using a media player. I have the option for starting ,stopping and pausing the player. The problem I have is that I cannot find the option to resume the song from the point that it previously was paused.. Any help provide would be really helpful. 回答1: Thank you for your attention but I've got it myself for pausing the Mediaplayer I used: Mediaplayer.pause(); length=Mediaplayer.getCurrentPosition(); and for resuming the player from the position where it stopped lately is done by:

iPhone SDK:How do you play video inside a view? Rather than fullscreen

最后都变了- 提交于 2019-11-26 11:49:56
问题 I am trying to play video inside a UIView , so my first step was to add a class for that view and start playing a movie in it using this code: - (IBAction)movie:(id)sender{ NSBundle *bundle = [NSBundle mainBundle]; NSString *moviePath = [bundle pathForResource:@\"Movie\" ofType:@\"m4v\"]; NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain]; MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; theMovie.scalingMode =