Giter Site home page Giter Site logo

rxmusicplayer-android's People

Contributors

dimkonomis 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

rxmusicplayer-android's Issues

FIX : Progress not updating issue in Notification Controls

Issue : Issue is duration is in seconds and progress is in milliseconds (x1000) so always progress is greater than total duration.

Fix : Set duration as below

    private fun getMetadata(media: Media?): MediaMetadataCompat {
        val duration = (media?.duration?:0)*1000                             // <---------- Fix
        return MediaMetadataCompat.Builder()
            .putString(MediaMetadataCompat.METADATA_KEY_ART_URI, media?.image)
            .putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, media?.title)
            .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, media?.artist)
            .putString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI, media?.streamUrl)
            .putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, media?.id?.toString())
            .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, duration?.toLong())    // <---------- Fix
            .build()
    }

Dismissing notification only pauses, doesn't stop, audio

If you are playing audio and go to device home screen, then pause and swipe away (dismiss) the notification. Then make a phone call and hang up, then the notification will reappear and audio will start playing again. I think audio should be stopped when a notification is dismissed so that it doesn't start playing again after an audioFocusChange. Or audioFocusedChange should be handled differently? In my fork i just added .setDeleteIntent(dismiss(service)) to the notification.

[Question:] Byte array as an audio source.

Is it possible to play audio from byte array - PCM or WAV? I have a working Java code for it but I have never write code on Kotlin. It would be nice to adopt this code in your library.

public class ByteArrayExoPlayer {
    public Uri getUri(byte[] data) {
        try {
            URL url = new URL(null, "bytes:///audio", new BytesHandler(data));
            return Uri.parse(url.toURI().toString());
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }

    public static void playback(Context context, byte[] dataPcm){
        ExoPlayer exoPlayer = ExoPlayerFactory.newSimpleInstance(context, new DefaultTrackSelector(), new DefaultLoadControl());
//        exoPlayer.addListener(eventListener);

        final ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(dataPcm);
        Uri audioByteUri = new ByteArrayExoPlayer().getUri(dataPcm);
        DataSpec dataSpec = new DataSpec(audioByteUri);
        try {
            byteArrayDataSource.open(dataSpec);
        } catch (IOException e) {
            e.printStackTrace();
        }

        DataSource.Factory factory = new DataSource.Factory() {
            @Override
            public DataSource createDataSource() {
                return byteArrayDataSource;
            }
        };

        MediaSource audioSource = new ExtractorMediaSource(audioByteUri, factory, new DefaultExtractorsFactory(),null,null);
//        MediaSource audioSource = new ExtractorMediaSource.Factory(factory).createMediaSource(audioByteUri);

        exoPlayer.prepare(audioSource);
        exoPlayer.setPlayWhenReady(true);
    }
}

public class ByteUrlConnection extends URLConnection {
    private byte[] mData;

    ByteUrlConnection(URL url, byte[] data) {
        super(url);
        mData = data;
    }

    @Override
    public void connect() throws IOException {
    }

    @Override
    public InputStream getInputStream() throws IOException {
        return new ByteArrayInputStream(mData);
    }
}


public class BytesHandler extends URLStreamHandler {
    private byte[] mData;

    public BytesHandler(byte[] data) {
        mData = data;
    }

    @Override
    protected URLConnection openConnection(URL url) throws IOException {
        return new ByteUrlConnection(url, mData);
    }
}

Access current media duration

as we use media from URL at the most time we don't have the duration
is there a way to access the duration after loading it from the internet?

or to access ExoPlayer object globally

thank you very much

Calling stop when paused causes IllegalArgumentException

To reproduce: pause media, then call stop

04-04 15:22:52.278 14666-14666/com.prayapp.client W/System.err: Caused by: java.lang.IllegalArgumentException: Receiver not registered: com.orfium.rx.musicplayer.playback.BasePlayback$audioNoisyReceiver$1@fc2dfe6 04-04 15:22:52.279 14666-14666/com.prayapp.client W/System.err: at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:793) 04-04 15:22:52.279 14666-14666/com.prayapp.client W/System.err: at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1203) 04-04 15:22:52.279 14666-14666/com.prayapp.client W/System.err: at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:576) 04-04 15:22:52.279 14666-14666/com.prayapp.client W/System.err: at com.orfium.rx.musicplayer.playback.BasePlayback.unregisterNoiseReceiver(BasePlayback.kt:119) 04-04 15:22:52.279 14666-14666/com.prayapp.client W/System.err: at com.orfium.rx.musicplayer.playback.BasePlayback.stop(BasePlayback.kt:71) 04-04 15:22:52.279 14666-14666/com.prayapp.client W/System.err: at com.orfium.rx.musicplayer.media.MediaManager.handleStopRequest(MediaManager.kt:120) 04-04 15:22:52.279 14666-14666/com.prayapp.client W/System.err: at com.orfium.rx.musicplayer.media.MediaManager.access$handleStopRequest(MediaManager.kt:13) 04-04 15:22:52.279 14666-14666/com.prayapp.client W/System.err: at com.orfium.rx.musicplayer.media.MediaManager$subscribeQueue$state$1.accept(MediaManager.kt:62) 04-04 15:22:52.279 14666-14666/com.prayapp.client W/System.err: at com.orfium.rx.musicplayer.media.MediaManager$subscribeQueue$state$1.accept(MediaManager.kt:13) 04-04 15:22:52.279 14666-14666/com.prayapp.client W/System.err: at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63)

