PhoneGap Playlist issue with iPhone App - iphone

I am creating a small fun application to play some mp3 files into a PhoneGap app
I have managed to play the audio in the background, many thanks to help on StackOverflow
But now the problem is when the app runs in background, or the app is locked, the next songs does not play. I have written the code to play the next song
=======
$(".greyselected").each(function(i) {
if($(this).is(":visible"))
{
activetrackclass = $(this).attr("class").split(" ")[0];
return;
}
});
$("." + activetrackclass).each(function(i){
if($(this).hasClass("greyselected"))
{
fetchmp3($("." + activetrackclass + ":eq(" + parseInt(i+1) + ")").find(".partistname").text(), $("." + activetrackclass + ":eq(" + parseInt(i+1) + ")").find(".ptrackname").text(), $("." + activetrackclass + ":eq(" + parseInt(i+1) + ")").find(".ptrackurl").text(), $("." + activetrackclass + ":eq(" + parseInt(i+1) + ")").find(".spanduration").text(), "tracklist");
$("." + activetrackclass).removeClass("greyselected");
$("." + activetrackclass + ":eq(" + parseInt(i+1) + ")").addClass("greyselected");
$("#divplayer").slideDown("slow");
return false;
}
});
=======
greyselected is the song currently playing
activetrackclass is a variable that holds the class of the track item or track div
fetchmp3 is the function to call the next mp3 file in the list
All mp3 are hosted on a server
When the app is active it plays just fine, but as soon as it goes to background it just plays the song which was actively playing and then stops until the app is made visible again
Would appreciate your valuable help as always

A background task only runs for a period of time, then the OS kills it. If your application is not active then it wont run forever and the ios will stop it after a while.
http://www.macworld.com/article/1164616/how_ios_multitasking_really_works.html
You can declare the support for background playback by specifying audio mode in UIBackgroundModes in Info.plist file. Check page 60 of iphone programming guide for more detail
You have lot of options to configure the behavior of the audio if you application can use the native code. Check the Categories Express Audio Roles in below docs.
http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007875
An old thread from Apple Developer Forum
https://devforums.apple.com/message/264397#264397

Related

Why Exoplayer 2.x is not switching to lower bitrates on low network during adaptive playback?

