[HOT AUDIO MOD]♫♫♫ Increase Note2 volume significantly ♫♫♫ - Galaxy Note II Themes and Apps

[HOT AUDIO MOD]♫♫♫ Increase Note2 volume significantly ♫♫♫
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
WORKS FOR ODEXED/DEOXED ROMS, all you need just root
and default_gain.conf file /system/etc
•••ORIGINAL default_gain.conf file if you have forgot to backup•••
https://www.box.com/s/zk7uccelynr8v3i4tipt
INSTALLATION:
Video how to install this mod, big credits to ashwin123
FIRST METHOD:
1.Download this file:
ULTRA VOLUME MOD
MID VOLUME MOD (58DB WHILE ULTRA HAS 60DB)
NORMAL VOLUME MOD( A BIT LOUDER THAN DEFAULT (55DB)
2.Make backup default_gain.conf file which you can find at /system/etc
3.With root explorer overwrite downloaded default_gain.conf and if it will be successfully overwritten, reboot device. Dont forget to give permissions RW- RW- RW-
If you wont be able to overwrite that file, reboot device and try again to overwrite.
Attached file (default_gain.conf) was modified and was increased volume of:
ringtones
in call
speaker
headphones
Within 60dB!!!!! Be careful, listening to music so loud!!!!
SECOND METHOD (edit manually default_gain.conf if you want only boost volume of headphones and etc):
1.With root explorer (personally i use es file explorer) copy your default_gain.conf file to sd card or external.
2.Open that file and find this:
Modifier "Normal" {
SupportedDevice {
"Headset Out"
}
Enable {
{ "Headphone ZC Switch", 0 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Left Output Mixer DAC Volume", 7 },
{ "Right Output Mixer DAC Volume", 7 },
{ "Headphone Volume", 57 },
}
Disable {
{ "Headphone ZC Switch", 0 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Headphone Volume", 57 },
}
}
Modifier "Normal" {
SupportedDevice {
"Headphone"
}
Enable {
{ "Headphone ZC Switch", 0 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Left Output Mixer DAC Volume", 7 },
{ "Right Output Mixer DAC Volume", 7 },
{ "Headphone Volume", 57 },
}
Disable {
{ "Headphone ZC Switch", 0 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Headphone Volume", 52 },
}
}
By default DB of volume is 50, i have increased it to 57 and so far everything is fine.
Be carefully with increasing those values too much. 57 seems to be really loud listening music via headphones.
So after you change values in that file, save changes and then copy it to /system/etc and dont forget to give permissions!!!!
BE CAREFUL, I'M NOT RESPONSIBLE FOR YOUR ACTIONS!
Don' forget, for this mod you need root!!!

Thanks!
Sent from my GT-N7100 using Tapatalk 2

Reb0rn said:
Thanks!
Sent from my GT-N7100 using Tapatalk 2
Click to expand...
Click to collapse
worked for you? ;D so far no feedbacks lol

Yeah I saw that no one actually wrote anything... so I thought this awesome mod needed a bump
Sent from my GT-N7100 using Tapatalk 2

Reb0rn said:
Yeah I saw that no one actually wrote anything... so I thought this awesome mod needed a bump
Sent from my GT-N7100 using Tapatalk 2
Click to expand...
Click to collapse
thanks, btw i have increased to 59, no problems ;D i think siyah kernel for s3 used this method to increase headphones audio boosting ;D

EdgaBimbam said:
thanks, btw i have increased to 59, no problems ;D i think siyah kernel for s3 used this method to increase headphones audio boosting ;D
Click to expand...
Click to collapse
i increased to 57 and i definitely felt the diffrence,only thing bothers me is bass boost,previosly i have galaxy s1 and dsp manager does the trick but now i am not enjoying listening music on note 2,i tried to mess around with equilizer also but no luck with that.

gaurav2009 said:
i increased to 57 and i definitely felt the diffrence,only thing bothers me is bass boost,previosly i have galaxy s1 and dsp manager does the trick but now i am not enjoying listening music on note 2,i tried to mess around with equilizer also but no luck with that.
Click to expand...
Click to collapse
yeh same here, s3 with siyah kernel was so good at audio quality, bass was amazing. Maybe later will be more audio mods for note 2, i will try to ask gokhanmoral is it possible to implent his eargasm on note 2 stock kernel ;D

MBB_Gnex_v2_d3h.zip
Worked for me...
Google it.
Sent from my GT-N7100 using Tapatalk 2

hmmm got reply from gokhanmoral and he said that when he will have time, he will try to implent mdnie display tweak and audio tweak ;D

greaaaaat thank please help how can i increas IN CALL VOLUME:crying::crying::crying:

http://forum.xda-developers.com/showthread.php?t=1922715
Sent from my GT-N7100 using Tapatalk 2

Will this work on note 1

srinivas07 said:
Will this work on note 1
Click to expand...
Click to collapse
you could try, if you find these values, make copy of your old default_gain.conf and try to replace with modified. BUT MODIFY MANUALLY, DONT TRY TO REPLACE WITH DOWNLOADED FROM HERE!!!!!

navydata said:
greaaaaat thank please help how can i increas IN CALL VOLUME:crying::crying::crying:
Click to expand...
Click to collapse
you could try to edit this in your default_gain.cof
#Modifier : Incall
Modifier "Incall" {
SupportedDevice {
"Earpiece"
}
Enable {
{ "AIF2DAC2L Mixer AIF2 Switch", 0 },
{ "AIF2DAC2R Mixer AIF2 Switch", 0 },
{ "AIF2ADC HPF Mode", 1 },
{ "AIF2ADC HPF Switch", 1 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF2DAC Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "AIF2 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Left Output Mixer DAC Volume", 7 },
{ "Right Output Mixer DAC Volume", 7 },
{ "Output Volume", 57 },
{ "Earpiece Volume", 1 },
}
Disable {
{ "AIF1DAC1 Volume", 96 },
{ "AIF2DAC Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "AIF2 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Left Output Mixer DAC Volume", 7 },
{ "Right Output Mixer DAC Volume", 7 },
{ "Output Volume", 61 },
{ "Earpiece Volume", 1 },
}
}
try to increase to 59 or 60.

#Modifier : Incall
Modifier "Incall" {
SupportedDevice {
"Earpiece"
}
Enable {
{ "AIF2DAC2L Mixer AIF2 Switch", 0 },
{ "AIF2DAC2R Mixer AIF2 Switch", 0 },
{ "AIF2ADC HPF Mode", 1 },
{ "AIF2ADC HPF Switch", 1 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF2DAC Volume", 96 },
{ "AIF1 Boost Volume", 55 },
{ "AIF2 Boost Volume", 55 },
{ "DAC1 Volume", 96 },
{ "Left Output Mixer DAC Volume", 7 },
{ "Right Output Mixer DAC Volume", 7 },
{ "Output Volume", 63 },
{ "Earpiece Volume", 1 },
}
Disable {
{ "AIF1DAC1 Volume", 96 },
{ "AIF2DAC Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "AIF2 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Left Output Mixer DAC Volume", 7 },
{ "Right Output Mixer DAC Volume", 7 },
{ "Output Volume", 61 },
{ "Earpiece Volume", 60 },
i make this and it working GREAAAAAAAAAAAAAAAAAAAAAAAT THANKS MATE u save my live

Raised level to 59 and working perfectly. Sweeet.

gaurav2009 said:
i increased to 57 and i definitely felt the diffrence,only thing bothers me is bass boost,previosly i have galaxy s1 and dsp manager does the trick but now i am not enjoying listening music on note 2,i tried to mess around with equilizer also but no luck with that.
Click to expand...
Click to collapse
I don't know for you, but with Beats audio Monster in-ear headphones (the cheapest ones which were given with the HTC Sensation XE), I have very good sound without this mod (not tried yet) with bass boost and even better with the Custom equalizer, not even extended. I'm on Vein droid Rom, which is amazing by the way.
f.
Sent from my GT-N7100 using Tapatalk

I have installed this https://play.google.com/store/apps/details?id=com.motioncoding.beats and now sound quality is better, especially bass

Bit stuck on whether to do this or not?
I really really really HATE the low output I have in my car and have been re-directed from this thread I created: http://forum.xda-developers.com/showthread.php?p=33160556
I'm a bit worried about bricking my new device if I root it... Please can someone answer these questions for me as I am new to Android..
1 - If I root my device, JUST root it (not install a custom ROM or anything like that), will I still get the standard OTA updates for the next versions of Android?
2 - If I root my device JUST to change this stupid decibel thing, will it revert back to the standard 50db when I get a new update and it unroots my device?
3 - Is my warranty still void if I root my device? I've read about "flash counter" or something but I havent a clue what it means.
4 - If the rooting fails for some reason, is it easy enough to fix?
Thanks in advance. I'm pretty clueless to all this as you can see!!

Seriously your on the wrong forum buddy @srinivas

Related

[Q] want to increase volume in [4.4.2] DN3 (Ditto Note 3) V5 60 or 63db

is there anyway to Increase Volume in [4.4.2] DN3 (Ditto Note 3) V5 60 or 63db
Hurricane sound boost tool is the best of the universe. Flash v2 and choose the level 60 or 63
http://forum.xda-developers.com/showthread.php?t=2634647
Regards.
Sent from my GT-N7100 using XDA Premium 4 mobile app
q
:good:
Just download es file manager.. give it root privileges and open the following..
System/etc and find file default_gain.conf
Modifier "Normal" {
SupportedDevice {
"Speaker"
}
Enable {
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "SPKL DAC1 Volume", 1 },
{ "SPKR DAC1 Volume", 1 },
{ "Speaker Mixer Volume", 3 },
{ "Speaker Boost Volume", 4 },
{ "Speaker Volume", XX},
}
Disable {
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "SPKL DAC1 Volume", 1 },
{ "SPKR DAC1 Volume", 1 },
{ "Speaker Mixer Volume", 0 },
{ "Speaker Volume", XX },
{ "Speaker Boost Volume", 0 },
}
}
Modifier "Normal" {
SupportedDevice {
"Headset Out"
}
Enable {
{ "Headphone ZC Switch", 0 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Left Output Mixer DAC Volume", 7 },
{ "Right Output Mixer DAC Volume", 7 },
{ "Headphone Volume", XX },
}
Disable {
{ "Headphone ZC Switch", 0 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Headphone Volume", XX },
}
}
Just change the values in the 'XX' to 60 but not more than 65.
U r done my friend
Modifier "Normal" {
SupportedDevice {
"Headphone"
}
Enable {
{ "Headphone ZC Switch", 0 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Left Output Mixer DAC Volume", 7 },
{ "Right Output Mixer DAC Volume", 7 },
{ "Headphone Volume", XX },
}
Disable {
{ "Headphone ZC Switch", 0 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Headphone Volume", XX },
}
Sent from my GT-N7100 using Tapatalk
Bhupen Gaitonde said:
Just download es file manager.. give it root privileges and open the following..
System/etc and find file default_gain.conf
Modifier "Normal" {
SupportedDevice {
"Speaker"
}
Enable {
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "SPKL DAC1 Volume", 1 },
{ "SPKR DAC1 Volume", 1 },
{ "Speaker Mixer Volume", 3 },
{ "Speaker Boost Volume", 4 },
{ "Speaker Volume", XX},
}
Disable {
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "SPKL DAC1 Volume", 1 },
{ "SPKR DAC1 Volume", 1 },
{ "Speaker Mixer Volume", 0 },
{ "Speaker Volume", XX },
{ "Speaker Boost Volume", 0 },
}
}
Modifier "Normal" {
SupportedDevice {
"Headset Out"
}
Enable {
{ "Headphone ZC Switch", 0 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Left Output Mixer DAC Volume", 7 },
{ "Right Output Mixer DAC Volume", 7 },
{ "Headphone Volume", XX },
}
Disable {
{ "Headphone ZC Switch", 0 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Headphone Volume", XX },
}
}
Just change the values in the 'XX' to 60 but not more than 65.
U r done my friend
Modifier "Normal" {
SupportedDevice {
"Headphone"
}
Enable {
{ "Headphone ZC Switch", 0 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Left Output Mixer DAC Volume", 7 },
{ "Right Output Mixer DAC Volume", 7 },
{ "Headphone Volume", XX },
}
Disable {
{ "Headphone ZC Switch", 0 },
{ "AIF1DAC1 Volume", 96 },
{ "AIF1 Boost Volume", 0 },
{ "DAC1 Volume", 96 },
{ "Headphone Volume", XX },
}
Sent from my GT-N7100 using Tapatalk
Click to expand...
Click to collapse
Please don't mind mate.
These methods are so complicated for noobs and a hassle also for everyone.
Why should one do these much things while a simple recovery flashable zip with options like 58db/60db/63db in aroma is available!!
Regards.
Sent from my GT-N7100 using XDA Premium 4 mobile app
I know friend..
But this is the easiest way.
It's very easy. I am also a noob compared to all of u. But still I find it very easy by this method.
Sent from my GT-N7100 using Tapatalk
Bhupen Gaitonde said:
I know friend..
But this is the easiest way.
It's very easy. I am also a noob compared to all of u. But still I find it very easy by this method.
Sent from my GT-N7100 using Tapatalk
Click to expand...
Click to collapse
You mean editing system file is easier than flash a zip?☺
Sent from my GT-N7100 using XDA Premium 4 mobile app
At least for this case it's easy. Because it works.
U just have to change the values as per ur requirement. Keeping in mind the potential of ur handset Speaker and Headset.
Sent from my GT-N7100 using Tapatalk
Bhupen Gaitonde said:
At least for this case it's easy. Because it works.
U just have to change the values as per ur requirement. Keeping in mind the potential of ur handset Speaker and Headset.
Sent from my GT-N7100 using Tapatalk
Click to expand...
Click to collapse
Maybe mate, but universal truth is every user prefers cwm flashable zips and if it has aroma to choose, then it feels like 'finally I got what I want'. The sound boost mod of @wesamothman got four options, stock medium high and extreme, so, one can choose his desired boost, if he feels it is not good, simply flash the zip again and choose another mod, no need to edit system files. Suppose I am a noob, I don't know anything, just got a rooted device, in this case which questions will arise?
#which file explorer should I use?
#how to open that file?
#how to edit that file?
#how to save the edited file?
#should I keep the original one? Or just edit the existing one?
#what to do if I want my stock sound back?
#i want more sound, not happy
#..........
Regards.
Sent from my GT-N7100 using XDA Premium 4 mobile app
Wow.. good answer.
Appreciate it. But I still feel that the option I mentioned is better than flash.
U just think..
Sent from my GT-N7100 using Tapatalk
Bhupen Gaitonde said:
Wow.. good answer.
Appreciate it. But I still feel that the option I mentioned is better than flash.
U just think..
Sent from my GT-N7100 using Tapatalk
Click to expand...
Click to collapse
Lol...thinking about it is just wastage of time for me mate. Users will choose the easier way.
Regards.
Sent from my GT-N7100 using XDA Premium 4 mobile app
Then go ahead..
Regards to u too..
Sent from my GT-N7100 using Tapatalk
i also have a thread.. files can be taken from there..
i am a noob but have done a decent job..
geekynoob said:
i also have a thread.. files can be taken from there..
i am a noob but have done a decent job..
Click to expand...
Click to collapse
Lol mate...I used your file for a long long time. It's really noob friendly.
Regards.
Sent from my GT-N7100 using XDA Premium 4 mobile app

[MOD] [MM] increase audio for headphones

Hi all I just bought a Note 4, immediately updated to Marshmallow, and I noticed the headphones volume was really lower than in my Note 2. I gave a look in Xda but didn't find any mod to increase audio level, so this is my solution. Of course you need root access..
Go in /Etc folder, copy default_gain.conf file to another directory and open it (I used Es note editor, which is bundled with Es file explorer).
Find the following lines:
Modifier "Normal" {
SupportedDevice {
"Headset Out"
}
Enable {
{ "Noise Gate Switch", 0 },
{ "HPOUT1L Impedance Volume", 113 },
{ "HPOUT1R Impedance Volume", 113 },
{ "HPOUT1L Input 1 Volume", 32 },
{ "HPOUT1R Input 1 Volume", 32 },
}
}
Modifier "Normal" {
SupportedDevice {
"Headphone"
}
Enable {
{ "Noise Gate Switch", 0 },
{ "HPOUT1L Impedance Volume", 113 },
{ "HPOUT1R Impedance Volume", 113 },
{ "HPOUT1L Input 1 Volume", 32 },
{ "HPOUT1R Input 1 Volume", 32 },.
All you have to do is to change the value in the strings
{ "HPOUT1L Input 1 Volume", SET THE VALUE YOU LIKE },
{ "HPOUT1R Input 1 Volume", SET THE VALUE YOU LIKE }
I changed it into 48 and it's enough for me, so my lines are as follows
Modifier "Normal" {
SupportedDevice {
"Headset Out"
}
Enable {
{ "Noise Gate Switch", 0 },
{ "HPOUT1L Impedance Volume", 113 },
{ "HPOUT1R Impedance Volume", 113 },
{ "HPOUT1L Input 1 Volume", 48 },
{ "HPOUT1R Input 1 Volume", 48 },
}
}
Modifier "Normal" {
SupportedDevice {
"Headphone"
}
Enable {
{ "Noise Gate Switch", 0 },
{ "HPOUT1L Impedance Volume", 113 },
{ "HPOUT1R Impedance Volume", 113 },
{ "HPOUT1L Input 1 Volume", 48 },
{ "HPOUT1R Input 1 Volume", 48 },
Now you have just to backup your original file, then copy the edited one in /Etc folder, set permissions to rw-r--r-- (I use root browser which is free) and reboot.
You headphones audio is much higher now
Link to my .conf file:
https://www.androidfilehost.com/?fid=24533103863138198
Hye you should share your own .conf file.
Sent from my SM-N910C using XDA-Developers mobile app
File added. Anyway maybe the mod adds a little bit of digital noise, even if I'm not sure about it. Please report your opinions.
Will it work if i am already having high loud sound..i want to make my phone sound normal
you perfect op! thank you.
gabripranzo said:
File added. Anyway maybe the mod adds a little bit of digital noise, even if I'm not sure about it. Please report your opinions.
Click to expand...
Click to collapse
because to me m8 works perfect your file thanks!!!
hmm... damn. sounds fantastic but won't work for my bluetooth headphones ... any recommendation where to change those values? thanks in advance!
edit: got it after reboot it was neccessary to decrease and increase the volume at the headphones. now the maximum is quite enough thanks mate.
Finally Found This!!! Thanks Alot @gabripranzo , i tried something different i've read somewhere the first row that contains "Headphone" & The 1st row that contains "Headset Out" in it i changed the value there of both (Left & Right) 113 to 125 & It works perfectly without any music stops! This Works better IMO. than the bottom lines that has 32 bec. When i changed the values there to 44 music always stopped at max volume.
MTranceAvB said:
Finally Found This!!! Thanks Alot @gabripranzo , i tried something different i've read somewhere the first row that contains "Headphone" & The 1st row that contains "Headset Out" in it i changed the value there of both (Left & Right) 113 to 125 & It works perfectly without any music stops! This Works better IMO. than the bottom lines that has 32 bec. When i changed the values there to 44 music always stopped at max volume.
Click to expand...
Click to collapse
I'm glad you found the right solution for you. I think music stops when you overcharge the amplifier, I experienced the same thing with my Note 8.0 tablet with Boeffla kernel: it allows to tweak the volume, but if it's set too high (I did it because I have high impedance headphones) music stops, probably to avoid damages.
In the end I bought a USB DAC/amp to connect to my Note 4 and I'm very happy with it

‘GymOut’- An Awareness Kit Application designed For Work Out.

This article is originally from HUAWEI Developer Foum
Forum link: https://forums.developer.huawei.com/forumPortal/en/home​
About GymOut:
GymOut is a simple work out App which uses some of the features of HMS awareness Kit. In this, we have to set Gym location (here it is taking current location) and work out time. Once we enter into Gym it prompts us to plug in the head set to listen the work out music. The music will stop playing after the completion of work out /on leaving the gym.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
An Introduction for Awareness Kit:
HUAWEI Awareness Kit provides your app with the ability to obtain contextual information including users' current time, location, behavior, audio device status, ambient light, weather, and nearby beacons. Through this features the app can gain insight into a user's current situation more efficiently, making it possible to deliver a smarter, more considerate user experience
· Capture API
The Capture API allows the app to request the current user status, such as time, location, behaviour, and whether a headset is connected. For example, it can request location for getting latitude and longitude.
· BarrierAPI
The Barrier API allows the app to set a combination of contextual conditions. When the preset contextual conditions are met, the app will receive a notification. We can even accommodate our app with different combinations of contextual conditions to support different use cases. For example, we will get notification once we enter into a specified location.
Software Requirements
Android Studio
Java JDK 1.8 or later
Huawei Mobile Services (APK) 4.0.0.300 or later
Integration
1. Create a project in android studio and Huawei AGC.
2. Provide the SHA-256 Key in App Information Section.
3. Provide storage location. (Selected Singapore here)
4. Download the agconnect-services.json from AGCand save into app directory.
5. In root build.gradle
Go to allprojects->repositories and buildscript->repositories and the given line.
Code:
maven { url 'http://developer.huawei.com/repo/' }
In dependency add class path
Code:
classpath 'com.huawei.agconnect:agcp:1.2.1.301'
6. In app build.gradle
We have to add signingConfigs and buildTypes, otherwise we have to create signed apk for awareness testing.
Code:
signingConfigs {
release {
storeFile file('store.jks')
keyAlias 'mykey'
keyPassword 'hmsapp'
storePassword 'hmsapp'
v1SigningEnabled true
v2SigningEnabled true
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
signingConfig signingConfigs.release
debuggable true
}
}
Add Implementation
Code:
implementation 'com.huawei.hms:awareness:1.0.4.301'
Apply plugin
Code:
apply plugin: 'com.huawei.agconnect'
7. The app need the following permissions
Code:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="com.huawei.hms.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
Code Implementation:
In this application we are using the following HMS Features:
Capture API
Location Capture: For getting gym Latitude and Longitude.
Barrier API
Location Barrier: To get notification when entering into Gym and exit from Gym .
Headset Barrier:To get alert to connect Head set for workout music
Time Barrier: To alert, once the time elapses the specified workout time.
To capture Location API using getLocation () function
Code:
private void getLocation() {
Awareness.getCaptureClient(this).getLocation()
.addOnSuccessListener(new OnSuccessListener<LocationResponse>() {
@Override
public void onSuccess(LocationResponse locationResponse) {
Location location = locationResponse.getLocation();
latitude=location.getLatitude();
longitude=location.getLongitude();
Toast.makeText(getApplicationContext(),"Longitude:" + longitude
+ ",Latitude:" + latitude,Toast.LENGTH_SHORT).show();
mLogView.printLog("Longitude:" + longitude
+ ",Latitude:" + latitude);
mp = MediaPlayer.create(getApplicationContext(), R.raw.audio);
mp.setLooping(true);
alert_stayTimeDialog();
//add_locationBarrier_enter
AwarenessBarrier enterBarrier = LocationBarrier.enter(latitude, longitude, radius);
Utils.addBarrier(getApplicationContext(), ENTER_BARRIER_LABEL, enterBarrier, mPendingIntent);
AwarenessBarrier exitBarrier = LocationBarrier.exit(latitude, longitude, radius);
Utils.addBarrier(getApplicationContext(), EXIT_BARRIER_LABEL, exitBarrier, mPendingIntent);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Toast.makeText(getApplicationContext(),"Failed to get the location.",Toast.LENGTH_SHORT).show();
mLogView.printLog("Failed to get the location.");
Log.e(TAG, "Failed to get the location.", e);
}
});
mScrollView.postDelayed(()-> mScrollView.smoothScrollTo(0,mScrollView.getBottom()),200);
}
Using GymBarrierReceiver to receive the broadcast sent by Awareness Kit when the barrier status changes.
Code:
final class GymBarrierReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
BarrierStatus barrierStatus = BarrierStatus.extract(intent);
String label = barrierStatus.getBarrierLabel();
int barrierPresentStatus = barrierStatus.getPresentStatus();
switch (label) {
case ENTER_BARRIER_LABEL:
if (barrierPresentStatus == BarrierStatus.TRUE) {
mLogView.printLog("You are in Gym");
alert_startWorkOutDialog();
} else if (barrierPresentStatus == BarrierStatus.FALSE) {
// mLogView.printLog("You are away from Gym");
} else {
mLogView.printLog("The location status is unknown.");
}
break;
case STAY_BARRIER_LABEL:
if (barrierPresentStatus == BarrierStatus.TRUE) {
mLogView.printLog("You have to spent "
+ workOutTime + " minutes in Gym");
} else if (barrierPresentStatus == BarrierStatus.FALSE) {
mLogView.printLog("Your time of duration in Gym is Over.");
} else {
mLogView.printLog("The location status is unknown.");
}
break;
case EXIT_BARRIER_LABEL:
if (barrierPresentStatus == BarrierStatus.TRUE) {
mLogView.printLog("You are exiting Gym");
mp.pause();
play_pause.setBackground(getDrawable(android.R.drawable.ic_media_play));
} else if (barrierPresentStatus == BarrierStatus.FALSE) {
// mLogView.printLog("You are in Gym");
} else {
mLogView.printLog("The location status is unknown.");
}
break;
case KEEPING_BARRIER_LABEL:
if (barrierPresentStatus == BarrierStatus.TRUE) {
mLogView.printLog("Audio is playing...");
play_pause.setVisibility(View.VISIBLE);
mp.start();
play_pause.setBackground(getDrawable(android.R.drawable.ic_media_pause));
} else if (barrierPresentStatus == BarrierStatus.FALSE) {
mLogView.printLog("Connect headset to play audio");
mp.pause();
play_pause.setBackground(getDrawable(android.R.drawable.ic_media_play));
} else {
mLogView.printLog("The headset status is unknown.");
}
break;
case CONNECTING_BARRIER_LABEL:
if (barrierPresentStatus == BarrierStatus.TRUE) {
mLogView.printLog("The headset is connecting. Audio is playing");
play_pause.setVisibility(View.VISIBLE);
mp.start();
play_pause.setBackground(getDrawable(android.R.drawable.ic_media_pause));
} else if (barrierPresentStatus == BarrierStatus.FALSE) {
} else {
mLogView.printLog("The headset status is unknown.");
}
break;
case DURING_TIME_PERIOD_BARRIER_LABEL:
if (barrierPresentStatus == BarrierStatus.TRUE) {
mLogView.printLog("Your Work out is "+workOutTime+" minutes.");
} else if (barrierPresentStatus == BarrierStatus.FALSE) {
mLogView.printLog("Work out time reached "+workOutTime+" minutes.");
} else {
mLogView.printLog("The time status is unknown.");
}
break;
default:
break;
}
mScrollView.postDelayed(()-> mScrollView.smoothScrollTo(0,mScrollView.getBottom()*3),200);
}
}
MediaPlayer is added as given :
Code:
MediaPlayer mp = MediaPlayer.create(this, R.raw.audio);
mp.setLooping(true);
CountDownTimer to notify remaining workout time:
Code:
public void countDown(long workOutInMs){
new CountDownTimer(workOutInMs,1000) {
@Override
public void onTick(long millisUntilFinished) {
int seconds = (int) (millisUntilFinished / 1000);
int minutes = seconds / 60;
seconds = seconds % 60;
workOut_txt.setText(String.format("%d:%02d", minutes, seconds));
// counter++;
}
@Override
public void onFinish() {
workOut_txt.setText("Your work out is over");
mp.pause();
play_pause.setBackground(getDrawable(android.R.drawable.ic_media_play));
play_pause.setVisibility(View.GONE);
}
}.start();
}
Added different barriers as given:
Code:
AwarenessBarrier enterBarrier = LocationBarrier.enter(latitude, longitude, radius);
Utils.addBarrier(getApplicationContext(), ENTER_BARRIER_LABEL, enterBarrier, mPendingIntent);
AwarenessBarrier exitBarrier = LocationBarrier.exit(latitude, longitude, radius);
Utils.addBarrier(getApplicationContext(), EXIT_BARRIER_LABEL, exitBarrier, mPendingIntent);
AwarenessBarrier stayBarrier = LocationBarrier.stay(latitude, longitude, radius, workOutInMs);
Utils.addBarrier(getApplicationContext(), STAY_BARRIER_LABEL, stayBarrier, mPendingIntent);
AwarenessBarrier keepingConnectedBarrier = HeadsetBarrier.keeping(HeadsetStatus.CONNECTED);
Utils.addBarrier(getApplicationContext(), KEEPING_BARRIER_LABEL, keepingConnectedBarrier, mPendingIntent);
AwarenessBarrier connectingBarrier = HeadsetBarrier.connecting();
Utils.addBarrier(getApplicationContext(), CONNECTING_BARRIER_LABEL, connectingBarrier, mPendingIntent);
AwarenessBarrier timePeriodBarrier = TimeBarrier.duringTimePeriod(currentTimeStamp,
currentTimeStamp + workOutInMs);
Utils.addBarrier(getApplicationContext(), DURING_TIME_PERIOD_BARRIER_LABEL,
timePeriodBarrier, mPendingIntent);
The function alert_stayTimeDialog() is used to capture user workout time.
Code:
void alert_stayTimeDialog(){
final EditText edittext = new EditText(this);
edittext.setText("0");
edittext.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_CLASS_NUMBER);
AlertDialog.Builder alert = new AlertDialog.Builder(
this);
alert.setMessage("Your Workout Time");
alert.setTitle("Enter time in minutes ");
alert.setView(edittext);
alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//What ever you want to do with the value
Editable YouEditTextValue = edittext.getText();
//OR
int stayTime = Integer.parseInt(edittext.getText().toString());
//Add the code after success
SharedPreferences.Editor editor = gymOutPref.edit();
editor.putBoolean("SET_WORKOUT", true);
editor.putInt("SET_WORKOUT_TIME", stayTime);
editor.commit();
workOutTime=stayTime;
set_workout.setEnabled(false);
set_workout.setBackground(getDrawable(R.drawable.button_style_disable));
delete_workout.setEnabled(true);
delete_workout.setBackground(getDrawable(R.drawable.button_style));
workOut_txt.setText("WorkOut Time:"+stayTime+" Mnts");
Toast.makeText(getApplicationContext(), "WorkOut Time: " + stayTime, Toast.LENGTH_LONG).show();
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// what ever you want to do with No option.
}
});
alert.show();
}

Make your own music player with Audio Kit: Part 3

More information like this, you can visit HUAWEI Developer Forum​
Original article link: https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201327669408150034&fid=0101187876626530001
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
After completing part two, which is "); background-size: 1px 1px; background-position: 0px calc(1em + 1px); font-size: 18px; text-decoration: underline;">here, not much left to implement, don’t you worry. Now. we will implement our playlist and a few additional UX-related features about it. Then we will implement advanced playback control buttons to further develop our versatility.
We will be using RecyclerView for the playlist and AudioKit play modes for the advanced playback controls. AudioKit makes it incredibly easy to implement those modes. Also, for viewing the playlist, I will use a bit “unconventional” ways and you can decide how unconventional it is.
If you remember our "); background-size: 1px 1px; background-position: 0px calc(1em + 1px); font-size: 18px; text-decoration: underline;">part 1, I said this:
Now, it is time to explain that code, because we will first implement the playlist feature, before implementing the advanced playback controls.
There I did this:
It first gets my custom adapter called PlaylistAdapter, set the layout manager of my RecyclerView (my playlist), sets the onClickListeners (to choose a song from) and finally calls the super method so that after initializing our managers in the task, let the AsyncTask do the rest that needs to be done.
If you have uncommented here previously, it is time to uncomment now and also let me share and explain the code of PlaylistAdapter, so you will not get ‘undefined’ errors. Create a new Java file for this, as you do for all adapters.
Code:
public class PlaylistAdapter extends RecyclerView.Adapter {
public interface OnItemClickListener {
void onItemClick (List myPlayList, int position);
}
private PlaylistAdapter.OnItemClickListener onItemClickListener;
List myPlayList;
public PlaylistAdapter(List myPlayList){
this.myPlayList = myPlayList;
}
public void setOnItemClickListener(PlaylistAdapter.OnItemClickListener onItemClickListener) {
this.onItemClickListener = onItemClickListener;
}
static class PlayListView extends RecyclerView.ViewHolder {
TextView songNameTextView;
TextView songArtistTextView;
TextView durationTextView;
ImageView moreOptionsImageView;
public PlayListView(View itemView) {
super(itemView);
songNameTextView = itemView.findViewById(R.id.songTitleTextView);
songArtistTextView = itemView.findViewById(R.id.songArtistTextView);
durationTextView = itemView.findViewById(R.id.durationTextView);
moreOptionsImageView = itemView.findViewById(R.id.moreOptionsImageView);
}
}
@NonNull
@Override
public PlayListView onCreateViewHolder(ViewGroup parent, int viewType) {
View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.playlist_detail_layout, parent, false);
return new PlayListView(layoutView);
}
@Override
public void onBindViewHolder(final PlayListView holder, final int position) {
HwAudioPlayItem currentItem = myPlayList.get(holder.getAdapterPosition());
holder.songNameTextView.setText(currentItem.getAudioTitle());
holder.songArtistTextView.setText(currentItem.getSinger());
long durationOfSong = currentItem.getDuration();
String totalDurationText = String.format(Locale.US, "d:d",
TimeUnit.MILLISECONDS.toMinutes(durationOfSong),
TimeUnit.MILLISECONDS.toSeconds(durationOfSong) -
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(durationOfSong))
);
holder.durationTextView.setText(totalDurationText);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(onItemClickListener != null) {
onItemClickListener.onItemClick(myPlayList, position);
}
}
});
}
@Override
public int getItemCount() {
return myPlayList.size();
}
}
This is one of the efficient and expandable (or let’s say: future-proof) ways of implementing onClickListener for a RecyclerView. There are other methods too and if you are knowledgable, you can implement your own way clicking RecyclerView items.
Since in part 1, I assumed some level of Android knowledge for this tutorial, I will not explain everything in the adapter, because it is not very very different than a normal custom adapter. I additionally implemented button interfaces. My constructor only has the playlist element, which I later process to view it in the playlist. I still convert my time 00:00 format because it is still a long value.
Also, do not forget to do this in your MainActivity:
And, because of that, you must implement onItemClick(…) method in the activity.
Code:
@Override
public void onItemClick(List myPlayList, int position) {
if (mHwAudioPlayerManager != null && mHwAudioQueueManager != null && mHwAudioQueueManager.getAllPlaylist() != null) {
/*
* 1. Obtains a playlist using the mHwAudioQueueManager.getAllPlaylist() method.
* 2. Compare myPlayList with mHwAudioQueueManager.
*/
if (mHwAudioQueueManager.getAllPlaylist() == myPlayList) {
//If the two playlists are the same, the user-specified song is played.
mHwAudioPlayerManager.play(position);
} else {
//If the two playlists are different, the mHwAudioPlayerManager playlist is updated.
//The music specified by the user is played.
mHwAudioPlayerManager.playList(playList, position, 0);
mHwAudioPlayerManager.setPlayMode(0);
mHwAudioQueueManager.setPlaylist(playList);
Log.w("Playlist", mHwAudioQueueManager.getAllPlaylist() + "");
}
}
}
/*
@Override
public void onItemClick(int position) {
if(mHwAudioPlayerManager != null){
mHwAudioPlayerManager.play(position);
}
}*/
And in MainActivity’s onItemClick(…) method, comments are put to further explain the code. If you do not like the verbose and think that this code looks complex, just comment the whole method and uncomment the below method (which is the same method with a simpler implementation). Be aware though, you should test it yourself to see whether it works for all cases.
Should you have any other questions regarding here (or anywhere else), please comment below, so I can address them.
Control Visibility
Now that our adapter is ready, we should control when/how the user can open it and when/how s/he can close it.
As I said before, my method may be a bit unconventional, so if you think you have a better idea you can implement it yourself. However, what I do is to add a constraint layout to the screen from the cover image to the bottom of the screen. Then, I control its visibility from GONE to VISIBLE, whenever the user clicks on the music button; and from VISIBLE to GONE whenever the user clicks on the music button and additionally, clicks on the back button.
Programmatically, I control the visibility in onCreate(…) method of the activity. And for the back button I override the onBackPressed(…) method. You can comment the onBackPressed(…) method completely and run the app, to see why I did it. This completely for user experience, in case the user wants to close the playlist with the back button click. I do it like this, it is simple enough to code them both:
Code:
@Override
protected void onCreate(Bundle savedInstanceState) {
//... your other codes
binding.containerLayout.setVisibility(View.GONE);
binding.playlistImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(binding.containerLayout.getVisibility() == View.GONE){
binding.containerLayout.setVisibility(View.VISIBLE);
}
else{
binding.containerLayout.setVisibility(View.GONE);
}
}
});
}
@Override
public void onBackPressed() {
if(binding.containerLayout.getVisibility() == View.VISIBLE){
binding.containerLayout.setVisibility(View.GONE);
}
else{
super.onBackPressed();
}
}
At first, I programmatically ensuring that the visibility of constraint layout is gone. You can also make it gone in the layout screen after you are done with the xml changes.
You should be done with the playlist now.
Advanced Playback Controls
Although they are called advanced controls, with the help of Huawei AudioKit, they are simpler to implement than they sound.
AudioKit offers 4 playback modes:
Code:
Playback modes:
0: sequential playback
1: shuffling songs
2: repeating a playlist
3: repeating a song
If you remember the code above, I set the playback mode as 0 in onItemClick(…) method, because we want the playback to be sequential if the user does not change anything explicitly.
Code:
protected void onCreate(Bundle savedInstanceState) {
//... your other codes
final Drawable shuffleDrawable = getDrawable(R.drawable.menu_shuffle_normal);
final Drawable orderDrawable = getDrawable(R.drawable.menu_order_normal);
final Drawable loopItself = getDrawable(R.drawable.menu_loop_one_normal);
final Drawable loopPlaylist = getDrawable(R.drawable.menu_loop_normal);
binding.shuffleButtonImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(mHwAudioPlayerManager != null){
if(binding.shuffleButtonImageView.getDrawable().getConstantState().equals(shuffleDrawable.getConstantState())){
mHwAudioPlayerManager.setPlayMode(0);
binding.shuffleButtonImageView.setImageDrawable(getDrawable(R.drawable.menu_order_normal));
Toast.makeText(MainActivity.this,"Normal order",Toast.LENGTH_SHORT).show();
}
else if(binding.shuffleButtonImageView.getDrawable().getConstantState().equals(orderDrawable.getConstantState())){
mHwAudioPlayerManager.setPlayMode(1);
binding.shuffleButtonImageView.setImageDrawable(getDrawable(R.drawable.menu_shuffle_normal));
Toast.makeText(MainActivity.this,"Shuffle songs",Toast.LENGTH_SHORT).show();
}
}
}
});
binding.loopButtonImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(mHwAudioPlayerManager != null){
if(binding.loopButtonImageView.getDrawable().getConstantState().equals(loopItself.getConstantState())){
mHwAudioPlayerManager.setPlayMode(2);
binding.loopButtonImageView.setImageDrawable(getDrawable(R.drawable.menu_loop_normal));
Toast.makeText(MainActivity.this,"Loop playlist",Toast.LENGTH_SHORT).show();
}
else if(binding.loopButtonImageView.getDrawable().getConstantState().equals(loopPlaylist.getConstantState())){
mHwAudioPlayerManager.setPlayMode(3);
binding.loopButtonImageView.setImageDrawable(getDrawable(R.drawable.menu_loop_one_normal));
Toast.makeText(MainActivity.this,"Loop the song",Toast.LENGTH_SHORT).show();
}
}
}
});
}
Let’s understand here. I get my drawables at first to compare them to each other. (You should know where to get them from by now, if you do not have them already.) After that, I implement onClicks of the buttons and change the playback modes as per the list I have given above. Also, I change the drawable to current playback drawable for better usability. At the end of every change, I notify the user about the change so that s/he knows what s/he just has changed into.
This feature also gives a good competitive edge, because with these buttons implemented, our music player looks more professional.
That is the end of my tutorial. I hope that you have benefitted from it. If you have any questions about any part of this tutorial, please comment in the related section. See you in the next tutorial!

