Youtube API in android doesn't work - android

I followed the instruction of this.But can not to make it work. Always got the "There was an error while playing" problem. Here is my steps:
Create the project in google play console
Enable the Youtube Data API for the project
Setup the credentials for the project
Import sample downloaded from google into Android studio
Change the package name to com.mydomain.youtubeapidemo
Change the developer key to the one in google play console
But I always get the "There was an error while playing" problem.
By the way, I'm using the following command to get the SHA1:
keytool -exportcert -alias androiddebugkey -keystore
~/.android/debug.keystore -list -v
What could be the reason? Thanks for any suggestion.
EDIT:
I got the following error message in my console:
04-27 23:25:28.132 4995-5050/? E/WVMExtractor﹕ Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
04-27 23:25:28.961 2798-2798/com.google.android.youtube.player E/MediaPlayer﹕ Should have subtitle controller already set
04-27 23:25:28.984 4995-5058/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
\04-27 23:25:29.046 4995-5058/? E/SoftFFmpegVideo﹕ unsupported role: video_decoder.mpeg2
04-27 23:25:29.046 4995-5058/? E/OMXNodeInstance﹕ setParameter(16777239) ERROR: 0x80001001
04-27 23:25:29.046 4995-5058/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
04-27 23:25:29.046 4995-5058/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
04-27 23:25:29.046 4995-5058/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
04-27 23:25:29.161 4995-5146/? E/SoftAVC﹕ Decoder failed: -2
04-27 23:25:29.161 4995-5060/? E/ACodec﹕ [OMX.google.h264.decoder] ERROR(0x80001001)
04-27 23:25:29.161 4995-5060/? E/ACodec﹕ signalError(omxError 0x80001001, internalError -2147483648)
04-27 23:25:29.162 4995-5057/? E/MediaCodec﹕ Codec reported err 0x80001001, actionCode 0, while in state 6
04-27 23:25:29.164 4995-5056/? E/NuPlayerDecoder﹕ Failed to dequeue input buffer for OMX.google.h264.decoder (err=-38)
04-27 23:25:29.164 4995-5049/? E/NuPlayer﹕ received error(0xffffffda) from video decoder, flushing(0), now shutting down
04-27 23:25:29.164 2798-2871/com.google.android.youtube.player E/MediaPlayer﹕ error (1, -38)
04-27 23:25:29.164 4995-5056/? E/NuPlayerDecoder﹕ failed to flush OMX.google.h264.decoder (err=-38)
04-27 23:25:29.164 4995-5049/? E/NuPlayer﹕ received error(0xffffffda) from video decoder, flushing(2), now shutting down
04-27 23:25:29.164 2798-2798/com.google.android.youtube.player E/MediaPlayer﹕ Error (1,-38)
04-27 23:25:29.165 2798-2815/com.google.android.youtube.player E/MediaPlayer﹕ error (1, -38)
04-27 23:25:30.415 2798-2798/com.google.android.youtube.player E/MediaPlayer﹕ Should have subtitle controller already set
04-27 23:25:30.452 4995-5159/? E/OMXNodeInstance﹕ setParameter(1866465283) ERROR: 0x8000101a
04-27 23:25:30.452 4995-5157/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
04-27 23:25:30.452 4995-5157/? E/ACodec﹕ [OMX.google.h264.decoder] storeMetaDataInBuffers failed w/ err -2147483648
04-27 23:25:31.983 4996-4996/? E/local_camera﹕ We have a problem with the hw connection 2 (No such file or directory)
04-27 23:25:31.984 2798-2871/com.google.android.youtube.player E/MediaPlayer﹕ error (100, 0)
04-27 23:25:31.984 2798-2798/com.google.android.youtube.player E/MediaPlayer﹕ Error (100,0)
04-27 23:25:31.987 495-554/system_process E/AudioService﹕ Media server died.
04-27 23:25:32.068 5181-5181/? E/MonoPipe﹕ Failed to fetch local time frequency when constructing a MonoPipe (res = -32). getNextWriteTimestamp calls will be non-functional
04-27 23:25:32.072 5181-5181/? E/SoundTriggerHwService﹕ couldn't load sound trigger module sound_trigger.primary (No such file or directory)
04-27 23:25:32.488 495-554/system_process E/AudioService﹕ Media server started.
04-27 23:25:33.279 5181-5194/? E/WVMExtractor﹕ Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
04-27 23:25:34.080 2798-2798/com.google.android.youtube.player E/MediaPlayer﹕ Should have subtitle controller already set
04-27 23:25:34.133 5181-5200/? E/SoftFFmpegVideo﹕ unsupported role: video_decoder.mpeg2
04-27 23:25:34.133 5181-5200/? E/OMXNodeInstance﹕ setParameter(16777239) ERROR: 0x80001001
04-27 23:25:34.231 5181-5281/? E/SoftAVC﹕ Decoder failed: -2
04-27 23:25:34.231 5181-5201/? E/ACodec﹕ [OMX.google.h264.decoder] ERROR(0x80001001)
04-27 23:25:34.231 5181-5201/? E/ACodec﹕ signalError(omxError 0x80001001, internalError -2147483648)
04-27 23:25:34.231 5181-5199/? E/MediaCodec﹕ Codec reported err 0x80001001, actionCode 0, while in state 6
04-27 23:25:34.232 5181-5198/? E/NuPlayerDecoder﹕ Failed to dequeue output buffer for OMX.google.h264.decoder (err=-38)
04-27 23:25:34.233 5181-5193/? E/NuPlayer﹕ received error(0xffffffda) from video decoder, flushing(0), now shutting down
04-27 23:25:34.233 5181-5198/? E/NuPlayerDecoder﹕ failed to flush OMX.google.h264.decoder (err=-38)
04-27 23:25:34.233 2798-2814/com.google.android.youtube.player E/MediaPlayer﹕ error (1, -38)
04-27 23:25:34.233 5181-5193/? E/NuPlayer﹕ received error(0xffffffda) from video decoder, flushing(2), now shutting down
04-27 23:25:34.233 2798-2814/com.google.android.youtube.player E/MediaPlayer﹕ error (1, -38)
04-27 23:25:34.233 2798-2798/com.google.android.youtube.player E/MediaPlayer﹕ Error (1,-38)
04-27 23:25:35.513 2798-2798/com.google.android.youtube.player E/MediaPlayer﹕ Should have subtitle controller already set
04-27 23:25:35.520 5181-5292/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
04-27 23:25:35.520 5181-5292/? E/ACodec﹕ [OMX.google.h264.decoder] storeMetaDataInBuffers failed w/ err -2147483648
04-27 23:25:35.521 5181-5294/? E/OMXNodeInstance﹕ setParameter(1866465283) ERROR: 0x8000101a
04-27 23:25:35.525 5181-5295/? E/SoftAVC﹕ Decoder failed: -2
04-27 23:25:35.525 5181-5292/? E/ACodec﹕ [OMX.google.h264.decoder] ERROR(0x80001001)
04-27 23:25:35.525 5181-5292/? E/ACodec﹕ signalError(omxError 0x80001001, internalError -2147483648)
04-27 23:25:35.525 5181-5291/? E/MediaCodec﹕ Codec reported err 0x80001001, actionCode 0, while in state 6
04-27 23:25:35.527 5181-5290/? E/NuPlayerDecoder﹕ Failed to dequeue input buffer for OMX.google.h264.decoder (err=-38)
04-27 23:25:35.527 5181-5285/? E/NuPlayer﹕ received error(0xffffffda) from video decoder, flushing(0), now shutting down
04-27 23:25:35.527 2798-2871/com.google.android.youtube.player E/MediaPlayer﹕ error (1, -38)
04-27 23:25:35.528 5181-5290/? E/NuPlayerDecoder﹕ failed to flush OMX.google.h264.decoder (err=-38)
04-27 23:25:35.528 5181-5285/? E/NuPlayer﹕ received error(0xffffffda) from video decoder, flushing(2), now shutting down
04-27 23:25:35.528 2798-2871/com.google.android.youtube.player E/MediaPlayer﹕ error (1, -38)
04-27 23:25:35.531 2798-2798/com.google.android.youtube.player E/MediaPlayer﹕ Error (1,-38)
04-27 23:25:36.694 2798-2798/com.google.android.youtube.player E/MediaPlayer﹕ Should have subtitle controller already set
04-27 23:25:36.709 5181-5306/? E/OMXNodeInstance﹕ setParameter(1866465283) ERROR: 0x8000101a
04-27 23:25:36.710 5181-5307/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
04-27 23:25:36.710 5181-5307/? E/ACodec﹕ [OMX.google.h264.decoder] storeMetaDataInBuffers failed w/ err -2147483648
04-27 23:25:36.722 5181-5310/? E/SoftAVC﹕ Decoder failed: -2
04-27 23:25:36.727 5181-5307/? E/ACodec﹕ [OMX.google.h264.decoder] ERROR(0x80001001)
04-27 23:25:36.727 5181-5307/? E/ACodec﹕ signalError(omxError 0x80001001, internalError -2147483648)
04-27 23:25:36.727 5181-5304/? E/MediaCodec﹕ Codec reported err 0x80001001, actionCode 0, while in state 6
04-27 23:25:36.729 5181-5303/? E/NuPlayerDecoder﹕ Failed to dequeue input buffer for OMX.google.h264.decoder (err=-38)
04-27 23:25:36.730 5181-5299/? E/NuPlayer﹕ received error(0xffffffda) from video decoder, flushing(0), now shutting down
04-27 23:25:36.733 2798-2871/com.google.android.youtube.player E/MediaPlayer﹕ error (1, -38)
04-27 23:25:36.739 5181-5303/? E/NuPlayerDecoder﹕ failed to flush OMX.google.h264.decoder (err=-38)
04-27 23:25:36.740 5181-5299/? E/NuPlayer﹕ received error(0xffffffda) from video decoder, flushing(2), now shutting down
04-27 23:25:36.749 2798-2859/com.google.android.youtube.player E/MediaPlayer﹕ error (1, -38)
04-27 23:25:36.766 2798-2798/com.google.android.youtube.player E/MediaPlayer﹕ Error (1,-38)
04-27 23:25:38.112 2798-2798/com.google.android.youtube.player E/MediaPlayer﹕ Should have subtitle controller already set
04-27 23:25:38.125 5181-5320/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
04-27 23:25:38.125 5181-5320/? E/ACodec﹕ [OMX.google.h264.decoder] storeMetaDataInBuffers failed w/ err -2147483648
04-27 23:25:38.125 5181-5321/? E/OMXNodeInstance﹕ setParameter(1866465283) ERROR: 0x8000101a
04-27 23:25:38.131 5181-5324/? A/libc﹕ Fatal signal 11 (SIGSEGV), code 1, fault addr 0x60 in tid 5324 (peg.aac.decoder)
04-27 23:25:38.238 85-85/? E/DEBUG﹕ AM write failure (32 / Broken pipe)
04-27 23:25:38.294 495-1532/system_process E/SharedPreferencesImpl﹕ Couldn't create directory for SharedPreferences file shared_prefs/log_files.xml
04-27 23:25:38.321 5183-5183/? E/local_camera﹕ We have a problem with the hw connection 2 (No such file or directory)
04-27 23:25:38.321 5182-5182/? E/local_camera﹕ We have a problem with the hw connection 2 (No such file or directory)
04-27 23:25:38.323 495-554/system_process E/AudioService﹕ Media server died.
04-27 23:25:38.323 2798-2814/com.google.android.youtube.player E/MediaPlayer﹕ error (100, 0)
04-27 23:25:38.323 2798-2798/com.google.android.youtube.player E/MediaPlayer﹕ Error (100,0)
04-27 23:25:38.412 5330-5330/? E/MonoPipe﹕ Failed to fetch local time frequency when constructing a MonoPipe (res = -32). getNextWriteTimestamp calls will be non-functional
04-27 23:25:38.417 5330-5330/? E/SoundTriggerHwService﹕ couldn't load sound trigger module sound_trigger.primary (No such file or directory)
04-27 23:25:38.824 495-554/system_process E/AudioService﹕ Media server started.