Waiting a while after sound stopped gives error

Hi, first of all, nice work!!

I found a bug when music has finished playing, if you then wait a while the broadcastReceiver crashes with following error:

2019-03-30 23:47:04.488 19052-19052/com.app.music.player E/ActivityThread: Service com.orfium.rx.musicplayer.media.MediaService has leaked IntentReceiver com.orfium.rx.musicplayer.playback.BasePlayback$audioNoisyReceiver$1@dfe2c57 that was originally registered here. Are you missing a call to unregisterReceiver()? android.app.IntentReceiverLeaked: Service com.orfium.rx.musicplayer.media.MediaService has leaked IntentReceiver com.orfium.rx.musicplayer.playback.BasePlayback$audioNoisyReceiver$1@dfe2c57 that was originally registered here. Are you missing a call to unregisterReceiver()? at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1538) at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1277) at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1555) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1528) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1516) at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:636) at com.orfium.rx.musicplayer.playback.BasePlayback.registerNoiseReceiver(BasePlayback.kt:107) at com.orfium.rx.musicplayer.playback.BasePlayback.play(BasePlayback.kt:42) at com.orfium.rx.musicplayer.media.MediaManager.play(MediaManager.kt:124) at com.orfium.rx.musicplayer.media.MediaManager.handlePlayRequest(MediaManager.kt:78) at com.orfium.rx.musicplayer.media.MediaManager.access$handlePlayRequest(MediaManager.kt:13) at com.orfium.rx.musicplayer.media.MediaManager$subscribeQueue$state$1.accept(MediaManager.kt:53) at com.orfium.rx.musicplayer.media.MediaManager$subscribeQueue$state$1.accept(MediaManager.kt:13) at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63) at io.reactivex.subjects.PublishSubject$PublishDisposable.onNext(PublishSubject.java:308) at io.reactivex.subjects.PublishSubject.onNext(PublishSubject.java:228) at com.orfium.rx.musicplayer.common.ExtensionsKt.playStop(Extensions.kt:14) at com.app.music.player.PopularAdapter$PopularViewHolder$bind$1.onClick(PopularAdapter.kt:41) at android.view.View.performClick(View.java:7333) at android.view.View.performClickInternal(View.java:7299) at android.view.View.access$3200(View.java:846) at android.view.View$PerformClick.run(View.java:27772) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:6981) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)

Also, the notification won't update if the music ended. The pause button stays in front and won't seem to toggle, pressing on it doesn't do a thing.

Configurable Notification

It would be great to be able to configure the notification.

For my use case I'd like to be able to specify a different resource ID for the small icon and a different intent for the content intent.

[Android 9] error on playStop() - startForegroundService

Hello, when i call playStop() on Android 9 I have an error:

PID: 31893
    Reason: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{3c706a4 u0 my.pacage.name/com.orfium.rx.musicplayer.media.MediaService}
    Load: 0.0 / 0.0 / 0.0
    CPU usage from 12833ms to 0ms ago (2019-09-05 08:59:52.016 to 2019-09-05 09:00:04.850) with 99% awake:

I'm calling RxMusicPlayer.start(this) in onCreate:

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        RxMusicPlayer.start(this)
        Stetho.initializeWithDefaults(this)
        hideMenuView.onClick { hideMenu() }
    }

In other Android versions everything works well, this problem exist only in Android 9.

firebase videos!

can it play videos from source like firebase, the link fetched from firebase of a video?

Cannot play media after calling stop

After sending Stop action to the player no additional media can be played. I believe this occurs because the ExoPlayer is released in PlaybackImpl stopPlayer method and does not appear to be re-initialized.

SeekBar Progress

It is not an issue all ok but want seekbar progress for every songs is it possible. I try currenplayback position but not working . Kindly help me out this. ThankYou.

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.