fork download
  1. package com.example.playyoutube;
  2.  
  3. import android.os.Bundle;
  4. import android.view.Menu;
  5. import android.widget.Toast;
  6.  
  7. import com.google.android.youtube.player.YouTubeBaseActivity;
  8. import com.google.android.youtube.player.YouTubeInitializationResult;
  9. import com.google.android.youtube.player.YouTubePlayer;
  10. import com.google.android.youtube.player.YouTubePlayer.ErrorReason;
  11. import com.google.android.youtube.player.YouTubePlayer.PlaybackEventListener;
  12. import com.google.android.youtube.player.YouTubePlayer.PlayerStateChangeListener;
  13. import com.google.android.youtube.player.YouTubePlayer.Provider;
  14. import com.google.android.youtube.player.YouTubePlayerView;
  15.  
  16. public class MainActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener{
  17.  
  18. private YouTubePlayerView playerView;
  19. private final String DEVELOPER_KEY = "AIzaSyD12ZgI_U2UI5pvOASxbA0ao2ikughIiPM";
  20. private final String video_id = "JHiNWkheC08";
  21. @Override
  22. protected void onCreate(Bundle savedInstanceState) {
  23. super.onCreate(savedInstanceState);
  24. setContentView(R.layout.activity_main);
  25. playerView = (YouTubePlayerView) findViewById(R.id.youtube_player);
  26. playerView.initialize(DEVELOPER_KEY, this);
  27.  
  28. }
  29.  
  30. @Override
  31. public boolean onCreateOptionsMenu(Menu menu) {
  32. // Inflate the menu; this adds items to the action bar if it is present.
  33. getMenuInflater().inflate(R.menu.main, menu);
  34. return true;
  35. }
  36.  
  37. @Override
  38. public void onInitializationFailure(Provider arg0,
  39. YouTubeInitializationResult arg1) {
  40. Toast.makeText(this, "Có lỗi", Toast.LENGTH_SHORT).show();
  41. }
  42.  
  43. @Override
  44. public void onInitializationSuccess(Provider provider, YouTubePlayer player,
  45. boolean flag) {
  46. // TODO Auto-generated method stub
  47. player.setPlaybackEventListener(playback);
  48. player.setPlayerStateChangeListener(playState);
  49. if(!flag)
  50. player.cueVideo(video_id);
  51. }
  52. private PlaybackEventListener playback = new PlaybackEventListener() {
  53.  
  54. @Override
  55. public void onStopped() {
  56. // TODO Auto-generated method stub
  57.  
  58. }
  59.  
  60. @Override
  61. public void onSeekTo(int arg0) {
  62. // TODO Auto-generated method stub
  63.  
  64. }
  65.  
  66. @Override
  67. public void onPlaying() {
  68. // TODO Auto-generated method stub
  69.  
  70. }
  71.  
  72. @Override
  73. public void onPaused() {
  74. // TODO Auto-generated method stub
  75.  
  76. }
  77.  
  78. @Override
  79. public void onBuffering(boolean arg0) {
  80. // TODO Auto-generated method stub
  81.  
  82. }
  83. };
  84. private PlayerStateChangeListener playState = new PlayerStateChangeListener() {
  85.  
  86. @Override
  87. public void onVideoStarted() {
  88. // TODO Auto-generated method stub
  89.  
  90. }
  91.  
  92. @Override
  93. public void onVideoEnded() {
  94. // TODO Auto-generated method stub
  95.  
  96. }
  97.  
  98. @Override
  99. public void onLoading() {
  100. // TODO Auto-generated method stub
  101.  
  102. }
  103.  
  104. @Override
  105. public void onLoaded(String arg0) {
  106. // TODO Auto-generated method stub
  107.  
  108. }
  109.  
  110. @Override
  111. public void onError(ErrorReason arg0) {
  112. // TODO Auto-generated method stub
  113.  
  114. }
  115.  
  116. @Override
  117. public void onAdStarted() {
  118. // TODO Auto-generated method stub
  119.  
  120. }
  121. };
  122. }
  123.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:16: error: class MainActivity is public, should be declared in a file named MainActivity.java