It works after I changed the video id in demo application. What I don't understand is it works if I put the video id from application to browser. Why the video in demo application doesn't work.

when you import the youtube android api demo ...
there you need to add your api key which one you have got from api store.
package com.examples.youtubeapidemo;
/**
* Static container class for holding a reference to your YouTube Developer Key.
*/
public class DeveloperKey {
/**
* Please replace this with a valid API key which is enabled for the
* YouTube Data API v3 service. Go to the
* Google Developers Console
* to register a new developer key.
*/
public static final String DEVELOPER_KEY = "Here you need to add your youtube api key ...dllk3m6SNbpRPHZLCly6Wq1pxM";
}

Related

ExoPlayer error: ACodec: signalError(omxError 0x80001019, internalError -2147483648)

I encountered an error when using react-native-video to play m3u8. What caused this?
m3u8 comes with a key, some can be played, some cannot be played
08-13 14:12:45.847 E/ACodec: [OMX.qcom.video.decoder.avc] storeMetaDataInBuffers failed w/ err -1010
08-13 14:12:45.878 E/ACodec: [OMX.qcom.video.decoder.avc] ERROR(0x80001019)
08-13 14:12:45.878 E/ACodec: signalError(omxError 0x80001019, internalError -2147483648)
08-13 14:12:45.884 E/MediaCodec: Codec reported err 0x80001019, actionCode 0, while in state 6
08-13 14:12:45.922 E/ExoPlayerImplInternal: Internal runtime error.
java.lang.IllegalStateException
at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)

