ionic 2 - play mp3 file - android

I use https://ionicframework.com/docs/native/media/ plugin for play mp3 file in
ionic 2 project like this code :
(put animal audio file in src/assets/audio/animal.mp3)
play(){
const file: MediaObject = this.media.create('../assets/audio/animal.mp3');
file.play();
}
in html
<button (click) = "play()" >Paly</button>
but in android device and when click on play button , I cannot hear any sounds

Try to use NativeAudio plugin (https://ionicframework.com/docs/native/native-audio/). It works really nice for me. Some example:
if (this.platform.is('cordova')) {
this.nativeAudio.preloadSimple('chamada', 'assets/sounds/Umbriel.mp3');
this.nativeAudio.loop('chamada');
}
In this case, nativeAudio is injected NativeAudio module. To stop it, I do:
if (this.platform.is('cordova')) {
this.nativeAudio.stop('chamada');
this.nativeAudio.unload('chamada');
}
You can check more options on documentation. Give it a try... good luck!

Related

How to add Sound Effects with Kotlin in Android

How do you program sound effects in kotlin android Looked all over Yt and there all in Java
Add/Import your sound effect file to your project and use MediaPlayer like this one
private var BgMusic:MediaPlayer? = null
fun playBgMusic(){
BgMusic = MediaPlayer.create(this, R.raw.gamebgmusic)
BgMusic?.setOnPreparedListener{
BgMusic?.start()
musicPlaying = true
}
BgMusic?.setOnCompletionListener {
BgMusic?.start()
}
}
fun pauseBgMusic(){
BgMusic!!.pause()
}
fun resumeBgMusic(){
BgMusic!!.start()
}
Add your sound effect file into your 'resources' folder in your app project, then call it from whichever activity or fragment you would like to execute it in with SoundPool, a public class that enables you to load the audio resource into memory and play it!
I link you here the SoundPool documentation as well as a blogpost that shows it in action.
Here's also a Kotlin tutorialspoint article.

Cordova - how to play mp4 video in fullscreen and in loop?

I would like to play given mp4 video file in the fullscreen and in the loop.
Is existing some plugin for this?
I found the videogular library for Angular based apps.
http://www.videogular.com/docs/#/api/com.2fdevs.videogular.directive:vgLoop
But i don't know it is the right choice for what i need.
I can be something lightweight. I need only play in fullscreen and in the loop wit possibility to close the video (no sound, seeking in video, timeline, etc..).
Many Thanks for any advice.
With Videogular you have all those requirements covered. Probably you need something pretty basic like this:
http://www.videogular.com/examples/simplest-videogular-player/
You can fork the codepen and add the loop capability. To do the fullscreen on play you can add an ng-click to the vg-overlay-play plugin with an API.toggleFullScreen() for example.
HTML
<div ng-controller="myController as ctrl">
<videogular vg-player-ready="onPlayerReady($API)" vg-loop="ctrl.config.loop">
<vg-media vg-src="ctrl.config.sources"></vg-media>
<vg-overlay-play ng-click="API.toggleFullScreen()"><vg-overlay-play>
</videogular>
</div>
JS
angular.module("myApp").controller("myController",
function myController($sce) {
this.API = null;
this.config = {
loop: true,
sources: [
{src: $sce.trustAsResourceUrl("http://static.videogular.com/assets/videos/videogular.mp4"), type: "video/mp4"},
{src: $sce.trustAsResourceUrl("http://static.videogular.com/assets/videos/videogular.webm"), type: "video/webm"},
{src: $sce.trustAsResourceUrl("http://static.videogular.com/assets/videos/videogular.ogg"), type: "video/ogg"}
]
};
this.onPlayerReady = function onPlayerReady(API) {
this.API = API;
};
}
);
I've not tested this, but it should work or close to.

FLEX Android: Do I need to copy .db and .xml to ApplicationStorage manually?

On flex app for Android first start (or after deleting app data), does Flex handle copying assets files from assets/ folder to File.applicationStorageDirectory, or is developer responsible for checking whether file exists there, and if not, copying ones from assets/ to File.applicationStorageDirectory?
If this goes by unanswered, I don't mind investigating it further and answering it myself, I was just wondering if someone knows this by heart.
Thanks!
Do you use Flash Builder?
In its menu there is Project -> Export Release Build... -> Next -> Package Contents and you can add your assets by toggling checkboxes.
Ok, here goes:
Flex does not take care of that - we have to do it manually.
I will use the following code to make sure my file exists in ApplicationStorageDirectory:
import flash.filesystem.File;
public const FNAME:String = "myDBFileName.db";
private var dbFile:File = File.applicationStorageDirectory.resolvePath(FNAME);
// 'original', initial file
private var originalDB:File =File.applicationDirectory.resolvePath(FNAME);
public function MyOpenFile(){
if (!dbFile.exists){
// It does not exist in AppStorageDirectory, so copy it from app instalation directory
originalDB.copyTo(dbFile);
}
// from here on, we can safely use dbFile.
}
So on 1st launch (and after 'delete app data'), app will copy original file to ApplicationStorageDirectory, and continue using it from there.

Angular Js and Trigger.io - Can't follow a link on Android that works on iOS

I am using AngularJS with Trigger.io to develop a mobile application for both iOS and Android.
When I try to open a link that looks like this:
<a ng-href="#/offers/{{featured_offer.Id}}"></a>
It works perfectly fine on iOS, but on Android I get this message in the trigger console, and the link is not navigated to:
[WARNING] Attempted to open a URL which could not be handled: unsafe:content://io.trigger.forge722b6464a0e211e2ba9d12313d00dc45/src/index.html#/offers/8
How can I get this to work in Android the same as it works in iOS?
Looks like Angular adds unsafe: to url schemes it doesn't recognise, I think you want to include something like:
app.config(function($compileProvider){
$compileProvider.urlSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel|content):/);
});
Which adds content: to the accepted url schemes.
I had this same problem, specifically with trying to display an img with a src of a file returned by forge.file.getImage. Angular adds unsafe: to the content: prefix of the local img URL, and as connorhd said, you need to add content: to the url whitelist.
Note that compileProvider's API has changed with recent versions of Angular, so I'm commenting here in case anyone else finds an updated version of this workaround useful.
app.config(['$compileProvider',
function($compileProvider) {
$compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel|content|blob):|data:image|/);
// note: you'll also have to do imgSrcSanitizationWhitelist if you want to use general links as well as ng-src on images.
}]);
I too had this problem just add sanitizer in you config.xml
var app = angular.module( 'myApp', [] )
.config( [
'$compileProvider',
function( $compileProvider )
{
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|chrome-extension):/);
// Angular before v1.2 uses $compileProvider.urlSanitizationWhitelist(...)
}
]);

