• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java LibVlcUtil类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.videolan.libvlc.LibVlcUtil的典型用法代码示例。如果您正苦于以下问题:Java LibVlcUtil类的具体用法?Java LibVlcUtil怎么用?Java LibVlcUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

LibVlcUtil类属于org.videolan.libvlc包,在下文中一共展示了LibVlcUtil类的21个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onCreate

点赞 3

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
/**
 * Simple friendly activity to tell the user something's wrong.
 *
 * Intent parameters (all optional):
 * runtimeError (bool) - Set to true if you want to show a runtime error
 *                       (defaults to a compatibility error)
 * message (string) - the more detailed problem
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.not_compatible);

    String errorMsg = LibVlcUtil.getErrorMsg();
    if(getIntent().getBooleanExtra("runtimeError", false))
        if(getIntent().getStringExtra("message") != null) {
            errorMsg = getIntent().getStringExtra("message");
            TextView tvo = (TextView)findViewById(R.id.message);
            tvo.setText(R.string.error_problem);
        }

    TextView tv = (TextView)findViewById(R.id.errormsg);
    tv.setText(getResources().getString(R.string.error_message_is) + "\n" + errorMsg);

    //AsyncHttpRequest asyncHttpRequest = new AsyncHttpRequest();
    //asyncHttpRequest.execute(Build.MODEL, Build.DEVICE);
}
 

开发者ID:smyhvae,
项目名称:VlcTest,
代码行数:28,
代码来源:CompatErrorActivity.java

示例2: onPopupMenu

点赞 3

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
    if (!LibVlcUtil.isHoneycombOrLater()) {
        // Call the "classic" context menu
        anchor.performLongClick();
        return;
    }

    PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
    popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu());
    setContextMenuItems(popupMenu.getMenu(), anchor, position);

    popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return handleContextItemSelected(item, position);
        }
    });
    popupMenu.show();
}
 

开发者ID:smyhvae,
项目名称:VlcTest,
代码行数:22,
代码来源:AudioAlbumsSongsFragment.java

示例3: prepareCacheFolder

点赞 3

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
@SuppressLint("NewApi")
public static void prepareCacheFolder(Context context) {
    if (LibVlcUtil.isFroyoOrLater() && AndroidDevices.hasExternalStorage() && context.getExternalCacheDir() != null)
        CACHE_DIR = context.getExternalCacheDir().getPath();
    else
        CACHE_DIR = Environment.getExternalStorageDirectory().getPath() + "/Android/data/" + context.getPackageName() + "/cache";
    ART_DIR = CACHE_DIR + "/art/";
    COVER_DIR = CACHE_DIR + "/covers/";
    PLAYLIST_DIR = CACHE_DIR + "/playlists/";

    for(String path : Arrays.asList(ART_DIR, COVER_DIR)) {
        File file = new File(path);
        if (!file.exists())
            file.mkdirs();
    }
}
 

开发者ID:smyhvae,
项目名称:VlcTest,
代码行数:17,
代码来源:AudioUtil.java

示例4: onPopupMenu

点赞 3

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
    if (!LibVlcUtil.isHoneycombOrLater()) {
        // Call the "classic" context menu
        anchor.performLongClick();
        return;
    }

    PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
    popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu());
    setContextMenuItems(popupMenu.getMenu(), anchor);

    popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return handleContextItemSelected(item, position);
        }
    });
    popupMenu.show();
}
 

开发者ID:smyhvae,
项目名称:VlcTest,
代码行数:22,
代码来源:AudioBrowserFragment.java

示例5: onContextPopupMenu

点赞 3

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onContextPopupMenu(View anchor, final int position) {
    if (!LibVlcUtil.isHoneycombOrLater()) {
        // Call the "classic" context menu
        anchor.performLongClick();
        return;
    }

    PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
    popupMenu.getMenuInflater().inflate(R.menu.video_list, popupMenu.getMenu());
    Media media = mVideoAdapter.getItem(position);
    setContextMenuItems(popupMenu.getMenu(), media);
    popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return handleContextItemSelected(item, position);
        }
    });
    popupMenu.show();
}
 

开发者ID:smyhvae,
项目名称:VlcTest,
代码行数:21,
代码来源:VideoGridFragment.java

示例6: setRemoteControlClientPlaybackState

点赞 3

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
/**
 * A function to control the Remote Control Client. It is needed for
 * compatibility with devices below Ice Cream Sandwich (4.0).
 *
 * @param p Playback state
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setRemoteControlClientPlaybackState(int state) {
    if (!LibVlcUtil.isICSOrLater() || mRemoteControlClient == null)
        return;

    switch (state) {
        case EventHandler.MediaPlayerPlaying:
            mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
            break;
        case EventHandler.MediaPlayerPaused:
            mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
            break;
        case EventHandler.MediaPlayerStopped:
            mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
            break;
    }
}
 

开发者ID:smyhvae,
项目名称:VlcTest,
代码行数:24,
代码来源:AudioService.java

示例7: updateRemoteControlClientMetadata

点赞 3

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateRemoteControlClientMetadata() {
    if (!LibVlcUtil.isICSOrLater()) // NOP check
        return;

    Media media = getCurrentMedia();
    if (mRemoteControlClient != null && media != null) {
        MetadataEditor editor = mRemoteControlClient.editMetadata(true);
        editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, media.getAlbum());
        editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, media.getArtist());
        editor.putString(MediaMetadataRetriever.METADATA_KEY_GENRE, media.getGenre());
        editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, media.getTitle());
        editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, media.getLength());
        // Copy the cover bitmap because the RemonteControlClient can recycle its artwork bitmap.
        Bitmap cover = getCover();
        editor.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, ((cover != null) ? cover.copy(cover.getConfig(), false) : null));
        editor.apply();
    }
}
 

开发者ID:smyhvae,
项目名称:VlcTest,
代码行数:20,
代码来源:AudioService.java

示例8: configureSurface

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
@Override
public int configureSurface(Surface surface, final int width, final int height, final int hal) {

    if (LibVlcUtil.isICSOrLater() || surface == null)
        return -1;
    if (width * height == 0)
        return 0;
    ExoVlcUtil.log(this, "configureSurface: " + width + "x" + height);

    final ConfigureSurfaceHolder holder = new ConfigureSurfaceHolder(surface);

    final Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {
        @Override
        public void run() {
            if (mSurface == holder.surface) {
                if (hal != 0)
                    view.getHolder().setFormat(hal);
                view.getHolder().setFixedSize(width, height);
            }

            synchronized (holder) {
                holder.configured = true;
                holder.notifyAll();
            }
        }
    });

    try {
        synchronized (holder) {
            while (!holder.configured)
                holder.wait();
        }
    } catch (InterruptedException e) {
        return 0;
    }
    return 1;
}
 

开发者ID:tyazid,
项目名称:Exoplayer_VLC,
代码行数:39,
代码来源:VLCRendererBuilder.java

示例9: configureSurface

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
@Override
public int configureSurface(Surface surface, final int width, final int height, final int hal) {

	if (LibVlcUtil.isICSOrLater() || surface == null)
		return -1;
	if (width * height == 0)
		return 0;
	ExoVlcUtil.log(this, "configureSurface: " + width + "x" + height);

	final ConfigureSurfaceHolder holder = new ConfigureSurfaceHolder(surface);

	final Handler handler = new Handler(Looper.getMainLooper());
	handler.post(new Runnable() {
		@Override
		public void run() {
			if (mSurface == holder.surface) {
				SurfaceHolder surfaceHolder = layoutHandler.getHolder();
				if (hal != 0)
					surfaceHolder.setFormat(hal);
				surfaceHolder.setFixedSize(width, height);
			}

			synchronized (holder) {
				holder.configured = true;
				holder.notifyAll();
			}
		}
	});

	try {
		synchronized (holder) {
			while (!holder.configured)
				holder.wait();
		}
	} catch (InterruptedException e) {
		return 0;
	}
	return 1;
}
 

开发者ID:tyazid,
项目名称:Exoplayer_VLC,
代码行数:40,
代码来源:VLCVideoSurfaceHandler.java

示例10: configureSurface

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
@Override
public int configureSurface(Surface surface, final int width, final int height, final int hal) {

	if (LibVlcUtil.isICSOrLater() || surface == null)
		return -1;
	if (width * height == 0)
		return 0;
	ExoVlcUtil.log(this, "configureSurface: " + width + "x" + height);

	final ConfigureSurfaceHolder holder = new ConfigureSurfaceHolder(surface);

	final Handler handler = new Handler(Looper.getMainLooper());
	handler.post(new Runnable() {
		@Override
		public void run() {
			if (mSurface == holder.surface) {
				if (hal != 0)
					view.getHolder().setFormat(hal);
				view.getHolder().setFixedSize(width, height);
			}

			synchronized (holder) {
				holder.configured = true;
				holder.notifyAll();
			}
		}
	});

	try {
		synchronized (holder) {
			while (!holder.configured)
				holder.wait();
		}
	} catch (InterruptedException e) {
		return 0;
	}
	return 1;
}
 

开发者ID:tyazid,
项目名称:Exoplayer_VLC,
代码行数:39,
代码来源:VLCRendererBuilder.java

示例11: mediaRouterAddCallback

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
/**
 * Add or remove MediaRouter callbacks. This is provided for version targeting.
 *
 * @param add true to add, false to remove
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void mediaRouterAddCallback(boolean add) {
    if(!LibVlcUtil.isJellyBeanMR1OrLater() || mMediaRouter == null) return;

    if(add)
        mMediaRouter.addCallback(MediaRouter.ROUTE_TYPE_LIVE_VIDEO, mMediaRouterCallback);
    else
        mMediaRouter.removeCallback(mMediaRouterCallback);
}
 

开发者ID:Tribler,
项目名称:tribler-android,
代码行数:15,
代码来源:VideoPlayerActivity.java

示例12: dimStatusBar

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
/**
 * Dim the status bar and/or navigation icons when needed on Android 3.x.
 * Hide it on Android 4.0 and later
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void dimStatusBar(boolean dim) {
    if (!LibVlcUtil.isHoneycombOrLater() || !Util.hasNavBar())
        return;
    int layout = 0;
    if (!Util.hasCombBar() && LibVlcUtil.isJellyBeanOrLater())
        layout = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    int visibility =  (dim ? (Util.hasCombBar()
            ? View.SYSTEM_UI_FLAG_LOW_PROFILE
                    : View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)
                    : View.SYSTEM_UI_FLAG_VISIBLE) | layout;
    mSurface.setSystemUiVisibility(visibility);
    mSubtitlesSurface.setSystemUiVisibility(visibility);
}
 

开发者ID:Tribler,
项目名称:tribler-android,
代码行数:19,
代码来源:VideoPlayerActivity.java

示例13: onCreate

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.player_remote);

    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mContext);

    mSurface = (SurfaceView) findViewById(R.id.remote_player_surface);
    mSurfaceHolder = mSurface.getHolder();
    mSurfaceFrame = (FrameLayout) findViewById(R.id.remote_player_surface_frame);
    String chroma = pref.getString("chroma_format", "");
    if(LibVlcUtil.isGingerbreadOrLater() && chroma.equals("YV12")) {
        mSurfaceHolder.setFormat(ImageFormat.YV12);
    } else if (chroma.equals("RV16")) {
        mSurfaceHolder.setFormat(PixelFormat.RGB_565);
    } else {
        mSurfaceHolder.setFormat(PixelFormat.RGBX_8888);
    }

    VideoPlayerActivity activity = (VideoPlayerActivity)getOwnerActivity();
    if (activity == null) {
        Log.e(TAG, "Failed to get the VideoPlayerActivity instance, secondary display won't work");
        return;
    }

    mSurfaceHolder.addCallback(activity.mSurfaceCallback);

    mSubtitlesSurface = (SurfaceView) findViewById(R.id.remote_subtitles_surface);
    mSubtitlesSurfaceHolder = mSubtitlesSurface.getHolder();
    mSubtitlesSurfaceHolder.setFormat(PixelFormat.RGBA_8888);
    mSubtitlesSurface.setZOrderMediaOverlay(true);
    mSubtitlesSurfaceHolder.addCallback(activity.mSubtitlesSurfaceCallback);

    /* Only show the subtitles surface when using "Full Acceleration" mode */
    if (mLibVLC != null && mLibVLC.getHardwareAcceleration() == LibVLC.HW_ACCELERATION_FULL)
        mSubtitlesSurface.setVisibility(View.VISIBLE);
    Log.i(TAG, "Secondary display created");
}
 

