Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlatformException on setUrl method call #18

Closed
maxsalo17 opened this issue Dec 30, 2019 · 10 comments
Closed

PlatformException on setUrl method call #18

maxsalo17 opened this issue Dec 30, 2019 · 10 comments
Assignees

Comments

@maxsalo17
Copy link

When i call setUrl method, i have "PlatformException (PlatformException(Error: java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference"

My player class:
`import 'package:just_audio/just_audio.dart';

class RadioAudioPlayer {
AudioPlayer player;
static final RadioAudioPlayer _instance = RadioAudioPlayer._internal();

factory RadioAudioPlayer() {
return _instance;
}

RadioAudioPlayer._internal();

initialize(){
player = AudioPlayer();
}

playFromUrl(url)async{
await player?.setUrl(url);
player?.play();
}

stop() async {
await player?.stop();
}

}`

@ryanheise ryanheise self-assigned this Dec 31, 2019
@ryanheise
Copy link
Owner

Can you share stack trace from the logcat logs? That will tell me what line number the exception occurred on.

@ryanheise
Copy link
Owner

I have just done a major re-implementation so whatever bug you encountered might be gone. Can you please try it and let me know (including stack traces) if you still get an error.

@maxsalo17
Copy link
Author

Stacktrace from logcat:

`2019-12-31 16:28:52.486 14407-14407/org.rfnd.transistor.radio.app E/AccessibilityBridge: VirtualView node must not be the root node.
2019-12-31 16:28:52.785 14407-14407/org.rfnd.transistor.radio.app E/AccessibilityBridge: VirtualView node must not be the root node.
2019-12-31 16:28:53.887 14407-16283/org.rfnd.transistor.radio.app I/NuMediaExtractor: [setDataSource]line:83 setDataSource(http://online.1043.com.ua:8000/1043fm?type=.mp3/;stream.mp3)
2019-12-31 16:28:53.912 14407-14407/org.rfnd.transistor.radio.app E/AccessibilityBridge: VirtualView node must not be the root node.
2019-12-31 16:28:53.922 14407-16283/org.rfnd.transistor.radio.app I/MediaHTTP: user-agent:stagefright/1.2 (Linux;Android 7.0)
2019-12-31 16:28:53.942 14407-16283/org.rfnd.transistor.radio.app I/NuCachedSource2: lowwater = 4194304 bytes, highwater = 20971520 bytes, keepalive = 15000000 us
2019-12-31 16:28:54.029 14407-16287/org.rfnd.transistor.radio.app I/NuCachedSource2: [fetchInternal]line:345 fetchInternal, at 0 + 0
2019-12-31 16:28:54.049 14407-16283/org.rfnd.transistor.radio.app E/WVMExtractor: Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
2019-12-31 16:28:54.307 14407-16287/org.rfnd.transistor.radio.app I/System.out: [socket][1] connection online.1043.com.ua/194.135.81.16:8000;LocalPort=-1(30000)
2019-12-31 16:28:54.372 14407-16287/org.rfnd.transistor.radio.app I/System.out: [socket][/10.100.114.184:55607] connected
2019-12-31 16:28:54.374 14407-16287/org.rfnd.transistor.radio.app I/System.out: [OkHttp] sendRequest>>
2019-12-31 16:28:54.376 14407-16287/org.rfnd.transistor.radio.app I/System.out: [OkHttp] sendRequest<<
2019-12-31 16:28:55.215 14407-16287/org.rfnd.transistor.radio.app I/NuCachedSource2: bandwidth = 0 bytes/s
2019-12-31 16:28:55.216 14407-16287/org.rfnd.transistor.radio.app I/NuCachedSource2: [fetchInternal]line:345 fetchInternal, at 0 + 65536
2019-12-31 16:28:55.219 14407-16283/org.rfnd.transistor.radio.app I/NuCachedSource2: [readAt]line:606 ---Cache (1) is shot again, result = 8192 ---
2019-12-31 16:28:58.890 14407-16287/org.rfnd.transistor.radio.app I/NuCachedSource2: bandwidth = 27083 bytes/s
2019-12-31 16:28:58.893 14407-16287/org.rfnd.transistor.radio.app I/NuCachedSource2: [fetchInternal]line:345 fetchInternal, at 0 + 131072
2019-12-31 16:28:58.893 14407-16283/org.rfnd.transistor.radio.app I/NuCachedSource2: [readAt]line:606 ---Cache (2) is shot again, result = 8192 ---
2019-12-31 16:29:02.949 14407-16287/org.rfnd.transistor.radio.app I/NuCachedSource2: bandwidth = 22103 bytes/s
2019-12-31 16:29:02.949 14407-16287/org.rfnd.transistor.radio.app I/NuCachedSource2: [fetchInternal]line:345 fetchInternal, at 0 + 196608
2019-12-31 16:29:02.950 14407-16283/org.rfnd.transistor.radio.app I/NuCachedSource2: [readAt]line:606 ---Cache (3) is shot again, result = 8192 ---
2019-12-31 16:29:03.038 14407-16283/org.rfnd.transistor.radio.app I/NuMediaExtractor: [selectTrack]line:320 index:0
2019-12-31 16:29:03.050 14407-16283/org.rfnd.transistor.radio.app W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference
2019-12-31 16:29:03.050 14407-16283/org.rfnd.transistor.radio.app W/System.err: at android.media.MediaFormat.getLong(MediaFormat.java:794)
2019-12-31 16:29:03.050 14407-16283/org.rfnd.transistor.radio.app W/System.err: at com.ryanheise.just_audio.AudioPlayer.blockingInitExtractorAndCodec(AudioPlayer.java:379)
2019-12-31 16:29:03.050 14407-16283/org.rfnd.transistor.radio.app W/System.err: at com.ryanheise.just_audio.AudioPlayer.lambda$setUrl$2$AudioPlayer(AudioPlayer.java:213)
2019-12-31 16:29:03.051 14407-16283/org.rfnd.transistor.radio.app W/System.err: at com.ryanheise.just_audio.-$$Lambda$AudioPlayer$WoHp8OTkJ2aXGrdSEBMGAV0jQUE.run(lambda)
2019-12-31 16:29:03.051 14407-16283/org.rfnd.transistor.radio.app W/System.err: at java.lang.Thread.run(Thread.java:761)
2019-12-31 16:29:03.122 14407-14443/org.rfnd.transistor.radio.app E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(Error: java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference, null, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)

#2 AudioPlayer._invokeMethod (package:just_audio/just_audio.dart:256:24)

#3 AudioPlayer.setUrl (package:just_audio/just_audio.dart:140:9)
#4 RadioAudioPlayer.playFromUrl (package:transistor/tools/audioPlayer.dart:23:22)
#5 RadioListBloc.playAudio (package:transistor/bloc/radioListBloc.dart:59:12)
#6 RadioListBloc.onAutoplay (package:transistor/bloc/radioListBloc.dart:54:12)
#7 RenderToggleable._handleTap (package:flutter/src/material/toggleable.dart:425:9)
#8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#9 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
#10 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
#11 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236:7)
#12 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
#13 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
#14 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
#15 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
#16 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
#17 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
#18 _rootRunUnary (dart:async/zone.dart:1138:13)
#19 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#20 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
#21 _invoke1 (dart:ui/hooks.dart:273:10)
#22 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)

`

@ryanheise
Copy link
Owner

Sorry I should have clarified that the new code is committed to git but not yet published to pub.dev until it's been tested, so to try it you would have to clone the repo.

@maxsalo17
Copy link
Author

Ok, I`ll try

@maxsalo17
Copy link
Author

Now it works, thank you. Is there any tutorial how to use audio_service with just_audio?

@ryanheise
Copy link
Owner

After a little more testing of just_audio and after this latest version is published, I will then update the audio_service example to use it. Hopefully within the next day or two.

@maxsalo17
Copy link
Author

@ryanheise, what about example?

@ryanheise
Copy link
Owner

Hi @maxsalo17

The example of audio_service has been updated now to use just_audio.

@github-actions
Copy link

github-actions bot commented Nov 8, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with just_audio.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants