Exoplayer shows blank screen when DRM session manager set to media source

1k views Asked by At

I am trying to play DASH video stream, I am using Pallycon service to manage keys. The below code works fine when drmSessionManager set to the ExoPlayerFactory.newSimpleInstance (deprecated) instance, but When I set drmSessionManager seperately for media source, player shows blank screen. And not showing any error in logcat.


public class MainActivity extends AppCompatActivity {


    private PallyconEventListener pallyconEventListener = new PallyconEventListener() {
        @Override
        public void onDrmKeysLoaded(Map<String, String> map) {

        }

        @Override
        public void onDrmSessionManagerError(Exception e) {

        }

        @Override
        public void onDrmKeysRestored() {

        }

        @Override
        public void onDrmKeysRemoved() {

        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        PlayerView playerView = findViewById(R.id.player_view);

        String siteId = "XXXX";
        String siteKey = "XXXX";
        PallyconWVMSDK WVMAgent = null;
        try {
            WVMAgent = PallyconWVMSDKFactory.getInstance(this);
            WVMAgent.init(this, null, siteId, siteKey);
            WVMAgent.setPallyconEventListener(pallyconEventListener);
        } catch (PallyconDrmException e) {
            e.printStackTrace();
        } catch (UnAuthorizedDeviceException e) {
            e.printStackTrace();
        }

        // TODO : 2.set content information
        UUID drmSchemeUuid = UUID.fromString((C.WIDEVINE_UUID).toString());
        Uri uri = Uri.parse("http://www.example.com/index.mpd");
        String drmLicenseUrl = "http://license.pallycon.com/ri/licenseManager.do";
        String cid = "COOL";
        String userId = "lpa";
        String ptoken = "";

        DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null;
        try {
            drmSessionManager = Objects.requireNonNull(WVMAgent).createDrmSessionManagerByToken(drmSchemeUuid, drmLicenseUrl, uri, userId, cid, ptoken, false);
        } catch (PallyconDrmException e) {
            e.printStackTrace();
        }

        DataSource.Factory dataSourceFactory = new DefaultHttpDataSourceFactory("cool");
        SimpleExoPlayer exoPlayer = new SimpleExoPlayer.Builder(this, new DefaultRenderersFactory(this)).setTrackSelector(new DefaultTrackSelector(this)).build();
        playerView.setPlayer(exoPlayer);

        MediaSource mediaSource2 = new DashMediaSource.Factory(dataSourceFactory).setDrmSessionManager(drmSessionManager).createMediaSource(uri);
        exoPlayer.prepare(mediaSource2);
        exoPlayer.setPlayWhenReady(true);
    }
}

0

There are 0 answers