开发者ID:Tribler,
项目名称:tribler-android,
代码行数:39,
代码来源:VideoPlayerActivity.java

示例14: getCoverFromFolder

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
private static String getCoverFromFolder(Context context, Media media) {
    File f = LibVlcUtil.URItoFile(media.getLocation());
    if (f != null && f.getParentFile() != null && f.getParentFile().listFiles() != null)
        for (File s : f.getParentFile().listFiles()) {
            if (s.getAbsolutePath().endsWith("png")
                    || s.getAbsolutePath().endsWith("jpg"))
                return s.getAbsolutePath();
        }
    return null;
}
 

开发者ID:smyhvae,
项目名称:VlcTest,
代码行数:11,
代码来源:AudioUtil.java

示例15: dimStatusBar

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
/**
 * Dim the status bar and/or navigation icons when needed on Android 3.x.
 * Hide it on Android 4.0 and later
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void dimStatusBar(boolean dim) {
    if (!LibVlcUtil.isHoneycombOrLater() || !AndroidDevices.hasNavBar() || mIsNavMenu)
        return;
    int layout = 0;
    if (!AndroidDevices.hasCombBar() && LibVlcUtil.isJellyBeanOrLater())
        layout = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    int visibility =  (dim ? (AndroidDevices.hasCombBar()
            ? View.SYSTEM_UI_FLAG_LOW_PROFILE
                    : View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)
                    : View.SYSTEM_UI_FLAG_VISIBLE) | layout;
    mSurface.setSystemUiVisibility(visibility);
    mSubtitlesSurface.setSystemUiVisibility(visibility);
}
 

开发者ID:smyhvae,
项目名称:VlcTest,
代码行数:19,
代码来源:VideoPlayerActivity.java

示例16: onCreate

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.player_remote);

    mSurface = (SurfaceView) findViewById(R.id.remote_player_surface);
    mSurfaceHolder = mSurface.getHolder();
    mSurfaceFrame = (FrameLayout) findViewById(R.id.remote_player_surface_frame);
    String chroma = mSettings.getString("chroma_format", "");
    if(LibVlcUtil.isGingerbreadOrLater() && chroma.equals("YV12")) {
        mSurfaceHolder.setFormat(ImageFormat.YV12);
    } else if (chroma.equals("RV16")) {
        mSurfaceHolder.setFormat(PixelFormat.RGB_565);
    } else {
        mSurfaceHolder.setFormat(PixelFormat.RGBX_8888);
    }

    VideoPlayerActivity activity = (VideoPlayerActivity)getOwnerActivity();
    if (activity == null) {
        Log.e(TAG, "Failed to get the VideoPlayerActivity instance, secondary display won't work");
        return;
    }

    mSurfaceHolder.addCallback(activity.mSurfaceCallback);

    mSubtitlesSurface = (SurfaceView) findViewById(R.id.remote_subtitles_surface);
    mSubtitlesSurfaceHolder = mSubtitlesSurface.getHolder();
    mSubtitlesSurfaceHolder.setFormat(PixelFormat.RGBA_8888);
    mSubtitlesSurface.setZOrderMediaOverlay(true);
    mSubtitlesSurfaceHolder.addCallback(activity.mSubtitlesSurfaceCallback);

    /* Only show the subtitles surface when using "Full Acceleration" mode */
    if (mLibVLC != null && mLibVLC.getHardwareAcceleration() == LibVLC.HW_ACCELERATION_FULL)
        mSubtitlesSurface.setVisibility(View.VISIBLE);
    Log.i(TAG, "Secondary display created");
}
 

开发者ID:smyhvae,
项目名称:VlcTest,
代码行数:37,
代码来源:VideoPlayerActivity.java

示例17: configureSurface

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
@Override
public int configureSurface(Surface surface,final int width,final int height, final int hal) {

	System.out.println("VideoActivity.configureSurface() :"+width +" x "+height+" ; hal="+hal+"; >=ICS:"+LibVlcUtil.isICSOrLater());
    if (LibVlcUtil.isICSOrLater() || surface == null)
        return -1;
    if (width * height == 0)
        return 0;
    Log.d(TAG, "configureSurface: " + width +"x"+height);

    final ConfigureSurfaceHolder holder = new ConfigureSurfaceHolder(surface);

    final Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {
        @Override
        public void run() {
            if (mSurface == holder.surface && mSurfaceHolder != null) {
                if (hal != 0)
                    mSurfaceHolder.setFormat(hal);
                mSurfaceHolder.setFixedSize(width, height);
            } 

            synchronized (holder) {
                holder.configured = true;
                holder.notifyAll();
            }
        }
    });

    try {
        synchronized (holder) {
            while (!holder.configured)
                holder.wait();
        }
    } catch (InterruptedException e) {
        return 0;
    }
    return 1;

	
	
	
	/********************************************************************************/
	
	
	
  /*  Log.d(TAG, "configureSurface: width = " + width + ", height = " + height);
    if (LibVlcUtil.isICSOrLater() || surface == null)
        return -1;
    if (width * height == 0)
        return 0;
    if(hal != 0)
        holder.setFormat(hal);
    holder.setFixedSize(width, height);
    return 1;*/
}
 

开发者ID:tyazid,
项目名称:Exoplayer_VLC,
代码行数:57,
代码来源:VideoActivity.java

示例18: nativeVlcMsg

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
/**
 * 
 * @param code
 */
static void nativeVlcMsg(int code) {
	if (code == -1)
		log(" Lib VLC", "Err msg:" + LibVlcUtil.getErrorMsg());
}
 

开发者ID:tyazid,
项目名称:Exoplayer_VLC,
代码行数:9,
代码来源:ExoVlcUtil.java

示例19: setRingtone

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
public static void setRingtone(Media song, Context context){
    File newringtone = LibVlcUtil.URItoFile(song.getLocation());
    if( newringtone != null && !newringtone.exists()) {
        Toast.makeText(context.getApplicationContext(),context.getString(R.string.ringtone_error), Toast.LENGTH_SHORT).show();
        return;
    }

    ContentValues values = new ContentValues();
    values.put(MediaStore.MediaColumns.DATA, newringtone.getAbsolutePath());
    values.put(MediaStore.MediaColumns.TITLE, song.getTitle());
    values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/*");
    values.put(MediaStore.Audio.Media.ARTIST, song.getArtist());
    values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
    values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false);
    values.put(MediaStore.Audio.Media.IS_ALARM, false);
    values.put(MediaStore.Audio.Media.IS_MUSIC, false);

    Uri uri = MediaStore.Audio.Media.getContentUriForPath(newringtone.getAbsolutePath());
    Uri newUri;
    try {
        context.getContentResolver().delete(uri, MediaStore.MediaColumns.DATA + "=\"" + newringtone.getAbsolutePath() + "\"", null);
        newUri = context.getContentResolver().insert(uri, values);
        RingtoneManager.setActualDefaultRingtoneUri(
                context.getApplicationContext(),
                RingtoneManager.TYPE_RINGTONE,
                newUri
                );
    } catch(Exception e) {
        Toast.makeText(context.getApplicationContext(),
                context.getString(R.string.ringtone_error),
                Toast.LENGTH_SHORT).show();
        return;
    }

    Toast.makeText(
            context.getApplicationContext(),
            context.getString(R.string.ringtone_set, song.getTitle()),
            Toast.LENGTH_SHORT)
            .show();

}
 

开发者ID:smyhvae,
项目名称:VlcTest,
代码行数:42,
代码来源:AudioUtil.java

示例20: onCreate

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    // Get libVLC instance
    try {
        mLibVLC = VLCInstance.getLibVlcInstance();
    } catch (LibVlcException e) {
        e.printStackTrace();
    }

    mCallback = new HashMap<IAudioServiceCallback, Integer>();
    mCurrentIndex = -1;
    mPrevIndex = -1;
    mNextIndex = -1;
    mPrevious = new Stack<Integer>();
    mEventHandler = EventHandler.getInstance();
    mRemoteControlClientReceiverComponent = new ComponentName(getPackageName(),
            RemoteControlClientReceiver.class.getName());

    // Make sure the audio player will acquire a wake-lock while playing. If we don't do
    // that, the CPU might go to sleep while the song is playing, causing playback to stop.
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);

    IntentFilter filter = new IntentFilter();
    filter.setPriority(Integer.MAX_VALUE);
    filter.addAction(ACTION_REMOTE_BACKWARD);
    filter.addAction(ACTION_REMOTE_PLAYPAUSE);
    filter.addAction(ACTION_REMOTE_PLAY);
    filter.addAction(ACTION_REMOTE_PAUSE);
    filter.addAction(ACTION_REMOTE_STOP);
    filter.addAction(ACTION_REMOTE_FORWARD);
    filter.addAction(ACTION_REMOTE_LAST_PLAYLIST);
    filter.addAction(ACTION_WIDGET_INIT);
    filter.addAction(Intent.ACTION_HEADSET_PLUG);
    filter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    filter.addAction(VLCApplication.SLEEP_INTENT);
    registerReceiver(serviceReceiver, filter);

    final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    boolean stealRemoteControl = pref.getBoolean("enable_steal_remote_control", false);

    if (!LibVlcUtil.isFroyoOrLater() || stealRemoteControl) {
        /* Backward compatibility for API 7 */
        filter = new IntentFilter();
        if (stealRemoteControl)
            filter.setPriority(Integer.MAX_VALUE);
        filter.addAction(Intent.ACTION_MEDIA_BUTTON);
        mRemoteControlClientReceiver = new RemoteControlClientReceiver();
        registerReceiver(mRemoteControlClientReceiver, filter);
    }
}
 