HMS Video Kit — 2

HMS Video Kit — 2
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
In this article, we are going to use some of the other important features of the video kit.
Settings Dialog
With this dialog, users will be able to change the playback options of the video. When the user clicks on TextView which is called Settings, the options will pop up through alert dialog.
Settings
First of all, I will shortly explain how we get the click actions on one of the settings clicked and then I will explain them all separately.
For the settings dialog, we create DialogUtil.java and PlaySettingDialog.java class that implements DialogInterface.OnClickListener. In its initDialog method, we get the playSettingType and OnPlaysettingListener interface and assign them to their local instance variables.
Java:
public PlaySettingDialog initDialog(OnPlaySettingListener playSettingListener, int playSettingType) {
this.onPlaySettingListener = playSettingListener;
this.playSettingType = playSettingType;
return this;
}
Here, OnPlaySettingListener is an interface that we will get its callback on our PlayActivity.java class to determine the selected item and setting type.
Java:
/**
* The player setting listener
*/
public interface OnPlaySettingListener {
/**
* Dialog select listener
*
* @param itemSelect The selected text
* @param settingType The corresponding operation type of player
*/
void onSettingItemClick(String itemSelect, int settingType);
}
When the user clicks on an item from the settings dialog, inside of its OnClick() method, we set the onSettingItemClick and cancel the alert dialog.
Java:
@Override
public void onClick(DialogInterface dialog, int which) {
if (onPlaySettingListener != null) {
onPlaySettingListener.onSettingItemClick(showTextList.get(which).first, playSettingType);
}
dialog.dismiss();
}
Now, I would like to go top again to our PlayActivity.java class. As you remember we have a play_view.xml layout file and onClick listener for some of our View components. We call onSettingDialog method when the user clicks on Settings TextView.
Java:
@Override
public void onClick(View v) {
switch (v.getId()) {
...
case R.id.setting_tv:
onSettingDialog();
break;
...
}
}
We prepare the text list of our settings dialog and call the showSettingDialog of our playView object. Then it calls the onSettingDialogSelectIndex method of DialogUtil class that will create a new PlaySettingDialog object and prepare it for the user.
Java:
/**
* Show the Settings dialog
*/
private void onSettingDialog() {
List<String> showTextList = new ArrayList<>();
showTextList.add(StringUtil.getStringFromResId(this, R.string.video_set_bandwidth_mode));
showTextList.add(StringUtil.getStringFromResId(this, R.string.video_stop_downloading));
showTextList.add(StringUtil.getStringFromResId(this, R.string.video_set_play_speed));
showTextList.add(StringUtil.getStringFromResId(this, R.string.play_mode));
showTextList.add(StringUtil.getStringFromResId(this, R.string.video_set_loop_play));
showTextList.add(StringUtil.getStringFromResId(this, R.string.video_mute_setting));
showTextList.add(StringUtil.getStringFromResId(this, R.string.video_set_volume));
playView.showSettingDialog(Constants.MSG_SETTING, showTextList, 0);
}
Lastly, when the user clicks on one of the items from the settings dialog, we get the itemSelect and settingType values in our PlayActivity’s onSettingItemClick callback thanks to OnPlaySettingListener interface.
Java:
@Override
public void onSettingItemClick(String itemSelect, int settingType) {
switch (settingType) {
case Constants.MSG_SETTING:
Log.d(TAG, "onSettingItemClick: MSG_SETTING CASE.");
if (TextUtils.equals(itemSelect,
StringUtil.getStringFromResId(PlayActivity.this, R.string.video_mute_setting))) {
switchVideoMute();
} else if (TextUtils.equals(itemSelect,
StringUtil.getStringFromResId(PlayActivity.this, R.string.video_set_bandwidth_mode))) {
switchBandwidthMode();
} else if (TextUtils.equals(itemSelect,
StringUtil.getStringFromResId(PlayActivity.this, R.string.video_set_play_speed))) {
setPlaySpeed();
} else if (TextUtils.equals(itemSelect,
StringUtil.getStringFromResId(PlayActivity.this, R.string.video_stop_downloading))) {
stopRequestStream();
} else if (TextUtils.equals(itemSelect,
StringUtil.getStringFromResId(PlayActivity.this, R.string.video_set_volume))) {
setVideoVolume();
} else if (TextUtils.equals(itemSelect,
StringUtil.getStringFromResId(PlayActivity.this, R.string.play_mode))) {
switchPlayMode();
} else if (TextUtils.equals(itemSelect,
StringUtil.getStringFromResId(PlayActivity.this, R.string.video_set_loop_play))) {
switchPlayLoop();
} else {
LogUtil.i(TAG, "current settings type is " + itemSelect);
}
break;
case Constants.PLAYER_SWITCH_PLAY_SPEED:
onSwitchPlaySpeed(itemSelect);
break;
case Constants.PLAYER_SWITCH_BANDWIDTH_MODE:
if (TextUtils.equals(itemSelect,
StringUtil.getStringFromResId(PlayActivity.this, R.string.open_adaptive_bandwidth))) {
playControl.setBandwidthSwitchMode(PlayerConstants.BandwidthSwitchMode.AUTO_SWITCH_MODE, true);
} else {
playControl.setBandwidthSwitchMode(PlayerConstants.BandwidthSwitchMode.MANUAL_SWITCH_MODE, true);
}
break;
...
}
}
I explained how the settings dialog works. You can also refer to my demo code for a better understanding. From now on, I will keep going with the features of the video kit.
Bandwidth Adaptation
It allows you to dynamically adapt the bitrate of the stream to varying network conditions and selects the most suitable bitrate for your app. Adaptive bitrate streaming works by detecting a user’s bandwidth and CPU capacity in real-time and adjusting the quality of the media stream accordingly. When the user clicks on Bandwidth adaptation we call the switchBandwidthMode() method.
Java:
/**
* Set the bandwidth switch
*/
private void switchBandwidthMode() {
List<String> showTextList = new ArrayList<>();
showTextList.add(getResources().getString(R.string.close_adaptive_bandwidth));
showTextList.add(getResources().getString(R.string.open_adaptive_bandwidth));
playView.showSettingDialog(Constants.PLAYER_SWITCH_BANDWIDTH_MODE, showTextList, Constants.DIALOG_INDEX_ONE);
}
When the user makes the choice, again we get it in onSettingItemClick callback of PlayActivity class.
Java:
@Override
public void onSettingItemClick(String itemSelect, int settingType) {
switch (settingType) {
...
case Constants.PLAYER_SWITCH_BANDWIDTH_MODE:
if (TextUtils.equals(itemSelect,
StringUtil.getStringFromResId(PlayActivity.this, R.string.open_adaptive_bandwidth))) {
playControl.setBandwidthSwitchMode(PlayerConstants.BandwidthSwitchMode.AUTO_SWITCH_MODE, true);
} else {
playControl.setBandwidthSwitchMode(PlayerConstants.BandwidthSwitchMode.MANUAL_SWITCH_MODE, true);
}
break;
...
}
}
Our playControl object’s setBandwidthSwitchMode() method will be called.
Java:
/**
* Set the bandwidth switching mode
*
* @param mod The bandwidth switching mode
* @param updateLocate Whether to update the local configuration
*/
public void setBandwidthSwitchMode(int mod, boolean updateLocate) {
if (wisePlayer != null) {
wisePlayer.setBandwidthSwitchMode(mod);
}
if (updateLocate) {
PlayControlUtil.setBandwidthSwitchMode(mod);
}
}
Here wisePlayer.setBandwidthSwitchMode() sets whether to enable adaptive bitrate streaming or keep using the current bitrate.
Download Control
This feature allows us to stop buffering if required. For instance, if you are watching a video on a mobile network and pause it, you can stop video buffering.
Java:
/**
* Whether to stop the downloading
*
* @param selectValue Select text value
*/
private void onSwitchRequestMode(String selectValue) {
if (selectValue.equals(StringUtil.getStringFromResId(PlayActivity.this, R.string.video_keep_download))) {
streamRequestMode = 0;
} else if (selectValue.equals(StringUtil.getStringFromResId(PlayActivity.this, R.string.video_stop_download))) {
streamRequestMode = 1;
}
LogUtil.i(TAG, "mStreamRequestMode:" + streamRequestMode);
playControl.setBufferingStatus(streamRequestMode == 0 ? true : false, true);
}
Here, for demonstration, if the user selects the stop download option, wisePlayer.setBufferingStatus() method will be called and the video buffering will stop.
Java:
public void setBufferingStatus(boolean status, boolean isUpdateLocal) {
if (wisePlayer != null && (isUpdateLocal || PlayControlUtil.isLoadBuff())) {
wisePlayer.setBufferingStatus(status);
if (isUpdateLocal) {
PlayControlUtil.setLoadBuff(status);
}
}
}
Playback Speed
Wiseplayer video kit allows us to change playback speed with setPlaySpeed() method call. In the demo project, I put that option to both settings dialog and the play speed button in activity_play.xml.
Java:
/**
* Set the speed
*
* @param speedValue The speed of the string
*/
public void setPlaySpeed(String speedValue) {
if (speedValue.equals("1.25x")) {
wisePlayer.setPlaySpeed(1.25f);
} else if (speedValue.equals("2.0x")) {
wisePlayer.setPlaySpeed(2.0f);
}
...
else {
wisePlayer.setPlaySpeed(1.0f);
}
}
Playback Mode
With this feature, we can set the playback mode to audio-only or audio+video.
Java:
/**
* Set play mode
*
* @param playMode Play mode
* @param updateLocate Whether to update the local configuration
*/
public void setPlayMode(int playMode, boolean updateLocate) {
if (wisePlayer != null) {
wisePlayer.setPlayMode(playMode);
}
if (updateLocate) {
PlayControlUtil.setPlayMode(playMode);
}
}
Repeat Mode
If we enable the repeat mode, after playing a video is finished, WisePlayer will not call PlayEndListener. Instead, it will play the video again from the beginning of it. To achieve it, we call the setCycleMode() method of the API.
Java:
/**
* Set cycle mode
*
* @param isCycleMode Whether open loop
*/
public void setCycleMode(boolean isCycleMode) {
if (wisePlayer != null) {
wisePlayer.setCycleMode(isCycleMode ? PlayerConstants.CycleMode.MODE_CYCLE : PlayerConstants.CycleMode.MODE_NORMAL);
}
}
Mute/Unmute
We can use the setMute(boolean status) method in order to indicate whether to mute a video or not.
Java:
/**
* Set the mute
*
* @param status Whether quiet
*/
public void setMute(boolean status) {
if (wisePlayer != null) {
wisePlayer.setMute(status);
}
PlayControlUtil.setIsMute(status);
}
Volume
We can set the playback volume by using the setVolume() method. The value ranges from 0 to 1.0. In the demo app, I have used a volume button in the activity_play.xml. We can set the volume either selecting it from the settings dialog or clicking on the volume button. I also used a seek bar for setting the desired volume level easily.
Java:
/**
* Set the volume, the current player is interval [0, 1]
*
* @param volume The volume interval [0, 1]
*/
public void setVolume(float volume) {
if (wisePlayer != null) {
LogUtil.d(TAG, "current set volume is " + volume);
wisePlayer.setVolume(volume);
}
}
In order to control the volume through the seek bar, we can add the code below.
Java:
public static void showSetVolumeDialog(Context context,
final OnDialogInputValueListener onDialogInputValueListener) {
View view = LayoutInflater.from(context).inflate(R.layout.set_volume_dialog, null);
final AlertDialog dialog =
new AlertDialog.Builder(context).setTitle(StringUtil.getStringFromResId(context, R.string.video_set_volume))
.setView(view)
.create();
dialog.show();
final SeekBar volumeSeek = (SeekBar) view.findViewById(R.id.seek_bar_volume);
volumeSeek.setProgress(0);
volumeSeek.setMax(100);
volumeSeek.setProgress(last_state);
volumeSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
float progress_f;
progress_f = (float) progress / 100;
onDialogInputValueListener.dialogInputListener(Float.toString(progress_f));
last_state = progress;
}
...
}
The maximum playback volume is determined by the current media volume of your phone.
Click to expand...
Click to collapse
You can find the source code of the demo app here.
In this article, we have used some of the important features of the video kit. HUAWEI Video Kit will support video editing and video hosting in later versions. Once the new features are released, I will be sharing a demo application that implements them.
For more information and features about the Video Kit, you can refer to the sources below.
RESOURCES
About the Service
API Reference
What are all the video format currently supports ,is there any limitation on file size?
sujith.e said:
What are all the video format currently supports ,is there any limitation on file size?
Click to expand...
Click to collapse
There is no limitation on file size. Also, the maximum resolution is 4K and the minimum is 270p.
It supports streaming media in 3GP, MP4, or TS format and complies with HTTP/HTTPS, HLS, or DASH.
How many errors code does it require?
Your explanations are very interesting.

Categories

Resources