Xamarin code works fine on Android but not on iOS - android

Both iOS and Android are using the same Xamarin code. Works fine on Android but not on iOS.
List<string> la_liste_de_liens contains URLs to podcasts such as www.something.com/podcast1.mp3, www.something.com/podcast2.mp3 and www.something.com/podcast3.mp3.
When I click the first item (item 0 from list) it plays well.
When I click the second item (item 1 from list) it would not play at all.
var les_liens = new List<string>();
string[] num1 = ((IEnumerable)some_podcast).Cast<object>()
.Select(x => x.ToString())
.ToArray();
var le_programme = Preferences.Get("prog", "default_value");
Le_prog.Text = le_programme;
Titre_episode.Text = num1[0];
List<string> la_liste_de_liens = Preferences.Get("haha",
"default_value1").Split(',').ToList();
var le_rang = Preferences.Get("rank", "default_value");
var url = la_liste_de_liens[int.Parse(le_rang)].ToString();
Console.Out.WriteLine(la_liste_de_liens);
Preferences.Set("le_url", url);
List<string> la_liste_de_durees = Preferences.Get("durdur",
"default_value2").Split(',').ToList();
var la_longueur = la_liste_de_durees[int.Parse(le_rang)].ToString();
Preferences.Set("longueur", la_longueur);
pause.ImageSource = "bouton_pause_bleu";
//low.ImageSource = "bouton_low_bleu";
//high.ImageSource = "bouton_high_bleu";
}
private void play_pod(object sender, System.EventArgs e)
{
//CrossMediaManager.Current.Volume.CurrentVolume = 30;
pause.ImageSource = "bouton_pause_bleu";
play.ImageSource = "bouton_play_vert";
stop.ImageSource = "bouton_stop_bleu";
//low.ImageSource = "bouton_low_bleu";
//high.ImageSource = "bouton_high_bleu";
var le_link = Preferences.Get("le_url", "default_value");
CrossMediaManager.Current.Play(le_link);
var le_temps = Preferences.Get("longueur", "default_value");
}
I could not figure out why. Could anyone provide some insight on this?

Related

transforming sourcecode for a designer widget into an android widget

