Giter Site home page Giter Site logo

arielfaur / ionic-audio Goto Github PK

View Code? Open in Web Editor NEW
322.0 34.0 165.0 23.88 MB

An audio player for Ionic 3 and Angular 4. Works with HTML 5 audio or native audio using Cordova Media plugin.

Home Page: http://arielfaur.github.io/ionic-audio/2.0/index.html

License: MIT License

JavaScript 14.81% CSS 83.58% HTML 1.61%
angular2 ionic2 audio ionic3 ionic-framework angular5 angular4 typescript

ionic-audio's Introduction

ionic-audio's People

Contributors

arielfaur avatar danharper avatar matheusrocha89 avatar zbarbuto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ionic-audio's Issues

Play Audio in background

Hey,
I was wondering if there is a way to have the audio play when the app is minimized or the screen is locked.

I found for the cordova media plugin you can pass a parameter to the play function like below:
var iOSPlayOptions = {
numberOfLoops: 1,
playAudioWhenScreenIsLocked: true
}
currentMedia.play(iOSPlayOptions);

But this doesn't seem to be working with this plugin. Any thoughts?

Thanks, this plugin is awesome!

'onSeek' method ?

Is it possible to add callback when the user slide the seekbar (e.g onSeekStart, onSeekChange, onSeekEnd,...). I want to retrieve the current track's position. Thks !

Parse error when building

After modifying the gulp file with:

`gulp.task('watch', ['clean'], function(done){
runSequence(
['sass', 'html', 'fonts', 'scripts'],
function(){
gulpWatch('app//*.scss', function(){ gulp.start('sass'); });
gulpWatch('app/
/*.html', function(){ gulp.start('html'); });
buildBrowserify({
watch: true,
src: ['./app/app.js', './node_modules/ionic-audio/dist/ionic-audio.ts', './node_modules/ionic-audio/typings/main.d.ts']
}).on('end', done);
}
);
});

gulp.task('build', ['clean'], function(done){
runSequence(
['sass', 'html', 'fonts', 'scripts'],
function(){
buildBrowserify({
minify: isRelease,
browserifyOptions: {
debug: !isRelease
},
uglifyOptions: {
mangle: false
},
src: ['./app/app.js', './node_modules/ionic-audio/dist/ionic-audio.ts', './node_modules/ionic-audio/typings/main.d.ts']
}).on('end', done);
}
);
});
`

I'm getting this parse error:

...node_modules/ionic-audio/dist/ionic-audio.ts:8 export * from './ionic-audio-interfaces'; ^ ParseError: 'import' and 'export' may appear only with 'sourceType: module'

Its not working in Android

I can't Skip a song using the slide, nor the loading symbol disappears... And after the song is played it won't stop anymore. Any solutions?

Uncaught TypeError: Object #<Object> has no method 'play' on Android

I had the plugin working previously with an older version of cordova but since updating to the latest, I get this error while running on an Android device:

Uncaught TypeError: Object #<Object> has no method 'play' 

My usage case follows the same as the example on the ionic audio website. When I tap the play button I see the loading spinner but get the above error in console.

The media plugin is installed and the code has not changed since I had it working. The only thing I changed was I updated cordova which meant I had to create a new project but I copied everything from the www folder and readded the plugins.

I had a nightmare getting videos to play on Android in the same App so I had to use the file and file-transfer plugins to access the video files. Could this be a similar problem?

Bower main property

Hi,

Can you please add "main" : "dist/ion-audio.js" in bower.json ?

It would enable wiredep to automatically add ionic-audio dependencies to the index.html.

Thanks

Error in Success callbackId facing issue ios

Hi I am facing this error,
in my project in one page I am getting all audio list dynamically and next page with controller
calling the audio like this
$scope.track = $rootScope.songsObject[$stateParams.id];
and the audio is playing well no issue I am going back again getting the list of audio's and again selected another one its working but same after 3 to 4 audio's just the spinner is rotating no errors in Xcode also and nothing is working I have youtube videos also they are also not working at that time I think in background some thing is happening and some times i am getting this error in Xcode
Error in Success callbackId: Media1035323214 : TypeError: 'undefined' is not an object (evaluating 'currentTrack.progress = position')
please help me

ReferenceError: Can't find variable: nan

I am trying to test the example app but I am getting the following error:

exeption nativeEvalAndFetch : ReferenceError: Can't find variable: nan

and the music is not playing.

H

Dynamic track loading?

Hello, first of all, a huge thanks for this awesome project.

I currently have an ionic-audio code block embedded in my footer like so.

