media

How to target a file (a path to it) in Java/JavaFX

雨燕双飞 提交于 2019-11-26 21:26:27
问题 It might be a simple one, but i can't seem to get it to work. I am making a video player in JavaFX but I don't know how to target the file that is going to be played (I don't know the correct syntax). Thank you in advance for your help. Here's a sample of code that i'm trying to run> Media media = new Media("trailers/trailer.mp4"); MediaPlayer player = new MediaPlayer(media); MediaView view = new MediaView(player); btw, the file is in the project folder, then trailers/trailer.mp4. Oh, and I'm

JavaScript Play Uploaded Audio

泄露秘密 提交于 2019-11-26 21:04:54
问题 How do I make it so that when audio is uploaded it can be played? I used this code, but it didn't work. <input type="file" id="audio" onchange="playFile(this)" /> <audio id="sound"></audio> <script type="text/javascript"> function playFile(obj){ var url=document.getElementById("audio").url; document.getElementById("sound").src=url; document.getElementById("sound").play() } </script> 回答1: [EDIT] One should not use the FileReader API to load an user selected File into its page. Instead one

Play sound using soundpool example

本秂侑毒 提交于 2019-11-26 19:55:08
I would like to learn how to use soundpool method. I would like you to show me a very simple example that run 2 sounds. TheFlash Create a folder named as raw under your_app/res/ . Then paste your ringtone in this folder, for example your_app/res/ringtone.mp3 . Now use the following code: SoundPool soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); int soundId = soundPool.load(context, R.raw.ringtone, 1); // soundId for reuse later on soundPool.play(soundId, 1, 1, 0, 0, 1); Be sure to release the SoundPool resources after use: soundPool.release(); soundPool = null; user3833732 Yes. i

Android: sample microphone without recording to get live amplitude/level?

倾然丶 夕夏残阳落幕 提交于 2019-11-26 19:19:31
问题 I was trying to get the amplitude level of a microphone on Android like so: MediaRecorder recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); Timer timer = new Timer(); timer.scheduleAtFixedRate(new RecorderTask(recorder), 0, 1000); private class RecorderTask extends TimerTask { private MediaRecorder recorder; public RecorderTask(MediaRecorder recorder) { this.recorder = recorder; } public void run() { Log.v("MicInfoService", "amplitude: " + recorder

How to create a custom media type (application/vnd) for a RESTful web service?

走远了吗. 提交于 2019-11-26 19:18:53
问题 I'm playing with REST right now and thought I properly implement HATEOAS just to get all concepts right. For that I want to create my own media types ( application/vnd[...]+xml and application/vnd[...]+json ). One first question: Does the media type define the contract between my server and client? The media type will define my message formats so I need to add XML schema and JSON schema to go with the new media types (so that REST clients know what's coming in messages and what to send back).

Playing BG Music Across Activities in Android

南笙酒味 提交于 2019-11-26 18:57:51
Hello! First time to ask a question here at stackoverflow. Exciting! Haha. We're developing an Android game and we play some background music for our intro (we have an Intro Activity) but we want it to continue playing to the next Activity, and perhaps be able to stop or play the music again from anywhere within the application. What we're doing at the moment is play the bgm using MediaPlayer at our Intro Activity. However, we stop the music as soon as the user leaves that Activity. Do we have to use something like Services for this? Or is MediaPlayer/SoundPool enough? If anyone knows the

Div show/hide media query

为君一笑 提交于 2019-11-26 18:40:50
What code can I use to make a particular div show only if on a mobile width? I have a 100% width full div at the top of my screen, would like it to only show when the device is specified as a mobile width. I'm not sure, what you mean as the 'mobile width'. But in each case, the CSS @media can be used for hiding elements in the screen width basis. See some example: <div id="my-content"></div> ...and: @media screen and (min-width: 0px) and (max-width: 400px) { #my-content { display: block; } /* show it on small screens */ } @media screen and (min-width: 401px) and (max-width: 1024px) { #my

How to save images from Camera in Android to specific folder?

隐身守侯 提交于 2019-11-26 16:44:21
问题 Basically, what I want to do is allow the user to make their own folder and then go to an activity that contains a button to launch the camera . From there I want to be able to launch the camera and save the camera images into the newly created folder. I am having trouble with last part of saving the camera images into the newly created folder. Here is my Code : public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button b =

Volume change listener?

自闭症网瘾萝莉.ら 提交于 2019-11-26 16:44:19
问题 Is there any way to listen for volume changes with an Android service and react to that? Btw: How does the Google music app allow the user to control the media volume even when the music is playing in the background? 回答1: Check out registerMediaButtonEventReceiver(ComponentName broadcastReceiver); Define a BroadcastReceiver that handles ACTION_MEDIA_BUTTON . The recieved intent includes a single extra field, EXTRA_KEY_EVENT , containing the key event that caused the broadcast. You can use

Audio spectrum analysis using FFT algorithm in Java

白昼怎懂夜的黑 提交于 2019-11-26 15:56:40
问题 I want to analyze the spectrum of an audio file in Java (ME). I want to draw spectrum as some media players do. But I don't understand some points: Input for FFT algorithm, which I have to get from the audio file. I don't now what it is called, what it is and more important, I don't know how to get it. Output: if input is an array (range?) I obtain other array, and it have range: 0-1, right (or not)? So what I have to do with it? 回答1: You need a few additional steps in addition to the FFT.