public class MainActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener{
       ^
Main.java:3: error: package android.os does not exist
import android.os.Bundle;
                 ^
Main.java:4: error: package android.view does not exist
import android.view.Menu;
                   ^
Main.java:5: error: package android.widget does not exist
import android.widget.Toast;
                     ^
Main.java:7: error: package com.google.android.youtube.player does not exist
import com.google.android.youtube.player.YouTubeBaseActivity;
                                        ^
Main.java:8: error: package com.google.android.youtube.player does not exist
import com.google.android.youtube.player.YouTubeInitializationResult;
                                        ^
Main.java:9: error: package com.google.android.youtube.player does not exist
import com.google.android.youtube.player.YouTubePlayer;
                                        ^
Main.java:10: error: package com.google.android.youtube.player.YouTubePlayer does not exist
import com.google.android.youtube.player.YouTubePlayer.ErrorReason;
                                                      ^
Main.java:11: error: package com.google.android.youtube.player.YouTubePlayer does not exist
import com.google.android.youtube.player.YouTubePlayer.PlaybackEventListener;
                                                      ^
Main.java:12: error: package com.google.android.youtube.player.YouTubePlayer does not exist
import com.google.android.youtube.player.YouTubePlayer.PlayerStateChangeListener;
                                                      ^
Main.java:13: error: package com.google.android.youtube.player.YouTubePlayer does not exist
import com.google.android.youtube.player.YouTubePlayer.Provider;
                                                      ^
Main.java:14: error: package com.google.android.youtube.player does not exist
import com.google.android.youtube.player.YouTubePlayerView;
                                        ^
Main.java:16: error: cannot find symbol
public class MainActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener{
                                  ^
  symbol: class YouTubeBaseActivity
Main.java:16: error: package YouTubePlayer does not exist
public class MainActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener{
                                                                              ^
Main.java:18: error: cannot find symbol
	private YouTubePlayerView playerView;
	        ^
  symbol:   class YouTubePlayerView
  location: class MainActivity
Main.java:22: error: cannot find symbol
	protected void onCreate(Bundle savedInstanceState) {
	                        ^
  symbol:   class Bundle
  location: class MainActivity
Main.java:31: error: cannot find symbol
	public boolean onCreateOptionsMenu(Menu menu) {
	                                   ^
  symbol:   class Menu
  location: class MainActivity
Main.java:38: error: cannot find symbol
	public void onInitializationFailure(Provider arg0,
	                                    ^
  symbol:   class Provider
  location: class MainActivity
Main.java:39: error: cannot find symbol
			YouTubeInitializationResult arg1) {
			^
  symbol:   class YouTubeInitializationResult
  location: class MainActivity
Main.java:44: error: cannot find symbol
	public void onInitializationSuccess(Provider provider, YouTubePlayer player,
	                                    ^
  symbol:   class Provider
  location: class MainActivity
Main.java:44: error: cannot find symbol
	public void onInitializationSuccess(Provider provider, YouTubePlayer player,
	                                                       ^
  symbol:   class YouTubePlayer
  location: class MainActivity
Main.java:52: error: cannot find symbol
	private PlaybackEventListener playback = new PlaybackEventListener() {
	        ^
  symbol:   class PlaybackEventListener
  location: class MainActivity
Main.java:84: error: cannot find symbol
	private PlayerStateChangeListener playState = new PlayerStateChangeListener() {
	        ^
  symbol:   class PlayerStateChangeListener
  location: class MainActivity
Main.java:23: error: cannot find symbol
		super.onCreate(savedInstanceState);
		^
  symbol:   variable super
  location: class MainActivity
Main.java:24: error: package R does not exist
		setContentView(R.layout.activity_main);
		                ^
Main.java:25: error: cannot find symbol
		playerView = (YouTubePlayerView) findViewById(R.id.youtube_player);
		              ^
  symbol:   class YouTubePlayerView
  location: class MainActivity
Main.java:25: error: package R does not exist
		playerView = (YouTubePlayerView) findViewById(R.id.youtube_player);
		                                               ^
Main.java:21: error: method does not override or implement a method from a supertype
	@Override
	^
Main.java:33: error: package R does not exist
		getMenuInflater().inflate(R.menu.main, menu);
		                           ^
Main.java:33: error: cannot find symbol
		getMenuInflater().inflate(R.menu.main, menu);
		^
  symbol:   method getMenuInflater()
  location: class MainActivity
Main.java:30: error: method does not override or implement a method from a supertype
	@Override
	^
Main.java:40: error: cannot find symbol
		Toast.makeText(this, "C? l?i", Toast.LENGTH_SHORT).show();
		                               ^
  symbol:   variable Toast
  location: class MainActivity
Main.java:40: error: cannot find symbol
		Toast.makeText(this, "C? l?i", Toast.LENGTH_SHORT).show();
		^
  symbol:   variable Toast
  location: class MainActivity
Main.java:37: error: method does not override or implement a method from a supertype
	@Override
	^
Main.java:43: error: method does not override or implement a method from a supertype
	@Override
	^
Main.java:52: error: cannot find symbol
	private PlaybackEventListener playback = new PlaybackEventListener() {
	                                             ^
  symbol:   class PlaybackEventListener
  location: class MainActivity
Main.java:84: error: cannot find symbol
	private PlayerStateChangeListener playState = new PlayerStateChangeListener() {
	                                                  ^
  symbol:   class PlayerStateChangeListener
  location: class MainActivity
37 errors
stdout
Standard output is empty