<ion-audio-track track="myTrack">
  <ion-audio-controls>
    <a class="button button-icon icon" ion-audio-play></a>
    <ion-spinner icon="ios"></ion-spinner>
  </ion-audio-controls>
</ion-audio-track>

In my controller, $scope.myTrack is dynamically loaded. Whenever an event fires (ionic slide changed), it triggers the following function:

$scope.slideChanged = function(index) {
  $scope.slideIndex = index;
  var newAudio = $scope.data[index]

  $scope.myTrack = {
    url: newAudio.path,
    artist: newAudio.artist,
    title: newAudio.title
  };
};

Upon update of the scope variable, when I click the "play" ion-audio-controls button, ionic-audio fails with the following console message:

Error: undefined is not an object (evaluating 'currentTrack.title')
play@http://IP:8100/lib/ionic-audio/dist/ion-audio.js:140:69
http://IP:8100/lib/ionic-audio/dist/ion-audio.js:200:25
http://IP:8100/lib/ionic/js/ionic.bundle.js:24922:30
completeOutstandingRequest@http://IP:8100/lib/ionic/js/ionic.bundle.js:13604:15
http://IP:8100/lib/ionic/js/ionic.bundle.js:13984:33

Is this functionality not available currently? If not, do you have plans to add such feature? Or can I please get a pointer as to what I should do to implement it?

Thank you so much.

cordova media freezes ui

One issue I ran into with doing a similar module was that when I loaded a network audio file, the entire UI freezes until it's ready to play. I tried to figure out a way to display an $ionicLoading indicator, but because the entire UI freezes before the indicator appears nothing gets displayed. Anyway, I was just wondering if this has a solution for that use case?

AAC stream support

Hello,
I'm trying to stream an icecast server for a webradio (AAC ext).
In the emulator, it tooks approx 10sec to play sound and in my real device loading never ends.

Do you have any ideas why this thing is occurring ? Does this module is supposed to support live streams ?

Thanks for this great module !

Missing Cordova Media plugin (Ionic v1.7.14)

Hello, I've done all your installation steps and also succesfully installed Cordova Media plugin, I can see it in package.json file and I also get cordova-plugin-media 2.1.0 "Media" by running command ionic plugin list so I suppose I have this plugin installed.
But no audio player shows on my page and I am getting this error in the console:

ionic-audio: missing Cordova Media plugin. Have you installed the plugin? 
Run 'ionic plugin add cordova-plugin-media'

ionic.bundle.js:21162 TypeError: Cannot read property 'stop' of null
    at Object.fn (ion-audio.js:320)
    at Scope.$digest (ionic.bundle.js:24515)
    at Scope.$apply (ionic.bundle.js:24783)
    at done (ionic.bundle.js:19196)
    at completeRequest (ionic.bundle.js:19368)
    at XMLHttpRequest.requestLoaded (ionic.bundle.js:19309)

Do you have any idea why is that so? Have I installed wrong version of Cordova Media plugin or is there something that I forgot to install?

iOS spinner stops while file downloads

Appears the spinner stops while the file is downloading on iOS before playing, giving the impression of a freeze or a crash...

I'm using the feature-track-observable branch as I'm using signed URL's and setting the track URL dynamically.

Any ideas why the spinner does that?

How to make it work with ng-repeat based on JSON feed

Hi,

I cannot make it work with the below code :

Controller (gets the JSON feed from my URL as an Array and put it in rootScope.musiques) :

  $http.get('myURL').then(function (resp) {
           $rootScope.musiques = resp.data.posts;
  }

In HTML :
Using ng-repeat to get the track info one by one from the array.
The thumbnail & title is showing correctly, but when clicking on the play button, it doesn't happen anything. I already tried your other branch "observable", but with no luck.

Any idea ?

          <div class="list list-inset" ng-repeat= "track in musiques"  on-refresh="doRefreshMusique()">   

            <ion-audio-track track="track">

              <div class="item item-thumbnail-left">

                <img ng-src="{{track.thumbnail_images.full.url}}" class="feed-image">

                <p>{{track.title}}</p>
                <ion-audio-controls>
                  <a class="button button-icon icon" ion-audio-play></a>
                  <ion-spinner icon="ios"></ion-spinner>
                </ion-audio-controls>
              </div>
              <div class="item">
                <ion-audio-progress-bar track="track" display-time></ion-audio-progress-bar>
              </div>
              </ion-audio-track>
            </div>

Thank you for your help.

Weird file issue

Hi,
I got an .mp3 file that I am trying to play in an ionic app. I've tried your very nice plugin with several other files. Everything seemed to work - but not with the file I got. Here's what I've done so far:

  • try online/offline
  • validate the mp3 file
  • converted the .mp3 to .wav and .aiff
  • used different settings on .mp3 conversion
  • change sample rate
  • check file permissions
  • check my code, but since your test audio is working I'm not too worried about this

Do you have any hint for me on what else could cause it not playing. In Xcode as I test the app it would say "now playing ..." but no sound whatsoever. In android there still seems to be another issue since the loading indicator just runs wild with nothing happening. (but I am not the one testing the android app, so I cannot give more info on that atm)

Request:

Would it be possible to broadcast events when the player status changes, for example to enable other elements to update to indicate a track is playing, or for analytics code?

Audio not play until file downloaded to device, screen no response during download

Thanks for the amazing plugin, I have a problem with it however. I have lots of audio files in the server which is pretty large, say from 10MB to 120MB, when testing the player in simulator I found that it seems the player will only play the audio until the whole audio file has been downloaded to the device, while during downloading process the device is frozen in the screen and cannot do anything, no percentage indicator or progress bar can be seen.

May i know if this is the true? i.e. player need to download the whole file before playing. If true, any way to stream the audio when downloading and showing the download percentage?

iOS 9.1 iPhone6

iOS Support

Hi!

I was wondering if this plugin has been tested on iOS yet?

How debug if is working?

So, i tried to use your module, but aperently dont work, i used your example but i could not make it work.

'ion-audio.min.js' is not same as ion-audio.js

Hello.
First of all, thank you for nice plugin for audio player. It is so useful for my project.

I found out an error when I use ion-audio.min.js instead of using ion-audio.js

However, if I run npm install and gulp build, it re-generates ion-audio.min.js then ion-audio.min.js is working properly.

I found out the difference between original ion-audio.min.js and my own re-generated ion-audio.min.js.
I attach the screenshots (The left is re-generated by gulp build, and the right is original ion-audio.min.js)

screen shot 2016-05-23 at 11 28 11
screen shot 2016-05-23 at 11 28 29

Can anyone fix ion-audio.min.js on github?
By doing so I don't have to run npm install and gulp build in ionic-audio directory whenever I checkout my project.

Thank you.

MediaManager not defined

when load page has media files show this error :

Error: null is not an object (evaluating 'MediaManager.stop')

when click play shows this error :

TypeError: null is not an object (evaluating 'MediaManager.play')

Debug ..

screen shot 2016-05-20 at 17 12 59

Playlist support

This is a great module!

Any plans for playlist support? Being able to move forward and back through a playlist while stopping, and possibly releasing audio resources would be very helpful.

demo

Guessing you're aware that the demos don't play?

background playback

Hello,

This plugin is working great for me. The only missing feature is audio playback when the app is in the background--Is this feature on the development roadmap? Thanks.

Issues with multiple tracks

Great to see this module evolving.
I took an other test run today, and found some issues.
The issues are with multiple tracks. When one track is playing, trying to play an other track doesn't change the first tracks button back to "play icon". Am I missing something?

.controller('ExercisesCtrl', function($scope, $ionicPlatform) {

  var urlprefix;
  if ($ionicPlatform.is('android')) { urlprefix = '/android_asset/www/' }

  $scope.exercises = [
    { 
      id: 1,
      title: 'Title 1', 
      description: '',
      descriptionlong: '',
      url: urlprefix + 'audio/1.mp3'
    },
    { 
      id: 2,
      title: 'Title 2', 
      description: '',
      descriptionlong: '',
      url: urlprefix + 'audio/2.mp3'
    }
  ];

})
<div class="list card exercise" ng-repeat="exercise in exercises" toggle-class="active">
  <ion-audio-track track="exercise">
    <div class="item">
        <ion-audio-controls>
          <a class="button button-icon button-stable icon ion-play" ion-audio-play></a>
        </ion-audio-controls>
        <h2>{{exercise.title}}</h2>
        <p>{{exercise.description}}</p>
        <div class="desc-long">
          <p>{{exercise.descriptionlong}}</p>
        </div>
    </div>
  </ion-audio-track>
</div>

Play/pause icon delay

There is a little delay when you press the play button until it switches over to pause, and thereby gives the user any UI feedback. I understand it does this because it first checks the Media, and loads it, and so on, and when the status is right, and it starts playing, it switches to "pause".

This makes it feel slow and unresponsive. It would be better to just switch it to "pause" as soon as it's pressed, and if an error occurs switch it back to "play" (or even some other "error" icon).

Force play

Hello,
How can I force the change of the currently played track?

Here is my view :

<ion-audio-track ng-repeat="track in roomCtrl.tracks" track="track">
      <div class="item item-icon-left">
        <ion-audio-controls>
          <a class="button button-icon icon" ion-audio-play></a>
        </ion-audio-controls>
        <h2>{{track.title}}</h2>
      </div>
    </ion-audio-track>

And in the controler I want to do something like this :

// Reassign directly
$scope.track = tracks[position++];

Do I need to force something?

ionic-audio: missing Cordova Media plugin.

Hey Arielfur,
Really trying to do things right. Getting the ionic-audio: missing Cordova Media plugin. I've run the ionic plugin add cordova-plugin-media and I see cordova-plugin-media right there in my plugins folder. Any idea why I'm getting that error?

I ran ionic plugin rm cordova-plugin-media and ionic plugin add cordova-plugin-media.

Safari shows blank page

Safari shows a blank page when providers are specified as below. The <ion-app></ion-app> is empty. If no providers are set providers: [] then Safari shows the app correctly. (<ion-app>...</ion-app> has content) Emulation in iOS has the same issue.
In either case Safari reports the error ReferenceError: Can't find variable: AudioContext at ionic-web-track.ts:25:91.
In Chrome all above works fine.

import {App, Platform} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {TabsPage} from './pages/tabs/tabs';
import {AudioProvider, WebAudioProvider} from 'ionic-audio/dist/ionic-audio';

// https://angular.io/docs/ts/latest/api/core/Type-interface.html
import {Type, provide} from 'angular2/core';

@app({
template: '<ion-nav [root]="rootPage">',
config: {}, // http://ionicframework.com/docs/v2/api/config/Config/
providers: [provide(AudioProvider, { useFactory: AudioProvider.factory })] // or use [WebAudioProvider] to force HTML5 Audio
})
export class MyApp {
rootPage: any = TabsPage;

constructor(platform: Platform) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
});
}
}