开发者ID:smyhvae,
项目名称:VlcTest,
代码行数:54,
代码来源:AudioService.java

示例21: setRingtone

点赞 2

import org.videolan.libvlc.LibVlcUtil; //导入依赖的package包/类
public static void setRingtone( Media song, Activity activity){
    File newringtone = LibVlcUtil.URItoFile(song.getLocation());
    if(!newringtone.exists()) {
        Toast.makeText(activity.getApplicationContext(),activity.getString(R.string.ringtone_error), Toast.LENGTH_SHORT).show();
        return;
    }

    ContentValues values = new ContentValues();
    values.put(MediaStore.MediaColumns.DATA, newringtone.getAbsolutePath());
    values.put(MediaStore.MediaColumns.TITLE, song.getTitle());
    values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/*");
    values.put(MediaStore.Audio.Media.ARTIST, song.getArtist());
    values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
    values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false);
    values.put(MediaStore.Audio.Media.IS_ALARM, false);
    values.put(MediaStore.Audio.Media.IS_MUSIC, false);

    Uri uri = MediaStore.Audio.Media.getContentUriForPath(newringtone.getAbsolutePath());
    Uri newUri;
    try {
        activity.getContentResolver().delete(uri, MediaStore.MediaColumns.DATA + "=\"" + newringtone.getAbsolutePath() + "\"", null);
        newUri = activity.getContentResolver().insert(uri, values);
        RingtoneManager.setActualDefaultRingtoneUri(
                activity.getApplicationContext(),
                RingtoneManager.TYPE_RINGTONE,
                newUri
                );
    } catch(Exception e) {
        Toast.makeText(activity.getApplicationContext(),
                activity.getString(R.string.ringtone_error),
                Toast.LENGTH_SHORT).show();
        return;
    }

    Toast.makeText(
            activity.getApplicationContext(),
            activity.getString(R.string.ringtone_set, song.getTitle()),
            Toast.LENGTH_SHORT)
            .show();

}
 

开发者ID:KlepikovMD,
项目名称:popcorntime-android-kitkat,
代码行数:42,
代码来源:AudioUtil.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)