【问题标题】:How to force an app chooser for video player?如何强制视频播放器的应用选择器?
【发布时间】:2015-11-04 12:16:22
【问题描述】:

我有list 下载的加密文件视频,但默认的android 播放器无法播放它们。我创建了自己的播放器来播放加密视频。所以我想要的是当用户点击加密视频时,它会弹出“完成操作?”然后他们选择所需的球员。我应该在我的播放器应用程序中添加什么来实现这一点?请帮忙

我希望我的视频播放器出现在列表中,例如 this

这是我下一个获取所选视频路径的课程,我如何获取路径?我希望播放器播放从我下载的确切选择的视频。

import java.security.GeneralSecurityException;

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

/**
 * A PlayActivity variant that plays an encrypted video.
 */
public class PlayActivity2 extends APlayActivity {

    @Override
    public Cipher getCipher() throws GeneralSecurityException {
        final Cipher c = Cipher.getInstance("ARC4");    // NoSuchAlgorithmException, NoSuchPaddingException
        c.init(Cipher.DECRYPT_MODE, new SecretKeySpec("BrianIsInTheKitchen".getBytes(), "ARC4"));   // InvalidKeyException
        return c;
    }

    @Override
    public String getPath() {



        return "THE SELECTED PATH OF THE ENCRYPTED VIDEO";
    }
}

【问题讨论】:

    标签: android


    【解决方案1】:

    您可以尝试将其添加到您的

    manifest.xml

    用于将您的活动注册为视频播放器

    <!-- Video player -->
        <activity android:name=".APlayActivity" android:label="@string/app_name"
           android:screenOrientation="sensorLandscape">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="rtsp" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="video/*" />
                <data android:mimeType="application/sdp" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="http" />
                <data android:mimeType="video/*" />
            </intent-filter>
        </activity>
    

    【讨论】:

    • 如何获取所选视频的路径,以便它可以在播放器上开始播放。我希望它从这个方法 public String getPath() { 目录中返回。返回“加密视频的选择路径”; }
    【解决方案2】:

    您需要声明一个intent-filter,以便您可以处理视频的文件格式,以便在您调用共享意图时调用播放器Activity 来播放视频。 例如,您可以在您的播放器&lt;activity&gt; 中添加类似这样的内容Mainfest.xml

    <!-- This activity also handles "SEND" and "SEND_MULTIPLE" with media data -->
    <intent-filter>
        <action android:name="android.intent.action.SEND"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:mimeType="video/*"/>
    </intent-filter>
    

    还要查看接收隐式意图下的文档here

    【讨论】:

    • 现在..请问如何获取所选视频的路径,以便它可以开始在播放器上播放。我希望它从这个方法 public String getPath() { 目录中返回。 return "加密的选定路径
    • 您从列表中获得的文件在哪里??
    猜你喜欢
    • 1970-01-01
    • 2012-12-13
    • 1970-01-01
    • 2021-12-03
    • 2020-05-05
    • 1970-01-01
    • 2019-08-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多