We are using exoplayer v2.x and are playing a HLS file which has 4 bitrate tracks.
When we configure exoplayer for adaptive playback, it is starting with a higher bitrate track but NOT switching back to a lower bitrate track when we throttle the network speed using Charles. The player seems to stick with the already selected higher bitrate track and keep on buffering instead of switching to a lower bitrate one.
We have configured the exoplayer in the following way:
private DefaultBandwidthMeter BANDWIDTH_METER =
new DefaultBandwidthMeter(mUiUpdateHandler, new BandwidthMeter.EventListener() {
#Override
public void onBandwidthSample(int elapsedMs, long bytes, long bitrate) {
Log.v(TAG, "Elapsed Time in MS " + elapsedMs + " Bytes " + bytes + " Bitrate " + bitrate);
bitrateEstimate = bitrate;
bytesDownloaded = bytes;
}
});
TrackSelection.Factory adaptiveTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
trackSelector = new DefaultTrackSelector(adaptiveTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(getActivity(), trackSelector,
new CustomLoadControl(new CustomLoadControl.EventListener() {
#Override
public void onBufferedDurationSample(long bufferedDurationUs) {
long bufferedDurationMs = bufferedDurationUs;
}
}, mUiUpdateHandler), drmSessionManager, extensionRendererMode);
Can anyone please confirm this is the correct way to configure the player? Also has anyone observed this problem and have a fix for this?
Thanks in advance.

Can't get the number of achievements from Unity game using Steamworks.NET

I was about to release a new game on Steam. It is a Unity game in which I use Steamworks.NET to get achievements from Steam.
I use the following code:
if (SteamManager.Initialized) {
string name = SteamFriends.GetPersonaName ();
Debug.Log (name+" - "+SteamUser.GetSteamID() );
m_GameID = new CGameID (SteamUtils.GetAppID ());
Debug.Log ("number of achievements: " + SteamUserStats.GetNumAchievements ());
Debug.Log ("gameID: " + m_GameID);
} else {
Debug.Log ("Steam not initialized");
}
m_GameID is set correctly (I use a steam_appid.txt file).
I use it for all my steam games, but for some reason SteamUserStats.GetNumAchievements () always returns 0.
I published the achievements on Steam, but still don't know why this is happening.
How I can correct that?
I discover the problem.
I just need to call SteamUserStats.RequestCurrentStats() in the update method. It's working now.

Unity isn't allowed to use location - Windows 10

I am using location services in a Unity 3D game. I am using this (slightly modified) script that I found in the Unity Documentation just for testing purposes. Here is the script:
using UnityEngine;
using System.Collections;
public class TestLocationService : MonoBehaviour
{
IEnumerator Start()
{
// First, check if user has location service enabled
if (!Input.location.isEnabledByUser)
print("no");
yield break;
// Start service before querying location
Input.location.Start();
// Wait until service initializes
int maxWait = 20;
while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
{
yield return new WaitForSeconds(1);
maxWait--;
}
// Service didn't initialize in 20 seconds
if (maxWait < 1)
{
print("Timed out");
yield break;
}
// Connection has failed
if (Input.location.status == LocationServiceStatus.Failed)
{
print("Unable to determine device location");
yield break;
}
else
{
// Access granted and location value could be retrieved
print("Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp);
}
// Stop service if there is no need to query location updates continuously
Input.location.Stop();
}
}
When I run the script, it is supposed to print my location. However, it thinks that location services are not enabled (I am using Windows 10) and just prints "no" before stopping. In my location settings, I have location enabled.
Why isn't Unity allowed to use my location?
Location access in Unity is for Handheld Devices Only(i.e. Mobiles and Tablets). You cannot use it on a Computer.
Unity Docs: https://docs.unity3d.com/ScriptReference/Input-location.html
You have to give Unity the permission to use the location services also.
If you scroll down on the screenshot that you posted, you will have to toggle the switch for Unity also.
If that doesn't work you might want to try installing some sort of geo sensor and see if it makes any difference.
Based on http://answers.unity3d.com/questions/1219218/windows-10-using-location-with-unity-through-pc-no.html the api Input.location.isEnabledByUser is supposed to work only for (handheld devices only)

Import existing animation file to unity web player model

I'm trying to import an existing .anim file to an existing unity model.
I know how do so it in Unity, and build into a HTML file, but I'm wondering is there a method to do it just using unityscript or javascript?
I mean using javascript to load an .anim file into the model in unity web player, if there is any solution, thanks!
Resource.Load allows you to do just that.
var mdl : GameObject = Resources.Load("Animations/"+ animationFolder+"/" + aName);
if (!mdl) {
Debug.LogError("Missing animation asset: Animations/" + animationFolder+"/"+aName + " could not be found.");
} else {
var aClip = mdl.animation.clip;
charAnimation.AddClip(aClip, aName);
Debug.Log(charAnimation[aName].name + " loaded from resource file " + animationFolder + "/" + aName + ". Length check: " + charAnimation[aName].length);
}

corona sdk iphone 4s 5.1.1 no sound

I don't have sound in apps on iphone 4s 5.1.1
tested my app + 2 (unmodified)examples from sample code
even when i send notifications - i get vibration (if with sound) - without sound i don't get vibration but in both cases sound does not play. not it notification not in app
Help!
I tried using ggmusic and ggsound libs by Glitched Games. Both of witch implement the new audio api.
here is some code so i meet the QUALITY STANDARTS
local supportedAudio = {
["Simulator"] = { extensions = { ".aac", ".aif", ".caf", ".wav", ".mp3", ".ogg" } },
["IOS"] = { extensions = { ".aac", ".aif", ".caf", ".wav", ".mp3" } },
["Android"] = { extensions = { ".wav", ".mp3", ".ogg" } },
}
Ok guyz, the thing is - you should check that switch on the right side that turns off sounds. Your media playback will play via loudspeker, but sounds dont. Turn sounds on and it fixes it.
Lame apple user I am.
Cheers!