2016-08-16 83 views
-2

我有视频inputs.how一个JSON解析器使用JSON如何在Android Studio中发挥使用JSON视频

http://astrovighnesh.com/admin/videosapi.php

,这是我的解析器来播放视频,需要发挥使用JSON这个视频

+1

JSON实际上不能播放视频。但你可以做的是解析YouTube的网址,并通过意向调用YouTube的应用程序,看看你是否可以为它的视频网址喂你的视频:) – Razgriz

+0

我还没有尝试任何即时通讯新的这个JSON,所以我需要适当的援助.. – maxwellmobile

+0

@maxwellmobile检查此参考:http://www.androidbegin.com/tutorial/android-video-streaming-videoview-tutorial/ –

回答

0

原始帖子here

首先,您需要获取YouTube视频网址,在您的情况下,这是“d2LAjSBm0lc”或“zUVe4_krJRw”。

您还需要“YouTube Android播放器API”,可以找到here

然后使用空的活动创建新项目。在布局XML中,添加以下代码:

<com.google.android.youtube.player.YouTubePlayerView 
     android:id=“@+id/videoView1“ 
     android:layout_width=“match_parent“ 
     android:layout_height=“wrap_content“ /> 

在YourActivity.Java类,改变基类胡亚蓉到YouTubeBaseActivity:您的活动

public class MainActivity extends YouTubeBaseActivity implements 
      YouTubePlayer.OnInitializedListener 

在OnCreate()函数中,添加下面的代码:

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    YouTubePlayerView youTubeView = (YouTubePlayerView) 
        findViewById(R.id.videoView1); 
    youTubeView.initialize(DeveloperKey.DEVELOPER_KEY, this); 
} 

在这里,你需要开发人员密钥,该密钥保存在静态类替换DeveloperKey:

public class DeveloperKey { 
    /** 
    * Please replace this with a valid API key which is enabled for the 
    * YouTube Data API v3 service. Go to the 
    * <a href=”https://code.google.com/apis/console/“>Google APIs Console</a> to 
    * register a new developer key. 
    */ 
    public static final String DEVELOPER_KEY = “abcdedefghijklmnopqrstuvwxyz”; 
} 

实现接口YouTubePlayer.OnInitializedListener:

@Override 
public void onInitializationSuccess(YouTubePlayer.Provider provider, 
      YouTubePlayer player, boolean wasRestored) { 
     if (!wasRestored) player.cueVideo(“d2LAjSBm0lc”); // your video to play 
} 
@Override 
public void onInitializationFailure(Provider arg0, 
      YouTubeInitializationResult arg1){ 
} 
+0

坦克非常适合我们的努力...... – maxwellmobile

相关问题