javaertj / simpledlna

基于cling实现的Android投屏方案
208 stars 53 forks source link

可以播放网络的么 #1

Closed Alexxiaopang closed 2 years ago

Alexxiaopang commented 4 years ago

如题,能否播放网络地址?

javaertj commented 2 years ago

可以的 `

     String sourceUrl = mMaxMediaData.getSourceUrl();
      if (mMaxMediaData.isLocalMediaData()) {
          sourceUrl = mMaxMediaData.getLocalVideoPath();
      }
      final MediaInfo mediaInfo = new MediaInfo();
      if (mMaxMediaData.isLocalMediaData()) {
          mediaInfo.setFilePath(sourceUrl);
      }
      mediaInfo.setMediaId(EncryptUtils.encryptMD5ToString(sourceUrl));
      mediaInfo.setMediaType(MediaInfo.TYPE_VIDEO);
      mediaInfo.setMediaName(mMaxMediaData.getTitle());
      mediaInfo.setUri(sourceUrl);
      mDLNAPlayer.setDataSource(mediaInfo);
      mDLNAPlayer.start(new DLNAControlCallback() {
          @Override
          public void onSuccess(@Nullable ActionInvocation invocation) {
              ToastUtils.showShort("投屏成功!");
              getContentView().post(new Runnable() {
                  @Override
                  public void run() {
                      dismiss();
                  }
              });
          }

          @Override
          public void onReceived(@Nullable ActionInvocation invocation, @Nullable Object... extra) {

          }

          @Override
          public void onFailure(@Nullable ActionInvocation invocation, int errorCode, @Nullable String errorMsg) {
              ToastUtils.showShort("投屏失败!");
          }
      });

`