How to play and pause MediaSession in Android - java

I'm trying to learn MediaSessions. I did a lot of research for music player which has MediaSession to learn how is it working. I found nothing about MediaSession. All music apps examples on youtube doesn't have MediaSession. I'm new in android and I did a music app but I didn't use MediaSession thefore I can't handle with headset keys, for example hook key . I really want to learn proper way to make an audio app.
Could you give a sample which is playing dummy audio with MediaSession and contains play and pause features please. All I need a sample Thank you.

The Universal Android Music Player Sample shows how to implement an audio media app that works across multiple form factors.
In the full guide, there's a media session and controller section you'd probably like to read.
You can find MediaSession implemented in the UAMP sample inside MusicService.
Other great resources:
Our new TV Reference App is tailored more towards video experiences on TV.
See also my codelab that steps through the basics of supporting MediaSessions.

Related

How to record video in background when having video calling in application

I am developing an application that will be use to record video in background once the video calling starts.I googled about it but didn't get any solution. Many articles say that it is not possible.
Please let me know the way to implement the functionality
What you can do is that you can simply record the screen of the phone. There are several libraries available for implementing that. You can trigger or alert the library to start recording the screen once the video call starts.

Android. Google Play Services Saved games API

I'm on the way to implement the Cloud Backup of progress that player achieved in the game so Saved Games function provided by Google Play Services looks like what I need.
After reading this documentation page about Saved Games I realized that it is not exactly what I need. Following the guide I have to show the new Activity for user where he's saving/loading the game progress, but I dont want to do that.
According to my idea no additional activities should be displayed, I want to do this on the background as non-visible for player task. Is there any way to do this the way I want?
I would appreciate any ideas. Thank you.
I think Google Play Games support automatic saving and loading. According to this video: Game On!: Cloud Save
7:26 of the video:
"the game does save to the cloud automatically"
and 7:55 of the video:
"And I'm just going to force a Cloud Load here by going into the Cloud Load menu. Notice that normally this would happen automatically"
What you have read in the document is the force save and load that can be seen in the Cload Save video.
If you notice:
Loading Saved Games
To improve your game's performance, you are encouraged to perform saved game loading as a background operation rather than in the main thread. One way to do this is by using an AsyncTask and override its doInBackground() method to open the saved game.
Here are github that can help you with save games implementation:
Google Play game services - Android Samples
AutoSaveUnitySample
Google Play Games plugin for Unity

Play YouTube Audio to a Specific Audio Device with Java

I've been looking around for quite some time to find a simple solution to the problem I am having.
Using Java, I'm trying to find a simple way to play the audio from a given YouTube URL to a selected audio mixer.
Looking around I see a few approaches, but they all appear to be missing an important aspect of what I'm looking for in one way or another
For example, using JavaFX or the JWebBrowser (in the DJ Native Swing library) both do not allow changing the audio output mixer, and the JavaFX browser no longer plays Youtube videos anyway.
I'd love to use the Java Sound API, as that allows audio mixer selection, but I don't really want to have to download the video, convert to wav, then play it. Using Java Sound is ideal if there is someway to steam the YouTube video audio to this API.
If you have any relatively straightforward way to play audio from a streamed YouTube video to a selectable audio device, please let me know.

Stream Video On Android Like YouTube

I want to play video on my android app with a player like YouTube.
My webapp is using videojs for playing different video formats.
I dont wish to use the native media player on android as i want to show portrait version of it and show the likes and comments beneath the video.
Currently am using a webview on the half of the layout and below that am using the layout for likes, comments etc.
So, What should i go for ? I want to use the player like YouTube. Is it even possible ?
Thanks !

how to record multiple sounds in musical application android

I am developing a musical piano app for android, in this app i want to record sound which user play by clicking piano buttons. I am using soundpool to play piano sounds. now for recording android gave us two api's MediaRecorder and AudioRecorder. but for both we have to set MediaRecorder.AudioSource. i didn't want to record sounds from mic because user sound can be included and more important sound quality decrease in recording. then i try to read bytes of that resource file which is played on clicking piano app. and when user click again and again then bytes will be together in global byte array. but when i play global byte array then this play only one resource file and one time only.
More important thing is i am new to android development. kindly guide me.
Although i did not find answer of my question, but now i am using technique for recording aspects which i want to share with all of you. Above function which i try to use is totally wrong option when you are trying to save music created by your app at run time. now for my first version i just saving the clicks of piano buttons along with system time in an array. now when i play that clicks it will play same sound as user try to record. i save these notes in database for further reuse by users.although this is not solution because these notes will be played in our app only, but this is good feature which we can add in our app. when i solve the correct solution, i will share with you guys

Categories

Resources