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

Change audio languages #2178

Closed
Dhaval3344 opened this issue Aug 7, 2019 · 5 comments
Closed

Change audio languages #2178

Dhaval3344 opened this issue Aug 7, 2019 · 5 comments

Comments

@Dhaval3344
Copy link

Dhaval3344 commented Aug 7, 2019

(!!!! Please be sure to follow the issue template, modify and submit the question!!!!, do not follow the template to remove Isuue)

(ps home problem highlights and demos please understand!)

Problem Description: I used this video player it's working good, now my question is how can i change audio language if in video there is multiple languages, i found onInfo() method using this videoPlayer.getGSYVideoManager().getPlayer().getMediaPlayer().setOnInfoListener() code.

in above code i got languages list like iMediaPlayer.getTrackInfo();

but when i click on list of language then how should i select track?
in android default videoview i did code for change language when user click on language list like:=> mediaPlayer.selectTrack(position + 1); , but how in this shuyu:gsyVideoPlayer ?

Please help me, Thank you!

7.0.2 has this problem!

GSY dependent version

For example implementation 'com.shuyu:gsyVideoPlayer-java:7.0.2'

My code is like this :=>

GSYVideoOptionBuilder gsyVideoOption = new GSYVideoOptionBuilder();
        gsyVideoOption.setThumbImageView(imageView)
                .setIsTouchWiget(true)
                .setRotateViewAuto(false)
                .setLockLand(false)
                .setAutoFullWithSize(false)
                .setShowFullAnimation(false)
                .setNeedLockFull(true)
                .setUrl(source2)
                .setCacheWithPlay(false)
                .setVideoTitle("")
                .setVideoAllCallBack(new GSYSampleCallBack() {
                    @Override
                    public void onPrepared(String url, Object... objects) {
                        Debuger.printfError("***** onPrepared **** " + objects[0]);
                        Debuger.printfError("***** onPrepared **** " + objects[1]);
                        super.onPrepared(url, objects);
                        //开始播放了才能旋转和全屏
                        orientationUtils.setEnable(true);
                        isPlay = true;
                        if (videoPlayer.getGSYVideoManager().getPlayer() != null) {
                            videoPlayer.getGSYVideoManager().getPlayer().getMediaPlayer().setOnInfoListener(new IMediaPlayer.OnInfoListener() {
                                @Override
                                public boolean onInfo(IMediaPlayer iMediaPlayer, int what, int extra) {
                                    Log.e("INfo", "========================" + iMediaPlayer.getTrackInfo().length);
                                    trackInfoArray = iMediaPlayer.getTrackInfo();

                                    if (isGetTrackInfo) {

                                        for (int i = 0; i < trackInfoArray.length; i++) {
                                            // you can switch out the language comparison logic to whatever works for you
                /*if (trackInfoArray[i].getTrackType() == MediaPlayer.TrackInfo.MEDIA_TRACK_TYPE_AUDIO
                        && trackInfoArray[i].getLanguage().equals(Locale.getDefault().getISO3Language())) {
                    mp.selectTrack(i);
                    break;
                }*/
                                            Log.e(TAG, "==========getTrackType" + trackInfoArray[i].getTrackType());
                                            Log.e(TAG, "==========MEDIA_TRACK_TYPE_AUDIO" + MediaPlayer.TrackInfo.MEDIA_TRACK_TYPE_AUDIO);
                                            Log.e(TAG, "==========trackInfoArray[i].getLanguage()" + trackInfoArray[i].getLanguage());

                                            Locale loc = new Locale(trackInfoArray[i].getLanguage());
                                            String languageName = loc.getDisplayLanguage(loc);
                                            GetLaguages getLanguageList = new GetLaguages();
                                            getLanguageList.setLangCode(trackInfoArray[i].getLanguage());
                                            getLanguageList.setLangName(languageName);
                                            if (!getLanguageList.getLangCode().equalsIgnoreCase("und")) {
                                                languageLists.add(getLanguageList);
                                            }

                                            Log.e(TAG, "==========getLanguage()==" + languageName);

                                            if (i == trackInfoArray.length - 1) {
                                                //Toast.makeText(playerActivity, "last Position is " + i, Toast.LENGTH_SHORT).show();
                                                Log.e(TAG, "last Position is==" + i);
                                                isGetTrackInfo = false;
                                                initAudioDialog();
                                            }
                                        }
                                    }

                                    //Init Language Audio List
                                    Log.e(TAG, "==========" + trackInfoArray.length);
                                    //mp.selectTrack(2);
                                    return true;
                                }
                            });
                        }
                        //设置 seek 的临近帧。
                        if (videoPlayer.getGSYVideoManager().getPlayer() instanceof Exo2PlayerManager) {
                            ((Exo2PlayerManager) videoPlayer.getGSYVideoManager().getPlayer()).setSeekParameter(SeekParameters.NEXT_SYNC);
                            Debuger.printfError("***** setSeekParameter **** ");
                        }
                    }

                    @Override
                    public void onEnterFullscreen(String url, Object... objects) {
                        super.onEnterFullscreen(url, objects);
                        Debuger.printfError("***** onEnterFullscreen **** " + objects[0]);//title
                        Debuger.printfError("***** onEnterFullscreen **** " + objects[1]);//当前全屏player
                    }

                    @Override
                    public void onAutoComplete(String url, Object... objects) {
                        super.onAutoComplete(url, objects);
                    }

                    @Override
                    public void onClickStartError(String url, Object... objects) {
                        super.onClickStartError(url, objects);
                    }

                    @Override
                    public void onQuitFullscreen(String url, Object... objects) {
                        super.onQuitFullscreen(url, objects);
                        Debuger.printfError("***** onQuitFullscreen **** " + objects[0]);//title
                        Debuger.printfError("***** onQuitFullscreen **** " + objects[1]);//当前非全屏player
                        if (orientationUtils != null) {
                            orientationUtils.backToProtVideo();
                        }
                    }
                })
                .setLockClickListener(new LockClickListener() {
                    @Override
                    public void onClick(View view, boolean lock) {
                        if (orientationUtils != null) {
                            //配合下方的onConfigurationChanged
                            orientationUtils.setEnable(!lock);
                        }
                    }
                })
                .setGSYVideoProgressListener(new GSYVideoProgressListener() {
                    @Override
                    public void onProgress(int progress, int secProgress, int currentPosition, int duration) {
                        Debuger.printfLog(" progress " + progress + " secProgress " + secProgress + " currentPosition " + currentPosition + " duration " + duration);
                    }
                })
                .build(videoPlayer);

        videoPlayer.startPlayLogic();
        videoPlayer.startAfterPrepared();