Android Studio videoView - unexpected end of stream

I'm trying to play video from the URL. Everything seems fine in the first few minutes, but then it crashes and the message "Can't Play Video" occurs. My code:
videoView.setVisibility(View.VISIBLE);
videoView.setVideoPath(url);
videoView.setMediaController(mediaController);
videoView.seekTo(time);
videoView.start();
Logcat:
2020-04-03 22:02:29.572 25409-25409/com.modyf.anime_app W/InputTransport: Slow Input: 152ms so far, channel 'ClientState{7a1b727 uid 10348 pid 25409} (server)' publisher ~ publishKeyEvent: seq=1, deviceId=4, source=0x101, action=0x0, flags=0x8, keyCode=25, scanCode=114, metaState=0x0, repeatCount=0,downTime=101580658000000, eventTime=101580658000000
2020-04-03 22:03:54.751 25409-25421/com.modyf.anime_app W/MediaHTTPConnection: readAt 25214561 / 16799 => java.net.ProtocolException: unexpected end of stream
2020-04-03 22:05:11.419 25409-25421/com.modyf.anime_app W/MediaPlayerNative: info/warning (804, -1004)
2020-04-03 22:05:11.475 25409-25422/com.modyf.anime_app E/MediaPlayerNative: error (1, -1004)
2020-04-03 22:05:11.476 25409-25409/com.modyf.anime_app E/MediaPlayer: Error (1,-1004)
2020-04-03 22:05:11.476 25409-25409/com.modyf.anime_app D/VideoView: Error: 1,-1004
2020-04-03 22:05:11.604 25409-25439/com.modyf.anime_app W/Adreno-EGL: <qeglDrvAPI_eglGetConfigAttrib:612>: EGL_BAD_ATTRIBUTE
2020-04-03 22:05:11.606 25409-25439/com.modyf.anime_app D/vndksupport: Loading /vendor/lib64/hw/gralloc.msm8937.so from current namespace instead of sphal namespace.