Displaying leadbolt ads on a phonegap android app

I’ve been trying without success to get leadbolt ads to show up on an android app I created using phonegap. This is what I’ve done so far:
I have created a notification ad on leadbolt.com, added references to LeadboltController.jar and LeadboltPhonegapPlugin.jar files contained in my projects libs folder.
Added the code below to my javascript file
var Leadbolt = function() { }
Leadbolt.prototype.load = function(data, successCallback, failureCallback) {
return PhoneGap.exec(successCallback, failureCallback, 'LeadboltPlugin', data[0], data);
};
PhoneGap.addConstructor(function() {
PhoneGap.addPlugin('leadbolt', new Leadbolt());
PluginManager.addService("LeadboltPlugin", "com.LeadboltPlugin.LeadboltPlugin");
});
Sometimes I insert the code below in my javascript file or index.html, either way I see no ads.
window.plugins.leadbolt.load(["*********"], null, null);
Am sure people must have gotten this to work on their apps. I would really appreciate any assistance offered.
Thanks alot.
Have you done this:
Open /res/xml/plugins.xml, add following lines:
<plugin name="LeadboltPlugin" value="com.LeadboltPlugin.LeadboltPlugin" />
<plugin name="LeadboltNotificationPlugin" value="com.LeadboltPlugin.LeadboltNotificationPlugin" />
Hey not sure if this helps, but I know Leadbolt released an update to their phonegap plugin and its available in the portal. They put all ads types in one plugin which is much more convenient to use. Have you tried that?
If still not working, you should write to their support with details and they will get an answer for you. I’ve done that and its been very helpful.

Categories

Resources