media

Android - MediaStore.Video.query() is returning null

岁酱吖の 提交于 2019-11-28 00:50:05
问题 I'm trying to retrieve the metadata from a video file (title, language, artist) using the method MediaStore.Video.query(). However, the method is always returning null. The code is bellow: String[] columns = { MediaStore.Video.VideoColumns._ID, MediaStore.Video.VideoColumns.TITLE, MediaStore.Video.VideoColumns.ARTIST }; Cursor cursor = MediaStore.Video.query(getApplicationContext().getContentResolver(), videoUri,columns); if (cursor != null) { cursor.moveToNext(); } String title = cursor

How do I make JavaFX MediaView stretch media to fill parent container?

余生长醉 提交于 2019-11-28 00:15:25
问题 I'm trying to make my video's dimensions stretch automatically and fill the MediaView and maintain the original aspect ratio of the video. Basically, I want my MediaPlayer to fit the parent container on resize etc. like pretty much all video players do. If anyone could shed some light on how to achieve this that would be much appreciated, thanks. 回答1: Here's an example of stretching to the containing Scene and the scene is set by the Dimension "size": final MediaPlayer videoPlayer = new

JavaScript Play Uploaded Audio

无人久伴 提交于 2019-11-28 00:11:44
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> [EDIT] One should not use the FileReader API to load an user selected File into its page. Instead one should prefer the URL.createObjectURL(File) method. This will return a blobURI, only accessible from user

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

随声附和 提交于 2019-11-27 23:22:40
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 running Windows. Put your file into the sources folder and load it as a resource: Media media = new

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

梦想与她 提交于 2019-11-27 18:08:57
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). I've done some research on the web but the details of how one does this are missing. Does it only

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

妖精的绣舞 提交于 2019-11-27 18:02:50
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.getMaxAmplitude()); } } Unfortunately, this only returns 0 all the time. It appears that for this to work I

Jersey REST support resume/media streaming

半世苍凉 提交于 2019-11-27 17:38:34
I need to support resume on Jersey REST, I'm trying to do it this way: @Path("/helloworld") public class RestServer { @GET @Path("say") @Produces("audio/mp3") public Response getMessage(@HeaderParam("Range") String r ) throws IOException{ String str="/Users/dima/Music/crazy_town_-_butterfly.mp3"; System.out.println(r); RandomAccessFile f=new RandomAccessFile(str, "r"); int off=0; int to=(int)f.length(); byte[] data ; if(r!=null){ String from=r.split("=")[1].split("-")[0]; String t=r.split("=")[1].split("-")[1]; off=Integer.parseInt(from); to=Integer.parseInt(t); } data= new byte[to-off]; f

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

若如初见. 提交于 2019-11-27 14:24:54
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 = (Button) findViewById(R.id.button1); b.setOnClickListener(new OnClickListener() { EditText text = (EditText

How to create equalizer for android

这一生的挚爱 提交于 2019-11-27 13:00:12
问题 I want to create simple equalizer for android. How can I do it? Try to find some methods in MediaPlayer class. But all my attempts failed. 回答1: Simple answer... you can't do it with the framework or with Java (because there is no JMF support in Android). You have to use the NDK and JNI to compile a native library with equalizer support. If you know C/C++ there are plenty of libraries around that will provide this functionality but if you don't know C/C++ or have the means to pay someone that

How to update the Android media database

巧了我就是萌 提交于 2019-11-27 12:57:01
My application shows the list of songs in sdcard, and there is an option to delete the song from SD card. Even when the song is deleted the song still comes in my applications list. How can I update the android media database and show the updated database? Android has a cache of sorts that keeps track of media files. Try this: sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); It makes the MediaScanner service run again, which should remove the deleted song from the device's cache. You also need to add this permission to