It maybe due to this typescript error when building:
TypeScript error: /Users/Eugene/Code/mindfood/node_modules/ionic-audio/dist/ionic-audio-providers.ts(30,19): Error TS2339: Property 'cordova' does not exist on type 'Window'.

Download locally?

Is it possible to give the user the option to download the audios locally in order to play them when offline?

how to add two ion-audio-track with sync?

hi ..
I want to add tow ion-audio-track one in the page contetnt and the other in top controller
this mean parent audio controll for manage inside other pages
I tried to add ion-audio-track in tow place and make track in rootScope for sharing the same data
but the problem is progress bar not working in two place
there are other options for doing it like this?

Loading Spinner iOS

Hi, this project is just what I'm looking for so thanks!

On iOS (iPhone 6) the loading spinner appears to freeze. I'm using it to stream mp3's from the web. The spinner spins once or twice and then stops until the audio begins to play about 30 seconds later. On my android test device (galaxy S3) the spinner spins and audio begins to play after about 1 or 2 seconds.

stop audio when use ion-infinite-scroll

I using ion-infinite-scroll just I push item in the-the base Audio array but when to load more Item the audio stops and reset to zero.

any solution for this case?

current time in progress bar start in "-1" not "0"

I have an audio file but there is a decrease in the current time in the progress bar, I print it what the values in track object I see duration: -1 , status : 0 , progress : 0 , URL : "cdvfile://..."

Changing the track URL

Hi @arielfaur

Thanks for your efforts in creating this nice module, i was working on it and i had a requirement to change the track url based on some conditions then play sound from the new URL, i was building this with cordova so i am using the cdvfile://localhost/ file system

I was able to achieve this by adding a new listener to track url as below in ionAudioTrackCtrl

let me if this sound correct and can be a nice enhancement for this module

   $scope.$watch('track.url', function () {
        if (!MediaManager) return;

        // Stop playing the current track
        MediaManager.stop();

        // Update elements & add as new track 
        init();

        // attach play funtion
        $scope.track.play = function () {

            MediaManager.play($scope.track.id);

            // notify global progress bar if detached from track
            if (!controller.hasOwnProgressBar) notifyProgressBar();

            return $scope.track.id;
        };
    });

Livestream

Maybe I missed something, as I'm currently not able to play a radio stream.
Is planned to support this kind of audio-files?

Seek to functionality?

This module is awesome. Exactly what i was looking for. Thank you.
I see that you have the "seek to via slider" functionality on your todo list. Do you have any code for this already, or maybe an alpha version, or an ETA? :)

not working

hello
sorry not sure what happened to my topic here
but I can't get it to work
I am using ionic view to test it on my iphone but it does not play anything and the app crashes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.