Giter Club home page Giter Club logo

songpickerane's Introduction

SongPickerANE

A song picker/player AIR native extension for iOS and Android.

Author: Rich Lovejoy (https://github.com/richpixel)

The SongPicker Air Native Extension lets you choose a song from your music library on your iOS or Android device using the native media picker, and play it back using the native media player.

#Notes:#

  • You must include the following line in the Android manifest section of your app config xml file to use the picker:

      <application>
      <activity android:name="com.newpixel.songpicker.PickSongActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"></activity>
      </application>
    
  • You must specify the iOS SDK to build against when packaging an app for iOS. (ActionScript Build Packaging > Apple iOS > Native Extensions)

  • On iOS it seems to intermittently crash if you try to init the SongPicker too soon after the app starts running. Try waiting for user interaction.

#Usage#

Include the SongPicker.ane in your project.

import com.newpixel.air.nativeextensions.SongPicker; import com.newpixel.air.nativeextensions.SongPickerEvent;

...

SongPicker.instance.addEventListener(SongPickerEvent.SONG_CHOSEN, songChooseHandler);
SongPicker.instance.addEventListener(SongPickerEvent.CANCELLED_SONG_PICKER, cancelPickHandler);	
SongPicker.instance.pickSong();

#API#

SongPicker class methods

  • pickSong():void Bring up the native media picker to allow a user to choose a song from his library. Triggers the SongPickerEvent.SONG_CHOSEN or SongPickerEvent.CANCELLED_SONG_PICKER when the picker is dismissed.

  • playSong(songId:String="", position:Number=-1):void Begin playing a song with the specified ID, or resume playing the current song if songId is "". Args: - songId: The persistent ID of the song to play, which is obtained after picking a song with the picker. - position: A playhead position in seconds, to begin playing the song. The default value -1 tells the player to begin playing at the start of the song or to resume where it left off.

  • pauseSong():void Pause the current song playback.

  • stopSong():void Stop current song playback.

SongPickerEvent

  • SONG_CHOSEN: Triggered when the user has selected a song from the media picker. The following properties will be available in the event object: - ID (String): persistent ID of the song. This is a 64-bit number on iOS and a URI on Android. - title (String): title of track. - artist (String): artist of track. - duration (int): length of the track in seconds

  • CANCELLED_SONG_PICKER: User has cancelled picking a song.

  • SONG_FINISHED: Playback of current song has finished.

#Examples#

See the SongPickerExample project which can be built with FlashBuilder.

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.