18712

Audio player for Ionic

Question:

I am learning Ionic and want to embed an audio player. I have found this Plnkr example of <a href="http://plnkr.co/edit/C9vWoszT3FmfcATmZZ81?p=preview" rel="nofollow">Video Player</a>:

angular.module('app',[]) .directive('youtubeIframe', ['$timeout', function ($timeout, $sce ) { return { restrict: 'A', link: function (scope, element, attrs) { $timeout( function () { var temp1 = '<iframe width="400px" height="200px" src="http://www.youtube.com/embed/'; var temp2 = '?&autoplay=0&autohide=1&fs=1&cc_load_policy=1&loop=0&rel=0&modestbranding=1&&hd=1&playsinline=0&showinfo=0&theme=light" frameborder="1" allowfullscreen></iframe>'; var finalvar = temp1 + attrs.youtubeIframe + temp2 ; console.log('Finalvar is: ' + finalvar); //just to check if url is ok element.prepend( finalvar ); }, 150); // The timeout is to give enough time for the Dom to be built and checked for its structure, so that we can manipulate it. } }; }]) .controller('VideoCtrl', function($scope) { $scope.angularvideos = [ { name: 'Angular on the go: Using Angular to power Mobile Apps', youtubeId: 'xOAG7Ab_Oz0', publishdate: 'Dec 2013' }, { name: 'Crafting the Perfect AngularJS Model and Making it Real Time', youtubeId: 'lHbWRFpbma4', publishdate: 'April 2014' }, { name: 'AngularJS & D3: Directives for Visualizations', youtubeId: 'aqHBLS_6gF8', publishdate: 'Jan 2014' }, { name: 'The Thick Front End', youtubeId: 'hv2NEW0uC1o', publishdate: 'Nov 2013' } ]; })

Is there a similar example for an audio player within iframe for a mobile App (Android for the time being, but later on iOS as well)?

Answer1:

I released a Ionic module that plays audio natively (tested it on Android so far) using the Cordova Media plugin.

You define a Ionic view:

<ion-view view-title="Music"> <ion-content> <ion-audio-track track="myTrack"> <div class="list list-inset"> <div class="item item-thumbnail-left"> <img src="{{track.art}}"> <h2>{{track.title}}</h2>

{{track.artist}}

<ion-audio-play></ion-audio-play> </div> <div class="item"> <ion-audio-progress-bar display-time></ion-audio-progress-bar> </div> </div> </ion-audio-track> </ion-content> </ion-view>

And your scope:

$scope.myTrack = { url: 'https://www.example.com/my_song.mp3', artist: 'Somebody', title: 'Song name', art: 'img/album_art.jpg' }

Looks like this:

<img alt="Screenshot" class="b-lazy" data-src="https://i.stack.imgur.com/KdBlM.png" data-original="https://i.stack.imgur.com/KdBlM.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

You can find it here: <a href="https://github.com/arielfaur/ionic-audio" rel="nofollow">https://github.com/arielfaur/ionic-audio</a>

Answer2:

I think right thing is available there- links:

<a href="http://www.videogular.com/examples/" rel="nofollow">Dev-friendly and stable module for audio, html5-video, youtube(iframe) etc..</a>

Here is <a href="http://www.videogular.com/examples/creating-an-audio-player/" rel="nofollow">Example</a> creating Audio Player.

Here is <a href="http://codepen.io/2fdevs/pen/tguGx" rel="nofollow">codepen</a>

<videogular vg-theme="controller.config.theme.url" class="videogular-container audio"> <vg-media vg-src="controller.config.sources"></vg-media> <vg-controls> <vg-play-pause-button></vg-play-pause-button> <vg-time-display>{{ currentTime | date:'mm:ss' }}</vg-time-display> <vg-scrub-bar> <vg-scrub-bar-current-time></vg-scrub-bar-current-time> </vg-scrub-bar> <vg-time-display>{{ timeLeft | date:'mm:ss' }}</vg-time-display> <vg-volume> <vg-mute-button></vg-mute-button> </vg-volume> </vg-controls> </videogular>

Recommend

  • insert element in the dom using javascript or jquery
  • how can i reference $_SERVER['DOCUMENT_ROOT'] in a .htaccess file?
  • How can I specify an auto_prepend_file in my .htaccess file without hardcoding the absolute path?
  • Getting the width from an scaled image
  • How to add closing tag for canvas in three js rendered Canvas?
  • Get the pasted content on document on paste event
  • Spark (Scala) Writing (and reading) to local file system from driver
  • jquery validation - waiting for remote check to complete
  • Android cannot disable cut copy paste
  • Bootstrap (v3.3.4) glyphicons not displayed in IE when refresh page (F5)
  • How do I display a dialog that asks the user multi-choice questıon using tkInter?
  • where do I find the xml.dom python package for the python-2.6.0-8.9.28 and I have a suse/x86_64 vers
  • How to use carriage return with multiple line?
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • Recording logins for password protected directories
  • Linq Objects Group By & Sum
  • Splitting given String into two variables - php
  • Optimizing database types to compact database (SQLite)
  • Volley JsonObjectRequest send headers in GET Request
  • Is there a amazon webstore API for customers?
  • How to get a value (ex: baseURL) in every Karate feature?
  • Check if a string to interpolate provides expected placeholders
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Perl system calls when running as another user using sudo
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Upload files with Ajax and Jquery
  • How to pass list parameters for each object using Spring MVC?
  • Circular dependency while pushing http interceptor
  • Proper folder structure for lots of source files
  • Buffer size for converting unsigned long to string
  • AngularJs get employee from factory
  • Proper way to use connect-multiparty with express.js?
  • using HTMLImports.whenReady not working in chrome
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • reshape alternating columns in less time and using less memory
  • Net Present Value in Excel for Grouped Recurring CF