I've seen this Widget and wonder if it's possible to use the sourcecode to make one for android. Any ideas are suggestions are appreciated.
This is just the jss part since I always have to upload a code
console.clear()
class PlayerWidget {
constructor(player, tracks) {
// State
this.current = 0
this.next = 0
this.currentImage = 0
this.tracks = tracks
this.player = player
this.isPaused = false
this.interval = null
// DOM
this.progressBar = this.player.querySelector('.c-player__ui__seek__seeker div')
this.progress = this.player.querySelector('.c-player__ui__seek__seeker')
this.playBtn = this.player.querySelector('.c-player__ui__play')
this.pauseBtn = this.player.querySelector('.c-player__ui__pause')
this.pauseSvgs = this.pauseBtn.querySelectorAll('svg')
this.prevBtn = this.player.querySelector('.c-player__ui__prev')
this.nextBtn = this.player.querySelector('.c-player__ui__next')
this.dots = this.player.querySelectorAll('.c-player__ui__dots__dot')
this.bindEvents()
}
bindEvents() {
this.nextBtn.addEventListener('click', e => this.nextTrack(e))```

Web Audio Api biquadFilter in Android needs extra configuration?

Here says the Web audio API works in Chrome for Android, and here I have tested CM Browser, Chrome and CyanogenMod default Android 5.1.1 browsers, and all pass the tests (specially the biquadNode one).
But When I open this codepen with an eq (biquadNode), I can hear the music but not the eq working.
Does biquadNode works in android? any special implementation is needed?
*Code pen required to post
var context = new AudioContext();
var mediaElement = document.getElementById('player');
var sourceNode = context.createMediaElementSource(mediaElement);
// EQ Properties
//
var gainDb = -40.0;
var bandSplit = [360,3600];
var hBand = context.createBiquadFilter();
hBand.type = "lowshelf";
hBand.frequency.value = bandSplit[0];
hBand.gain.value = gainDb;
var hInvert = context.createGain();
hInvert.gain.value = -1.0;
var mBand = context.createGain();
var lBand = context.createBiquadFilter();
lBand.type = "highshelf";
lBand.frequency.value = bandSplit[1];
lBand.gain.value = gainDb;
var lInvert = context.createGain();
lInvert.gain.value = -1.0;
sourceNode.connect(lBand);
sourceNode.connect(mBand);
sourceNode.connect(hBand);
hBand.connect(hInvert);
lBand.connect(lInvert);
hInvert.connect(mBand);
lInvert.connect(mBand);
var lGain = context.createGain();
var mGain = context.createGain();
var hGain = context.createGain();
lBand.connect(lGain);
mBand.connect(mGain);
hBand.connect(hGain);
var sum = context.createGain();
lGain.connect(sum);
mGain.connect(sum);
hGain.connect(sum);
sum.connect(context.destination);
// Input
//
function changeGain(string,type)
{
var value = parseFloat(string) / 100.0;
switch(type)
{
case 'lowGain': lGain.gain.value = value; break;
case 'midGain': mGain.gain.value = value; break;
case 'highGain': hGain.gain.value = value; break;
}
}
createMediaElementSource in Chrome on Android doesn't work in general. But if you have a recent build of Chrome (49 and later?), you can go to chrome://flags and enable the unified media pipeline option. That will make createMediaElementSource work like on desktop.

Get data from a website in android

I developed an app in Windows phone 8/8.1, now I am trying to develop for android users. I am getting data from a website and displaying in my app. the website needs login userid,password. I successfully implemented it in C#. but I am unable to do it in java. can some guide me.
My code in C# :
HttpClientHandler handler = new HttpClientHandler();
HttpClient client = new HttpClient(handler, false);
handler.AllowAutoRedirect = true;
handler.PreAuthenticate = true;
Uri vceURI = new Uri("http://xxxx/default.aspx");
var html = await client.GetStringAsync(siteURI);
var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
var viewstateNode = doc.GetElementbyId("__VIEWSTATE");
var eventvalidationNode = doc.GetElementbyId("__EVENTVALIDATION");
var viewstate = viewstateNode.GetAttributeValue("value", "");
var eventvalidation = eventvalidationNode.GetAttributeValue("value", "");
var formContent1 = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("__VIEWSTATE", viewstate),
new KeyValuePair<string, string>("__EVENTVALIDATION", eventvalidation),
new KeyValuePair<string,string>("txtLoginID",_username),
new KeyValuePair<string,string>("txtPWD",_pswd),
new KeyValuePair<string,string>("btnLogin","Go%21")
});
var outputDoc = await client.PostAsync("http://xxx/default.aspx", formContent1);
html = await outputDoc.Content.ReadAsStringAsync();
doc.LoadHtml(html);
// parsing(doc);
var studentInfoNode = doc.GetElementbyId("divStudInfo");
var _studentinfonode1 = studentInfoNode.ChildNodes;
var studentInfo = studentInfoNode.ChildNodes[0].ChildNodes;
the above studentInfo object contain required data
I tried using HttpClient + HttpPost but I am ending up in null exception :(
If some ever worked on similar application can you please help me.
Thanks

Record Sound in Android using ActionScript 3

i build a application that record sound in Desktop using ActionScript 3 , now i convert the application to Andriod Application but there is a problem that SampleDataEvent.SAMPLE_DATA event doesn't receive any data to record
Here is the code :
private var _microphone:Microphone;
private var _buffer:ByteArray = new ByteArray();
private var _difference:uint;
public function record():void
{
if ( _microphone == null )
_microphone = Microphone.getMicrophone();
_difference = getTimer();
_microphone.setSilenceLevel(_silenceLevel, _timeOut);
_microphone.gain = _gain;
_microphone.rate = _rate;
_buffer.length = 0;
_microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, onSampleData);
_microphone.addEventListener(StatusEvent.STATUS, onStatus);
}
private function onSampleData(event:SampleDataEvent):void
{
_recordingEvent.time = getTimer() - _difference;
dispatchEvent( _recordingEvent );
var buteData:Number;
while(event.data.bytesAvailable > 0)
{
buteData = event.data.readFloat();
_buffer.writeFloat(buteData);
soundBytes.writeFloat( buteData);
}
}
anyone can help here
Thanx
I think, maybe you don't check out about AIR for Android settings. If you not checked in the RECORD_AUDIO. you should check it.
refer a below image.

Loading External Picture in air for android

I need load images from a folder in application directory created in sd Card of mobile android
This is working in PC, but not in mobile version
Some solution ?
var imagesFin:File = File.applicationStorageDirectory.resolvePath("appImages/");
var files:Array = imagesFin.getDirectoryListing();
for (var i:uint = 0; i < files.length; i++){
var picLoader = new Loader();
picLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadPicture);
picLoader.load(new URLRequest(files[i].nativePath));
}
function loadPicture(event:Event):void {
var imgAtual = event.target.content;
ContainerImagesList.addChild(imgAtual);
}
This work for me:
var bytes:ByteArray = new ByteArray();
var myFileStream:FileStream = new FileStream();
var myFile:File = File.documentsDirectory.resolvePath(YOUR_PATH);
myFileStream.addEventListener(Event.COMPLETE, fileCompleteHandler)
myFileStream.openAsync(myFile, FileMode.READ);
function fileCompleteHandler(event:Event):void
{
myFileStream.readBytes(bytes);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
loader.loadBytes(bytes);
function imageLoaded(e:Event):void
{
addChild(Bitmap(loader.content));
myFileStream.removeEventListener(Event.COMPLETE, fileCompleteHandler);
myFileStream.close();
}
}
Cheers!
In iOS I never use resolvePath. I just use a relative url like "images/photo.jpg" and it works perfectly on any iOS device.
Instead of resolvePath you could also use URL schemes. It's a lot simpler "app:/images/photo.jpg" or "app-storage:/settings/prefs.xml".
http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118666ade46-7fe4.html
This is what I do to get all images in my image file cache
var imageFolder:File = new File("app:/img");
var getfiles:Array = imageFolder.getDirectoryListing();

Categories

Resources