@CarGuo
Copy link
Owner

CarGuo commented Aug 7, 2019

like ((IjkMediaPlayer)getGSYVideoManager().getPlayer().getMediaPlayer()).selectTrack(); may help you .

or you can custom your IPlayerManager and setup PlayerFactory.setPlayManager(YourPlayerManager.class) , then you can added freely .

@Dhaval3344
Copy link
Author

like ((IjkMediaPlayer)getGSYVideoManager().getPlayer().getMediaPlayer()).selectTrack(); may help you .

or you can custom your IPlayerManager and setup PlayerFactory.setPlayManager(YourPlayerManager.class) , then you can added freely .

Hello @CarGuo ,

Using above code language not chaging getting crash,

My Code is:=> ((IjkMediaPlayer)videoPlayer.getGSYVideoManager().getPlayer().getMediaPlayer()).setOnInfoListener(new IMediaPlayer.OnInfoListener() {
@OverRide
public boolean onInfo(IMediaPlayer iMediaPlayer, int i, int i1) {
if (!isCalled) {
Log.e("INfo", "==" + iMediaPlayer.getTrackInfo().length);
((IjkMediaPlayer) videoPlayer.getGSYVideoManager().getPlayer().getMediaPlayer()).selectTrack(1);
// iMediaPlayer.
isCalled = true;
}
return true;
}
});

