我有一个媒体播放器,但是当选择另一个文件时,它会继续播放旧文件和新文件,因此它会同时播放两个文件,这是我的 onCreate 方法
private MediaPlayer mediaplayer = new MediaPlayer();
private Handler handler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.songplaying);
// Getting Our Extras From Intent
Bundle names = getIntent().getExtras();
// Getting Specific Data
path = names.getString("pathkeyword");
//Start Player
try {
playAudio(path);
} catch (Exception e) {
e.printStackTrace();
Run Code Online (Sandbox Code Playgroud)
}
这是播放音频的方法
private void playAudio(String url) throws Exception{
mediaplayer.release();
mediaplayer.setDataSource(url);
mediaplayer.prepare();
mediaplayer.start();
Run Code Online (Sandbox Code Playgroud) 我希望在我的游戏中添加视频(例如过场动画或动画菜单屏幕)。
我环顾四周,似乎 pygame 不再支持视频播放,所以我想知道是否有另一种方法可以在很好地集成到我的游戏中的同时播放视频,例如让视频在后台播放并让pygame 元素(开始按钮等)在前台。
我正在尝试从我的反应网站访问公开共享的谷歌驱动器视频文件,因为谷歌驱动器文件不是绝对可下载的文件,我正在尝试使用自定义播放器播放谷歌驱动器视频,所以在播放器中显示视频之前,我需要使用 XHR 请求提取绝对文件 url。但是我无法使用 XHR 访问 googledrive.com,因为它只会收到 CORS 错误。有没有办法从客户端域请求其他服务器域而不需要任何服务器端更改?
我有一个问题,无法在我的 JavaFX 项目中导入 MediaPlayer。我正在使用 IntelliJ 和 Maven 构建,JDK 17 ..我更新了 Maven 依赖项,并且安装了 JavaFX 插件,但它仍然无法工作。.提前感谢您的任何答案/建议
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>1.0-SNAPSHOT</version>
<name>demo</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.7.1</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17.0.0.1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.7</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean …Run Code Online (Sandbox Code Playgroud) 有人建议如何以编程方式检测是否安装了Windows Media Player?
我知道注册表设置查找,但不要相信它,因为它有点误导(卸载可能不会删除它).而且我考虑过只是推出一个视频,但是错误可能是因为没有安装Media Player而引起的,所以它也不是决定性的.
理想情况下,我更喜欢可以从我的C++应用程序和我的NSIS安装程序中使用的解决方案.但我的C++应用程序是最重要的,我愿意接受安装程序中的注册表黑客攻击.
当我使用prepare(); 在我的媒体播放器上,一个黑色的布局弹出,直到准备好媒体播放器.我想改变黑屏的布局,这可能吗?
我正在为Windows 8开发媒体播放器,我需要阅读Windows Media Player媒体库中的所有音乐.
我怎么能在WinRT C#中做到这一点?
谢谢
c# media-player windows-8 windows-runtime windows-store-apps
这就是我在控制器中所拥有的:
@FXML
private MediaView mediaView;
Run Code Online (Sandbox Code Playgroud)
在处理按钮按下的方法中我得到了filechooser:
File file = fileChooser.showOpenDialog(null);
if(file != null){
initPlayer(file.toURI().toString());
}
Run Code Online (Sandbox Code Playgroud)
这是方法initPlayer:
private void initPlayer (String uri) {
if (uri == null)
return;
if (mediaPlayer != null) {
mediaPlayer.stop();
mediaPlayer = null;
}
Media media = new Media(uri);
mediaPlayer = new MediaPlayer(media);
mediaPlayer.setAutoPlay(true);
mediaView = new MediaView(mediaPlayer);
mediaPlayer.setOnReady(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
}
});
}
Run Code Online (Sandbox Code Playgroud)
这是我在场景构建器中创建的视图中的代码的一部分:
<Pane layoutX="80.0" layoutY="14.0" prefHeight="480.0" prefWidth="640.0">
<MediaView fx:id="mediaView" fitHeight="480.0" fitWidth="640.0" />
</Pane>
Run Code Online (Sandbox Code Playgroud)
当我选择文件时,我听到了声音,但我看不到视频.这段代码有什么问题?我错过了什么?
我正试图OnItemClick从ListView我设置的声音中播放声音.
我收到错误" create(Context, int)类型中的方法MediaPlayer不适用于参数(new AdapterView.OnItemClickListener(){}, int)"带"创建"下划线.
不是100%肯定为什么我得到这个错误,如果有人可以提供帮助,将不胜感激.
ListView BoardList = (ListView) findViewById(R.id.BoardList);
BoardList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
String List[] = {"Play 1", "Play 2", "Play 3", "Play 4", "Play 5", "Play 6", "Play 7", "Play 8", "Play 9" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.listcustomize, R.id.textItem, List);
BoardList.setAdapter(adapter);
BoardList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position == 0) {
MediaPlayer mPlayer = MediaPlayer.create(this, R.raw.Audio1);
mPlayer .start();
} …Run Code Online (Sandbox Code Playgroud) 我为Windows Phone 8.1开发了音乐应用程序.我使用BackgroundTask并访问手机音乐库.应用程序在具有虚拟SD卡的模拟器上工作正常,但在设备上不起作用.在设备上尝试播放时,会发生错误:
Failed with error code System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Run Code Online (Sandbox Code Playgroud)
此问题代码,发生错误.为简单城市放置在前台应用程序中的代码:
BackgroundMediaPlayer.Current.SetUriSource(new Uri("C:\\Data\\Users\\Public\\Music\\Ballroom\\Juan Camus - Now That The Love's Gone.mp3"));
BackgroundMediaPlayer.Current.Play();
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?
background-music media-player audio-player windows-phone windows-phone-8.1