deezer_playback 0.0.2

Flutter Android iOS

A new flutter plugin project.

Deezer Playback #

Deezer Playback Plugin.

No iOS Implementation yet, WIP..

Features #

  • Connect / Authorize
  • Play (track)
  • Resume / pause
  • Queue
  • Playback position
  • Seek
  • Seek to relative position
  • Play Next
  • Play Previous
  • Repeat
  • Search For Tracks
  • Get Track

Installation #

IMPORTANT: Make sure you have the Deezer app installed and that you are logged in or your test device!

First, add deezer_playback as a dependency in your pubspec.yaml file.

Afterwards, download the Deezer Android SDK here and move the deezer-sdk--x.x.x.aar file to android/app/libs/ in your project.

IMPORTANT: Make sure you add permissions bellow to your Android Manifest located in /android/app/src/main/AndroidManifest.xml !

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-library android:name="org.apache.http.legacy" android:required="false" />

Then initialize the deezer playback sdk like this

@override
  void initState() {
    super.initState();
    initConnector();
    connect();
  }

  /// Initialize the Deezer playback sdk, by calling iniatilizeDeezer
  Future<void> initConnector() async {
    try {
      await DeezerPlayBack.iniatilizeDeezer(appId: "").then(
          (connected) {
        if (!mounted) return;
        // If the method call is successful, update the state to reflect this change
        setState(() {
          _connectedToDeezer = connected;
        });
      }, onError: (error) {
        // If the method call trows an error, print the error to see what went wrong
        print(error);
      });
    } on PlatformException {
      print('Failed to connect.');
    }
  }
  /// Initialize the Deezer playback sdk, by calling DeezerConnect
  Future<void> connect() async {
    try {
      await DeezerPlayback.connectToDeezer().then((authorised) {
        if (!mounted) return;
        // If the method call is successful, update the state to reflect this change
        setState(() {
          _connectedToDeezer = authorised;
        });
        print("we authorized deezer"+_connectedToDeezer.toString());
      }, onError: (error) {
        // If the method call trows an error, print the error to see what went wrong
        print(error);
      });
    } on PlatformException {
      print('Failed to connect.');
    }
  }

After this you can use all the available methods

Available methods #

Methoddescriptionparametersnotes
iniatilizeDeezerInitilizes the deezer playback sdkappId,
connectToDeezerConnect to deezer account
playPlay's a deezer track, album or playlisttrack Id
pausePause's the currently playing track
resumeResumes the currently paused track
skipNextPlay's the next track
skipPreviousPlay's the previous track
seekToSeeks to the passed timetime(mS)
seekToRelativePositionSeeks to relative position+-time(mS)
toggleRepeatToggle Repeat options
getPlaybackPositionGet's the current tracks playback position
searchTracksGet tracks by searchingany keyword
getTrackGet track by IDid(string)

Changelog #

See CHANGELOG.md.

Contributing #

Feel free to contribute by opening issues and/or pull requests. Your feedback is very welcome!

License #

MIT License

Copyright (c) [2019] [NARU ENTREPRISE]