=================THIS IS CRASH REPORT===============================
A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2019-08-08 11:05:30.410 30948-30948/? A/DEBUG: Build fingerprint: 'xiaomi/mido/mido:7.0/NRD90M/V10.2.3.0.NCFMIXM:user/release-keys'
2019-08-08 11:05:30.410 30948-30948/? A/DEBUG: Revision: '0'
2019-08-08 11:05:30.410 30948-30948/? A/DEBUG: ABI: 'arm64'
2019-08-08 11:05:30.410 30948-30948/? A/DEBUG: pid: 30130, tid: 30886, name: ff_audio_dec >>> com.app.cinestool <<<
2019-08-08 11:05:30.410 30948-30948/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
2019-08-08 11:05:30.426 30948-30948/? A/DEBUG: Abort message: 'Assertion frame->buf[0] failed at libavcodec/decode.c:610
'
2019-08-08 11:05:30.426 30948-30948/? A/DEBUG: x0 0000000000000000 x1 00000000000078a6 x2 0000000000000006 x3 0000000000000008
2019-08-08 11:05:30.427 30948-30948/? A/DEBUG: x4 0000000000000000 x5 0000000000000000 x6 0000007fa328f000 x7 0000000000000000
2019-08-08 11:05:30.427 30948-30948/? A/DEBUG: x8 0000000000000083 x9 ffffffffffffffdf x10 0000000000000000 x11 0000000000000001
2019-08-08 11:05:30.427 30948-30948/? A/DEBUG: x12 ffffffffffffffff x13 0000000000000000 x14 0000000000000000 x15 000b9c190d4e5ad9
2019-08-08 11:05:30.427 30948-30948/? A/DEBUG: x16 0000007fa2b05ed0 x17 0000007fa2aaf510 x18 0000007f7e4e2468 x19 0000007f7cf294f8
2019-08-08 11:05:30.427 30948-30948/? A/DEBUG: x20 0000000000000006 x21 0000007f7cf29450 x22 0000000000000000 x23 0000007f7cf29178
2019-08-08 11:05:30.427 30948-30948/? A/DEBUG: x24 0000007f76013300 x25 0000000000000000 x26 0000007f779f0400 x27 0000007f816586b0
2019-08-08 11:05:30.427 30948-30948/? A/DEBUG: x28 0000000000000000 x29 0000007f7cf29060 x30 0000007fa2aac9a0
2019-08-08 11:05:30.427 30948-30948/? A/DEBUG: sp 0000007f7cf29040 pc 0000007fa2aaf518 pstate 0000000060000000
2019-08-08 11:05:30.447 30948-30948/? A/DEBUG: backtrace:
2019-08-08 11:05:30.447 30948-30948/? A/DEBUG: #00 pc 000000000006b518 /system/lib64/libc.so (tgkill+8)
2019-08-08 11:05:30.447 30948-30948/? A/DEBUG: #1 pc 000000000006899c /system/lib64/libc.so (pthread_kill+64)
2019-08-08 11:05:30.447 30948-30948/? A/DEBUG: #2 pc 0000000000023ee8 /system/lib64/libc.so (raise+24)
2019-08-08 11:05:30.447 30948-30948/? A/DEBUG: #3 pc 000000000001c96c /system/lib64/libc.so (abort+52)
2019-08-08 11:05:30.447 30948-30948/? A/DEBUG: #4 pc 00000000000e8200 /data/app/com.app.cinestool-2/lib/arm64/libijkffmpeg.so

@CarGuo
Copy link
Owner

CarGuo commented Aug 12, 2019

Could you provide some video stream which support switching audio tracks for test?

@Dhaval3344
Copy link
Author

@CarGuo
Copy link
Owner

CarGuo commented Aug 12, 2019

image

    .setVideoAllCallBack(new GSYSampleCallBack() {
                    @Override
                    public void onPrepared(String url, Object... objects) {
                        Debuger.printfError("***** onPrepared **** " + objects[0]);
                        Debuger.printfError("***** onPrepared **** " + objects[1]);

                        IjkTrackInfo[] ijkTrackInfos = ((IjkMediaPlayer)detailPlayer.getGSYVideoManager().getPlayer().getMediaPlayer()).getTrackInfo();

                        if(ijkTrackInfos != null && ijkTrackInfos.length > 0) {
                            for (IjkTrackInfo ijkTrackInfo : ijkTrackInfos) {
                                Debuger.printfError("********* " + ijkTrackInfo);
                            }
                            ((IjkMediaPlayer)detailPlayer.getGSYVideoManager().getPlayer().getMediaPlayer()).selectTrack(2);
                        }

                        super.onPrepared(url, objects);

                    }

@CarGuo CarGuo closed this as completed Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants