【问题标题】:Streaming Live Ustream video to Android App将直播 Ustream 视频流式传输到 Android 应用程序
【发布时间】:2014-09-27 02:44:08
【问题描述】:

我有一个 Android 应用程序,我想实现一个功能,让我可以播​​放来自 Ustream 的实时视频,但我不知道这是否可以使用嵌入代码来完成。我看过this question,但它并没有真正帮助。 有没有人幸运地实现了这个或类似的东西?

干杯

【问题讨论】:

    标签: java android video embed


    【解决方案1】:

    请查看他们是否为您提供了带有“rtsp”链接的 API。 (我认为他们会。) 然后,您必须在 VideoView URI 中使用它。它会是这样的:

    public class MainActivity extends ActionBarActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            VideoView videoView = (VideoView) findViewById(R.id.video);
            Uri video = Uri.parse("{YOUR RTSP LINK HERE}");
    
            videoView.setVideoURI(video);
            videoView.start();      
        }
    
        (...)
    }
    

    还有你的布局文件 main_activity.xml

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="{yourpackageandsuch}.MainActivity" >
    
        <VideoView
            android:id="@+id/video"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true" />
    
    </RelativeLayout>
    

    【讨论】:

    • 感谢您的帮助。我将继续寻找 RTSP 链接,但我在视频中看不到任何与此相似的内容:/
    猜你喜欢
    • 2016-12-03
    • 1970-01-01
    • 2012-07-20
    • 2012-03-16
    • 2010-12-29
    • 2014-02-16
    • 2018-01-28
    • 1970-01-01
    相关资源
    最近更新 更多