How to fix videos that can be played although they are corrupted

My case is, I did to convert a video with a mediacodec lib, then I sent the converted file to another device. Before I sent to another device, that file could run normally. But when file is received, that file is corrupted but still can be played and show a dialog like "Can't properly play this file due to an unexpected error has occured".
This is an error log:
05-26 10:10:53.522 299-12376/? E/ACodec: [OMX.Intel.aac.decoder] ERROR(0x80001001)
05-26 10:10:53.522 299-12376/? E/ACodec: signalError(omxError 0x80001001, internalError -2147483648)
05-26 10:10:53.522 299-12376/? E/MediaCodec: Codec reported err 0x80001001, actionCode 0, while in state 6
05-26 10:10:53.522 299-12375/? E/NuPlayerDecoder: Failed to dequeue input buffer for OMX.Intel.aac.decoder (err=-38)
05-26 10:10:53.523 299-12365/? E/NuPlayer: received error(0xffffffda) from audio decoder, flushing(0), now shutting down
05-26 10:10:53.523 2608-14507/? E/MediaPlayer: error (1, -38)
05-26 10:10:53.523 2608-2608/? E/MediaPlayer: Error (1,-38)
05-26 10:10:53.523 2608-2608/? D/VideoView: Error: 1,-38
05-26 10:10:53.523 2608-2608/? D/MoviePlayerForL: Gallery MoviePlayer Receive error
05-26 10:10:53.523 299-12375/? E/NuPlayerDecoder: failed to flush OMX.Intel.aac.decoder (err=-38)
05-26 10:10:53.523 299-12365/? E/NuPlayer: received error(0xffffffda) from audio decoder, flushing(2), now shutting down
05-26 10:10:53.526 2608-29677/? E/MediaPlayer: error (1, -38)
05-26 10:10:53.527 299-12376/? E/SimpleSoftOMXComponent: 1
05-26 10:10:53.527 299-12376/? E/SimpleSoftOMXComponent: 2
05-26 10:10:53.527 299-12376/? E/SimpleSoftOMXComponent: 3
Now my question is, what makes that file is broken and how to fix it?

How to set the Android MediaCodec profile?

