New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-23258] Android: Support audioSessionId getters #7989
Conversation
Test Code: var win = Titanium.UI.createWindow({
title:'Audio Test',
backgroundColor:'#fff',
layout: 'vertical'
});
var startStopButton = Titanium.UI.createButton({
title:'Start/Stop Streaming',
top:10,
width:200,
height:40
});
var pauseResumeButton = Titanium.UI.createButton({
title:'Pause/Resume Streaming',
top:10,
width:200,
height:40,
enabled:false
});
var getID = Titanium.UI.createButton({
title:'getId',
top:10,
width:200,
height:40
});
win.add(startStopButton);
win.add(pauseResumeButton);
win.add(getID);
// allowBackground: true on Android allows the
// player to keep playing when the app is in the
// background.
var audioPlayer = Ti.Media.createAudioPlayer({
url: 'http://www.noiseaddicts.com/samples_1w72b820/17.mp3',
allowBackground: true
});
startStopButton.addEventListener('click',function() {
// When paused, playing returns false.
// If both are false, playback is stopped.
if (audioPlayer.playing || audioPlayer.paused)
{
audioPlayer.stop();
pauseResumeButton.enabled = false;
if (Ti.Platform.name === 'android')
{
audioPlayer.release();
}
}
else
{
audioPlayer.start();
pauseResumeButton.enabled = true;
}
});
pauseResumeButton.addEventListener('click', function() {
if (audioPlayer.paused) {
audioPlayer.start();
}
else {
audioPlayer.pause();
}
});
audioPlayer.addEventListener('progress',function(e) {
Ti.API.info('Time Played: ' + Math.round(e.progress) + ' milliseconds');
});
audioPlayer.addEventListener('change',function(e)
{
Ti.API.info('State: ' + e.description + ' (' + e.state + ')');
});
win.addEventListener('close',function() {
audioPlayer.stop();
if (Ti.Platform.osname === 'android')
{
audioPlayer.release();
}
});
getID.addEventListener('click', function() {
alert("Audio Player Id:"+ audioPlayer.getAudioSessionId());
});
win.open(); Test steps:-
|
@AngelkPetkov we are feature freezing for 5.4.0. This should be fine to be added for 5.4.0. Before that, could you do a few things?
After that's done, could you get someone to review the documentation and code alignment? I think Hans should be fine with checking it. Once that's done, please merge this. |
Code functionally tested with the test case above and reviewed as mentioned above. This can be merged (by Hans, Hieu or Angel) once the above comments have been addressed. |
if (s != null) { | ||
return s.getAudioSessionId(); | ||
} | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation is off
[TIMOB-23258] Android: Added Documentation
Made indentation same as the rest of the class and added docs. Thanks Ash! |
JIRA
Community PR , FT please.