I am try to set the profile, such as:
MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline
The code snippet like this:
MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, config.getWidth(), config.getHeight());
format.setInteger(MediaFormat.KEY_COLOR_FORMAT,
MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
format.setInteger(MediaFormat.KEY_BIT_RATE, config.getBitrate());
format.setInteger(MediaFormat.KEY_FRAME_RATE, config.getHumanFPS());
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, config.getIFrameInterval());
format.setInteger(MediaFormat.KEY_PROFILE, MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline);
mEncoder = MediaCodec.createEncoderByType(MIME_TYPE);
mEncoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
But I got the following error:
07-24 08:05:54.981 I/OMX-VENC( 298): Component_init : OMX.qcom.video.encoder.avc : return = 0x0
07-24 08:05:54.989 E/OMX-VENC( 298): set_parameter: metamode is valid for input port only
07-24 08:05:54.989 E/OMXNodeInstance( 298): OMX_SetParameter() failed for StoreMetaDataInBuffers: 0x8000101a
07-24 08:05:54.992 E/ACodec ( 8612): [OMX.qcom.video.encoder.avc] storeMetaDataInBuffers (output) failed w/ err -2147483648
07-24 08:05:54.994 W/ACodec ( 8612): do not know color format 0x7fa30c04 = 2141391876
07-24 08:05:54.994 W/ACodec ( 8612): do not know color format 0x7f000789 = 2130708361
07-24 08:05:54.997 D/FFmpegMuxer( 8612): RECEIVED AUDIO DATA NOT ALL TRACKS ADDED
07-24 08:05:55.005 I/art ( 810): Explicit concurrent mark sweep GC freed 21609(1113KB) AllocSpace objects, 2(32KB) LOS objects, 39% free, 18MB/30MB, paused 2.045ms total 137.471ms
07-24 08:05:55.012 I/ACodec ( 8612): [OMX.qcom.video.encoder.avc] setupVideoEncoder failed
07-24 08:05:55.012 E/ACodec ( 8612): [OMX.qcom.video.encoder.avc] configureCodec returning error -38
07-24 08:05:55.012 E/ACodec ( 8612): signalError(omxError 0x80001001, internalError -2147483648)
07-24 08:05:55.013 E/MediaCodec( 8612): Codec reported err 0x80001001, actionCode 0, while in state 3
07-24 08:05:55.013 E/MediaCodec( 8612): configure failed with err 0x80001001, resetting...
07-24 08:05:55.014 I/OMX-VENC( 298): Component Deinit
07-24 08:05:55.016 I/OMXClient( 8612): Using client-side OMX mux.
07-24 08:05:55.023 I/OMX-VENC( 298): Component_init : OMX.qcom.video.encoder.avc : return = 0x0
--------- beginning of crash
07-24 08:05:55.028 E/AndroidRuntime( 8612): FATAL EXCEPTION: TextureMovieEncoder
07-24 08:05:55.028 E/AndroidRuntime( 8612): Process: com.camera.demo, PID: 8612
07-24 08:05:55.028 E/AndroidRuntime( 8612): android.media.MediaCodec$CodecException: Error 0x80001001
07-24 08:05:55.028 E/AndroidRuntime( 8612): at android.media.MediaCodec.native_configure(Native Method)
07-24 08:05:55.028 E/AndroidRuntime( 8612): at android.media.MediaCodec.configure(MediaCodec.java:577)
Where did i miss?
If you set the profile, you may need to set the level as well - have a look at setupAVCEncoderParameters in https://android.googlesource.com/platform/frameworks/av/+/6ade04174/media/libstagefright/ACodec.cpp. See https://stackoverflow.com/a/26293422/3115956 for a similar answer and an explanation on how to pick a value to set as level.

Media Codec : Insufficient sized buffer

When i play video with resolution 704x576 (using MediaCodec) . I'm seeing this error and app is crashing
Logs:
12-04 04:35:55.507 E/OMX-VDEC-1080P( 9621): Insufficient sized buffer given for playback, expected 2514944, got 2506752
12-04 04:35:55.507 E/OMXNodeInstance( 9621): OMX_UseBuffer failed with error -2147479547 (0x80001005)
12-04 04:35:55.507 E/ACodec (22699): registering GraphicBuffer 0 with OMX IL component failed: -2147483648
12-04 04:35:55.507 E/ACodec (22699): Failed to allocate output port buffers after port reconfiguration (error 0x80000000)
12-04 04:35:55.507 E/MediaCodec(22699): Codec reported an error. (omx error 0x80001001, internalError -2147483648)

Categories

Resources